Exemple #1
0
 /// <summary>
 /// 更新客户信息
 /// </summary>
 /// <param name="newObj"></param>
 public void UpdateCustomer(cst_customer newObj)
 {
     if (newObj.cust_manager_id > 0)
     {
         newObj.cust_manager_name = new sys_userRepository().GetUserByUserId(newObj.cust_manager_id.Value).usr_name;
     }
     new cst_customerRepository().UpdateCustomer(newObj);
 }
        public ActionResult Update(FormCollection forms)
        {
            //cst_customer c = new cst_customer();
            //c.cust_no = forms["cust_no"];
            //if (int.TryParse(forms["cust_Id"], out int id))
            //{
            //    c.cust_Id = id;
            //}
            //var linq = new LinqHelper();
            //linq.Db.Set<cst_customer>().Attach(c);

            //foreach (var p in c.GetType().GetProperties())
            //{
            //    var propName = p.Name;
            //    var proType = p.PropertyType;
            //    if (proType.Name.Contains("ICollection"))
            //    {
            //        continue;
            //    }
            //    {
            //        var o = Coommon.Cast(p.PropertyType.Name, forms[propName]);
            //        c.GetType().GetProperty(propName).SetValue(c, o);
            //    }
            //}
            //linq.Db.Entry<cst_customer>(c).State = System.Data.Entity.EntityState.Modified;
            //linq.Db.SaveChanges();

            Dictionary <string, object> dic = new Dictionary <string, object>();

            //保存客户等级管理人姓名
            cst_customer c = new cst_customer();

            if (int.TryParse(forms["cust_manager_id"], out int val))
            {
                var name = new LinqHelper().Db.sys_user.Where(u => u.usr_id == val).Select(u => u.usr_name).FirstOrDefault();
                dic.Add("cust_manager_name", name);
            }
            if (int.TryParse(forms["cust_level"], out int val1))
            {
                var level_label = Common.GetCstManaName("cust_level", val1.ToString());
                dic.Add("cust_level_label", level_label);
            }

            foreach (var key in forms.AllKeys)
            {
                dic.Add(key, forms[key]);
            }

            Common.UpdateSomeFiel <cst_customer>(c, dic, new LinqHelper().Db);
            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// 根据搜索条件获得客户信息集合
        /// </summary>
        /// <param name="searchEntity"></param>
        /// <returns></returns>
        public List <cst_customer> GetCustomersBySearchEntity(cst_customer searchEntity)
        {
            List <cst_customer> list = (from c in LinqHelper.GetDataContext().cst_customer
                                        where c.cust_no.Contains(searchEntity.cust_no == null ? "" : searchEntity.cust_no) &&
                                        c.cust_name.Contains(searchEntity.cust_name == null ? "" : searchEntity.cust_name) &&
                                        c.cust_manager_name.Contains(searchEntity.cust_manager_name == null ? "" : searchEntity.cust_manager_name) &&
                                        c.cust_region.Contains(searchEntity.cust_region == null?"":searchEntity.cust_region)
                                        orderby c.cust_Id descending
                                        select c).ToList();

            if (searchEntity.cust_level > 0)
            {
                list = list.Where(c => c.cust_level == searchEntity.cust_level).ToList();
            }
            return(list);
        }
Exemple #4
0
        /// <summary>
        /// 开发成功
        /// </summary>
        /// <param name="id">计划编号</param>
        /// <param name="userId">当前用户编号</param>
        /// <param name="userName">当前用户名称</param>
        public void PlanOk(int id, int userId, string userName)
        {
            sal_chance   sal   = new sal_chanceService().GetSalById(id);
            cst_customer cst   = new cst_customer();
            cst_linkman  lkman = new cst_linkman();

            //编号
            cst.cust_no           = "KH" + new Random().Next(10000000, 99999999);
            cst.cust_name         = sal.chc_cust_name;
            cst.cust_manager_id   = userId;
            cst.cust_manager_name = userName;
            lkman.lkm_name        = sal.chc_linkman;
            lkman.lkm_mobile      = sal.chc_tel;
            lkman.lkm_cust_name   = sal.chc_cust_name;
            lkman.lkm_cust_no     = cst.cust_no;
            new cst_customerRepository().AddCustomer(cst);
            new cst_linkmanRepository().AddLinkMan(lkman);
            new sal_chanceRepository().PlanOk(id);
        }
 /// <summary>
 /// 更新客户信息
 /// </summary>
 /// <param name="newObj"></param>
 public void UpdateCustomer(cst_customer newObj)
 {
     new LinqHelper().UpadateEntity <cst_customer>(newObj);
 }
 /// <summary>
 /// 添加客户公司
 /// </summary>
 /// <param name="cst"></param>
 public void AddCustomer(cst_customer cst)
 {
     new LinqHelper().InsertEntity <cst_customer>(cst);
 }
Exemple #7
0
 /// <summary>
 /// 根据搜索条件获得客户信息集合
 /// </summary>
 /// <param name="searchEntity"></param>
 /// <returns></returns>
 public List <cst_customer> GetCustomersBySearchEntity(cst_customer searchEntity)
 {
     return(new cst_customerRepository().GetCustomersBySearchEntity(searchEntity));
 }