1
zrg
2024-11-06 fa997057189d83a4dacb629c7e898d4b5a4d867f
WebAPI/Controllers/BaseSet/Gy_CustomerController.cs
@@ -12,8 +12,8 @@
using SyntacticSugar.constant;
using System.Web;
using WebAPI.Controllers.SCGL.日计划管理;
using WebAPI.WebBLL.JCJM.GYZL;
using WebAPI.WebBLL.JCJM.IMPL;
//using WebAPI.WebBLL.JCJM.GYZL;
//using WebAPI.WebBLL.JCJM.IMPL;
using System.IO;
namespace WebAPI.Controllers
{
@@ -25,7 +25,7 @@
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        private Gy_CustomerService customerService = new Gy_CustomerImpl();
        //private Gy_CustomerService customerService = new Gy_CustomerImpl();
        DataSet ds;
        #region 返回客户列表
@@ -101,6 +101,73 @@
            }
        }
        #endregion
        #region 客户分页列表
        [Route("Gy_Customer/page")]
        [HttpGet]
        public json Gy_CustomerPage(string sWhere, string user, int page, int size, string Organization)
        {
            DataSet ds;
            json res = new json();
            try
            {
                List<object> columnNameList = new List<object>();
                //判断权限
                if (!DBUtility.ClsPub.Security_Log_second("Crm_CustomerFileList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //客户制定
                string sErr = "";
                if (oSystemParameter.ShowBill(ref sErr))
                {
                    if (oSystemParameter.omodel.WMS_CampanyName != "乔一")
                    {
                        sWhere += ("and 组织名称 = '" + Organization + "'");
                    }
                }
                sWhere = sWhere.Replace("'", "''");
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_Gy_CustomerList " + page + "," + size + ",''", "h_p_Gy_CustomerList");
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_Gy_CustomerList " + page + "," + size + ",'" + sWhere + "'", "h_p_Gy_CustomerList");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                res.code = CodeConstant.SUCCEED;
                res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                res.Message = "Sucess!";
                res.list = columnNameList;
                res.data = ds.Tables[0];
                return res;
            }
            catch (Exception e)
            {
                res.code = CodeConstant.FAIL;
                res.count = CountConstant.FAIL;
                res.Message = "Exception!" + e.ToString();
                res.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 客户子表[关联用户] 查询
        /// <summary>
@@ -1367,41 +1434,41 @@
        #endregion
        #region 客户列表 文件上传
        [Route("Gy_Customer/Gy_Process_Excel")]
        [HttpPost]
        public json Gy_Department_Excel()
        {
            json res = new json();
            try
            {
                //获取文件名称
                var file = HttpContext.Current.Request.Files[0];
                //获取文件物理路径
                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
                //保存文件
                file.SaveAs(ExcelPath);
        //[Route("Gy_Customer/Gy_Process_Excel")]
        //[HttpPost]
        //public json Gy_Department_Excel()
        //{
        //    json res = new json();
        //    try
        //    {
        //        //获取文件名称
        //        var file = HttpContext.Current.Request.Files[0];
        //        //获取文件物理路径
        //        string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
        //        //保存文件
        //        file.SaveAs(ExcelPath);
                NpoiHelper np = new NpoiHelper();
                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
                //删除文件
                File.Delete(ExcelPath);
                DataTable provisional = customerService.UploadExcel(ExcelDs);
        //        NpoiHelper np = new NpoiHelper();
        //        DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
        //        //删除文件
        //        File.Delete(ExcelPath);
        //        DataTable provisional = customerService.UploadExcel(ExcelDs);
                
                res.code = CodeConstant.SUCCEED;
                res.count = CountConstant.SUCCEED;
                res.Message = "上传成功";
                res.data = provisional;
                return res;
            }
            catch (Exception e)
            {
                res.code = "0";
                res.count = 0;
                res.Message = "Exception!" + e.ToString();
                res.data = null;
                return res;
            }
        }
        //        res.code = CodeConstant.SUCCEED;
        //        res.count = CountConstant.SUCCEED;
        //        res.Message = "上传成功";
        //        res.data = provisional;
        //        return res;
        //    }
        //    catch (Exception e)
        //    {
        //        res.code = "0";
        //        res.count = 0;
        //        res.Message = "Exception!" + e.ToString();
        //        res.data = null;
        //        return res;
        //    }
        //}
        /// <summary>
        /// 判断当前职员是否存在
@@ -1409,15 +1476,15 @@
        /// <param name="HEmpNumber"></param>
        /// <param name="HEmpName"></param>
        /// <returns></returns>
        private bool JudgeEmp(string HEmpNumber, string HEmpName)
        {
            if (!String.IsNullOrEmpty(HEmpNumber) && !String.IsNullOrEmpty(HEmpName))
            {
                DataSet emp = oCN.RunProcReturn("select * from Gy_Employee where HNumber = '" + HEmpNumber + "' and HName = '" + HEmpName + "'", "Gy_Employee");
                return emp.Tables[0].Rows.Count <= EmptyConstant.EMPTY ? true : false;
            }
            return false;
        }
        //private bool JudgeEmp(string HEmpNumber, string HEmpName)
        //{
        //    if (!String.IsNullOrEmpty(HEmpNumber) && !String.IsNullOrEmpty(HEmpName))
        //    {
        //        DataSet emp = oCN.RunProcReturn("select * from Gy_Employee where HNumber = '" + HEmpNumber + "' and HName = '" + HEmpName + "'", "Gy_Employee");
        //        return emp.Tables[0].Rows.Count <= EmptyConstant.EMPTY ? true : false;
        //    }
        //    return false;
        //}
        /// <summary>
        /// 判断列