Exemple #1
0
        private void SetInfo(Foresight.DataAccess.InsideCustomer data)
        {
            this.tdCustomerName.Value         = data.CustomerName;
            this.tdCategoryName.Value         = data.CategoryName;
            this.tdInteresting.Value          = data.Interesting;
            this.tdContactMan.Value           = data.ContactMan;
            this.tdContactPhone.Value         = data.ContactPhone;
            this.tdQQNo.Value                 = data.QQNo;
            this.tdQQGroupInvitation.Value    = data.QQGroupInvitation;
            this.tdWechatNo.Value             = data.WechatNo;
            this.tdWechaGroupInvitation.Value = data.WechaGroupInvitation;
            this.tdOtherContactMan.Value      = data.OtherContactMan;
            this.tdNewFollowup.Value          = string.Empty;
            this.tdBusinessStage.Value        = data.BusinessStage;
            this.tdCost.Value                 = data.Cost > 0 ? data.Cost.ToString() : "0";
            this.tdDealProbably.Value         = data.DealProbably;
            this.tdRemark.Value               = data.Remark;
            var    followupList           = Foresight.DataAccess.InsideCustomer_Followup.GetInsideCustomer_FollowupList(data.ID);
            string historyFollowupContent = string.Empty;

            foreach (var item in followupList)
            {
                historyFollowupContent += item.FollowupDate.ToString("yyyy-MM-dd HH:mm:ss") + ": " + item.FollowupContent + "。 ";
            }
            this.tdHistoryNewFollowup.Value = historyFollowupContent;
        }
        public static InsideCustomer[] GeInsideCustomerList(List <int> IDList, string OrderBy)
        {
            List <SqlParameter> parameters = new List <SqlParameter>();
            List <string>       conditions = new List <string>();

            conditions.Add("1=1");
            if (IDList.Count > 0)
            {
                conditions.Add("ID in (" + string.Join(",", IDList.ToArray()) + ")");
            }
            string fieldList = "select [InsideCustomer].* from [InsideCustomer] where " + string.Join(" and ", conditions.ToArray()) + " " + OrderBy;

            InsideCustomer[] list = new InsideCustomer[] { };
            list = GetList <InsideCustomer>(fieldList, parameters).ToArray();
            return(list);
        }
        public static Ui.DataGrid GeInsideCustomerGrid(string CustomerBelonger, DateTime StartTime, DateTime EndTime, string Region, string Province, string City, string CustomerName, string IndustryName, string CategoryName, string Interesting, string orderBy, long startRowIndex, int pageSize, bool canexport = false)
        {
            long totalRows = 0;
            List <SqlParameter> parameters = new List <SqlParameter>();
            List <string>       conditions = new List <string>();

            conditions.Add("1=1");
            if (!string.IsNullOrEmpty(CustomerBelonger))
            {
                conditions.Add("[CustomerBelonger] like @CustomerBelonger");
                parameters.Add(new SqlParameter("@CustomerBelonger", "%" + CustomerBelonger + "%"));
            }
            if (StartTime > DateTime.MinValue)
            {
                conditions.Add("[NewFollowupDate]>=@StartTime");
                parameters.Add(new SqlParameter("@StartTime", StartTime));
            }
            if (EndTime > DateTime.MinValue)
            {
                conditions.Add("[NewFollowupDate]<=@EndTime");
                parameters.Add(new SqlParameter("@EndTime", EndTime));
            }
            if (!string.IsNullOrEmpty(Region))
            {
                conditions.Add("[Region] like @Region");
                parameters.Add(new SqlParameter("@Region", "%" + Region + "%"));
            }
            if (!string.IsNullOrEmpty(Province))
            {
                conditions.Add("[Province] like @Province");
                parameters.Add(new SqlParameter("@Province", "%" + Province + "%"));
            }
            if (!string.IsNullOrEmpty(City))
            {
                conditions.Add("[City] like @City");
                parameters.Add(new SqlParameter("@City", "%" + City + "%"));
            }
            if (!string.IsNullOrEmpty(CustomerName))
            {
                conditions.Add("[CustomerName] like @CustomerName");
                parameters.Add(new SqlParameter("@CustomerName", "%" + CustomerName + "%"));
            }
            if (!string.IsNullOrEmpty(IndustryName))
            {
                conditions.Add("[IndustryName] like @IndustryName");
                parameters.Add(new SqlParameter("@IndustryName", "%" + IndustryName + "%"));
            }
            if (!string.IsNullOrEmpty(CategoryName))
            {
                conditions.Add("[CategoryName] like @CategoryName");
                parameters.Add(new SqlParameter("@CategoryName", "%" + CategoryName + "%"));
            }
            if (!string.IsNullOrEmpty(Interesting))
            {
                conditions.Add("[Interesting] like @Interesting");
                parameters.Add(new SqlParameter("@Interesting", "%" + Interesting + "%"));
            }
            string fieldList = "[InsideCustomer].*";
            string Statement = " from [InsideCustomer] where " + string.Join(" and ", conditions.ToArray());

            InsideCustomer[] list = new InsideCustomer[] { };
            if (canexport)
            {
                list = GetList <InsideCustomer>("select " + fieldList + Statement + " " + orderBy, parameters).ToArray();
            }
            else
            {
                list = GetList <InsideCustomer>(fieldList, Statement, parameters, orderBy, startRowIndex, pageSize, out totalRows).ToArray();
            }
            DataAccess.Ui.DataGrid dg = new Ui.DataGrid();
            dg.rows  = list;
            dg.total = totalRows;
            dg.page  = pageSize;
            return(dg);
        }
