예제 #1
0
        public string GetCustInfo(string query)
        {
            int    RecordCount = 0;
            string Filter      = "CustTel.Contains(\"" + query + "\") or CustName.Contains(\"" + query + "\")";
            //只取前10个
            IList <vw_CRMCustomer2> CustList = svr.SearchByCriteria(0, 10, out RecordCount, Filter, "CustName", null, null, null, 0);

            //----------------------------------------
            if (CustList.Count > 0)
            {
                vw_CRMCustomer2 cust = CustList[0];

                string CustInfo = string.Empty;
                CustInfo = cust.CustID + "$$" + cust.CustName + "$$" + cust.CustType + "$$" + cust.FavoriteProd
                           + "$$" + cust.PreferPrice + "$$" + cust.PreferPlace;

                string DealInfo = "$$$$";

                Filter = " and CustID=" + cust.CustID.ToString();
                string OrderBy = "DealDate Desc";

                var dtDeal = svr.SearchByCriteria(typeof(vw_CRMCustomerDeal), 0, 1,
                                                  out RecordCount, Filter, OrderBy);
                if (dtDeal.Rows.Count > 0)
                {
                    DealInfo = dtDeal.Rows[0]["ContractNum"] + "$$" + dtDeal.Rows[0]["TotalAmount"] + "$$" + dtDeal.Rows[0]["DealOwnerName"];
                }
                return(CustInfo + "$$" + DealInfo);
            }
            else
            {
                return("$$ $$ $$ $$ $$ $$ $$ $$ ");
            }
        }
예제 #2
0
        //Row Data Bound
        protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                // for the Footer, display the running totals
                e.Row.Cells[0].ColumnSpan = e.Row.Cells.Count;
                e.Row.Cells[0].Text       = GetREMes("lblTotalRecords") + "  " + recordCount.ToString();
                for (int i = 1; i < e.Row.Cells.Count; i++)
                {
                    e.Row.Cells[i].Visible = false;
                }
            }
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (ConfigurationManager.AppSettings["Industry"].ToLower() == "chemical")
                {
                    e.Row.FindControl("lnkTicket").Visible = false;
                    e.Row.FindControl("lnkVisum").Visible  = false;
                }
                else
                {
                    e.Row.FindControl("lnkTel").Visible   = false;
                    e.Row.FindControl("lnkVisit").Visible = false;

                    e.Row.FindControl("lnkBid").Visible  = false;
                    e.Row.FindControl("lnkDeal").Visible = false;
                }
                //Button btnDel = (Button)e.Row.FindControl("lnkDel");
                //btnDel.Attributes.Add("onclick", "onDel('" + btnDel.UniqueID + "');return false;");
                //是否花自己钱 true/false-> 是/否
                if (e.Row.Cells[6].Text == "True")
                {
                    e.Row.Cells[6].Text = "是";
                }
                else if (e.Row.Cells[6].Text == "False")
                {
                    e.Row.Cells[6].Text = "不是";
                }
                else
                {
                    e.Row.Cells[6].Text = "";
                }
                System.Web.UI.WebControls.Image imgIdle = (System.Web.UI.WebControls.Image)e.Row.FindControl("imgIdle");

                if (e.Row.DataItem.GetType() == typeof(vw_CRMCustomer2))
                {
                    vw_CRMCustomer2 cust = (vw_CRMCustomer2)e.Row.DataItem;

                    //根据成交时间不同,显示不同的颜色,绿,黄,红,灰
                    if (cust.LatestDealDate == null)
                    {
                        e.Row.BackColor = ColorTranslator.FromHtml("#F1F3F5");
                    }
                    else
                    {
                        TimeSpan ts = DateTime.Now - (DateTime)cust.LatestDealDate;
                        if (ts.Days <= 30)
                        {
                            e.Row.BackColor = Color.LightGreen;
                        }
                        else if (ts.Days > 30 && ts.Days <= 90)
                        {
                            e.Row.BackColor = Color.Yellow;
                        }
                        else
                        {
                            e.Row.BackColor = Color.Red;
                        }
                    }

                    var IdleDays = cust.IdleDays;
                    //现在行动记录变成15天没联系才提醒...
                    if (IdleDays > 15)
                    {
                        imgIdle.ImageUrl = "../images/report.gif";
                    }
                    else
                    {
                        imgIdle.ImageUrl = "../images/setup.png";
                    }
                }
                string sId = gvData.DataKeys[e.Row.RowIndex].Value.ToString();

                //最后一列是按钮,该单元格不要onclick
                for (int i = 0; i < e.Row.Cells.Count - 2; i++)
                {
                    e.Row.Cells[i].Attributes.Add("onclick", "onEdit('" + sId + "','" + EditURL + "'); return false;");
                }
            }
        }