Exemple #4
0
        private void import(HttpContext context)
        {
            HttpFileCollection uploadFiles = context.Request.Files;

            if (uploadFiles.Count == 0)
            {
                context.Response.Write("请选择一个文件");
                return;
            }
            if (string.IsNullOrEmpty(uploadFiles[0].FileName))
            {
                context.Response.Write("请选择一个文件");
                return;
            }
            string msg          = string.Empty;
            int    CompanyID    = int.Parse(context.Request.Params["CompanyID"]);
            int    CreatorID    = int.Parse(context.Request.Params["CreatorID"]);
            string AddMan       = context.Request.Params["AddMan"];
            bool   ImportFailed = false;
            int    TotalNumber  = 0;

            titleList = Foresight.DataAccess.TableColumn.GetTableColumnByPageCode("insidecustomersource", true).Where(p => (!p.ColumnName.Equals("选择按钮") && !p.ColumnName.Equals("合同附件"))).ToArray();
            using (SqlHelper helper = new SqlHelper())
            {
                try
                {
                    helper.BeginTransaction();
                    #region 导入处理
                    for (int j = 0; j < uploadFiles.Count; j++)
                    {
                        HttpPostedFile postedFile = uploadFiles[j];
                        string         filepath   = HttpContext.Current.Server.MapPath("~/upload/Customer/" + DateTime.Now.ToString("yyyyMMdd"));
                        if (!System.IO.Directory.Exists(filepath))
                        {
                            System.IO.Directory.CreateDirectory(filepath);
                        }
                        string filename = DateTime.Now.ToLocalTime().ToString("yyyyMMddHHmmss") + "_" + postedFile.FileName;
                        string fullpath = Path.Combine(filepath, filename);
                        postedFile.SaveAs(fullpath);
                        DataTable table = ExcelExportHelper.NPOIReadExcel(fullpath);
                        for (int i = 0; i < table.Rows.Count; i++)
                        {
                            Foresight.DataAccess.InsideCustomer customer = null;
                            object Value = null, CustomerName = null, ContactPhone = null;
                            if (GetColumnValue("客户名称", table, i, out CustomerName))
                            {
                                if (!string.IsNullOrEmpty(CustomerName.ToString()))
                                {
                                    customer = Foresight.DataAccess.InsideCustomer.GeInsideCustomerByParams(CustomerName.ToString(), string.Empty, helper);
                                }
                            }
                            if (customer != null)
                            {
                                msg         += "<p>第" + (i + 2) + "行上传失败。原因:客户已存在</p>";
                                ImportFailed = true;
                                break;
                            }
                            if (GetColumnValue("联系方式", table, i, out ContactPhone))
                            {
                                if (!string.IsNullOrEmpty(ContactPhone.ToString()))
                                {
                                    customer = Foresight.DataAccess.InsideCustomer.GeInsideCustomerByParams(string.Empty, ContactPhone.ToString(), helper);
                                }
                            }
                            if (customer != null)
                            {
                                msg         += "<p>第" + (i + 2) + "行上传失败。原因:客户已存在</p>";
                                ImportFailed = true;
                                break;
                            }
                            customer = new Foresight.DataAccess.InsideCustomer();
                            if (GetColumnValue("客户名称", table, i, out Value))
                            {
                                customer.CustomerName = Value.ToString();
                            }
                            if (GetColumnValue("行业", table, i, out Value))
                            {
                                customer.IndustryName = Value.ToString();
                            }
                            if (GetColumnValue("分类", table, i, out Value))
                            {
                                customer.CategoryName = Value.ToString();
                            }
                            if (GetColumnValue("意向分析", table, i, out Value))
                            {
                                customer.Interesting = Value.ToString();
                            }
                            if (GetColumnValue("联系人", table, i, out Value))
                            {
                                customer.ContactMan = Value.ToString();
                            }
                            if (GetColumnValue("联系方式", table, i, out Value))
                            {
                                customer.ContactPhone = Value.ToString();
                            }
                            if (GetColumnValue("QQ", table, i, out Value))
                            {
                                customer.QQNo = Value.ToString();
                            }
                            if (GetColumnValue("QQ群邀约", table, i, out Value))
                            {
                                customer.QQGroupInvitation = Value.ToString();
                            }
                            if (GetColumnValue("微信", table, i, out Value))
                            {
                                customer.WechatNo = Value.ToString();
                            }
                            if (GetColumnValue("微信群邀约", table, i, out Value))
                            {
                                customer.WechaGroupInvitation = Value.ToString();
                            }
                            if (GetColumnValue("其他联系人", table, i, out Value))
                            {
                                customer.OtherContactMan = Value.ToString();
                            }
                            if (GetColumnValue("客户所有者", table, i, out Value))
                            {
                                customer.CustomerBelonger = Value.ToString();
                            }
                            if (GetColumnValue("跟进日期", table, i, out Value))
                            {
                                DateTime NewFollowupDate = DateTime.MinValue;
                                DateTime.TryParse(Value.ToString(), out NewFollowupDate);
                                customer.NewFollowupDate = NewFollowupDate;
                            }
                            if (GetColumnValue("跟进记录", table, i, out Value))
                            {
                                customer.NewFollowup = Value.ToString();
                            }
                            if (GetColumnValue("区域", table, i, out Value))
                            {
                                customer.Region = Value.ToString();
                            }
                            if (GetColumnValue("省区", table, i, out Value))
                            {
                                customer.Province = Value.ToString();
                            }
                            if (GetColumnValue("城市", table, i, out Value))
                            {
                                customer.City = Value.ToString();
                            }
                            if (GetColumnValue("商务阶段", table, i, out Value))
                            {
                                customer.BusinessStage = Value.ToString();
                            }
                            if (GetColumnValue("报价", table, i, out Value))
                            {
                                decimal Cost = decimal.MinValue;
                                decimal.TryParse(Value.ToString(), out Cost);
                                customer.Cost = Cost;
                            }
                            if (GetColumnValue("成交可能性", table, i, out Value))
                            {
                                customer.DealProbably = Value.ToString();
                            }
                            if (GetColumnValue("备注", table, i, out Value))
                            {
                                customer.Remark = Value.ToString();
                            }
                            customer.AddTime = DateTime.Now;
                            customer.AddMan  = WebUtil.GetUser(context).RealName;
                            customer.Save(helper);
                            TotalNumber = i;
                        }
                    }
                    #endregion
                    if (!ImportFailed)
                    {
                        helper.Commit();
                        msg += "<p>导入完成</p>";
                    }
                    else
                    {
                        helper.Rollback();
                        msg += "<p>导入失败</p>";
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteError("ImportCustomerHandler", "visit: import", ex);
                    helper.Rollback();
                    msg += "<p>第" + (TotalNumber + 2) + "行上传失败。原因:" + ex.Message + "</p>";
                }
                context.Response.Write(msg);
            }
        }