Ejemplo n.º 1
0
        public IHttpActionResult AddCustomer()
        {
            string name = requestHelper.GetRequsetForm("customerName", "");
            string tel  = requestHelper.GetRequsetForm("tel", "");

            if (string.IsNullOrEmpty(name))
            {
                return(Ok(ReturnJsonResult.ToJson(-1, "客户名称不能为空!", "")));
            }
            if (string.IsNullOrEmpty(tel))
            {
                return(Ok(ReturnJsonResult.ToJson(-1, "联系电话不能为空!", "")));
            }
            Model.Customers model = new Model.Customers();
            model.CustomerName = name;
            model.Tel          = tel;
            int i = bll.Add(model);

            if (i > 0)
            {
                return(Ok(ReturnJsonResult.ToJson(1, "添加成功!", "")));
            }

            return(Ok(ReturnJsonResult.ToJson(-1, "添加失败!", "")));
        }
Ejemplo n.º 2
0
        public int AddCustomers(Model.Customers model)
        {
            StringBuilder strSql = new StringBuilder();//Id, CreateDate,

            strSql.Append("insert into Customers values(@CusCode, @CusName, @State, @CusType, @CusLevel, GETDATE(),@SalesmanId, @ServicerId, @Remark)");
            SqlParameter[] paras = new SqlParameter[] {
                new SqlParameter("@CusCode", model.CusCode),
                new SqlParameter("@CusName", model.CusName),
                new SqlParameter("@State", model.State),
                new SqlParameter("@CusType", model.CusType),
                new SqlParameter("@CusLevel", model.CusLevel),
                new SqlParameter("@SalesmanId", model.SalesmanId),
                new SqlParameter("@ServicerId", model.ServicerId),
                new SqlParameter("@Remark", model.Remark)
            };
            using (SqlConnection con = new SqlConnection(ZGZY.Common.SqlHelper.connStr))
            {
                con.Open();
                SqlCommand com = new SqlCommand(strSql.ToString(), con);
                com.Parameters.AddRange(paras);

                int sum = com.ExecuteNonQuery();
                return(sum);
            }
        }
Ejemplo n.º 3
0
        public Model.Customers GetCustomersById(object ID)
        {
            StringBuilder strsql = new StringBuilder();

            strsql.Append("select * from Customers where Id=@id");
            using (SqlConnection con = new SqlConnection(ZGZY.Common.SqlHelper.connStr))
            {
                con.Open();
                SqlCommand com = new SqlCommand(strsql.ToString(), con);
                com.Parameters.Add(new SqlParameter("@id", ID));
                SqlDataReader read = com.ExecuteReader();
                while (read.Read())
                {
                    ZGZY.Model.Customers model = new Model.Customers();
                    model.Id         = int.Parse(read["id"].ToString());
                    model.State      = int.Parse(read["State"].ToString());
                    model.CusType    = int.Parse(read["CusType"].ToString());
                    model.CusLevel   = int.Parse(read["CusLevel"].ToString());
                    model.CusCode    = read["CusCode"].ToString();
                    model.CusName    = read["CusName"].ToString();
                    model.CreateDate = DateTime.Parse(read["CreateDate"].ToString());
                    model.SalesmanId = int.Parse(read["SalesmanId"].ToString());
                    model.ServicerId = int.Parse(read["ServicerId"].ToString());
                    model.Remark     = read["Remark"].ToString();
                    return(model);
                }
            }
            return(null);
        }
 public CustomerBuyProcces(int musteriID)
 {
     this.musteriID = musteriID;
     InitializeComponent();
     cust                  = CD.MusteriIDyeGöreAra(musteriID);
     label3.Text           = cust.CustomerName + cust.CustomerSurname + " müşterisinin hangi tarihler arasındaki satın\n alımlarını görmek istiyorsunuz ?";
     dateTimePicker1.Value = DateTime.Now.AddDays(-30);
 }
Ejemplo n.º 5
0
 public int EditCustomers(Model.Customers model)
 {
     if (model != null)
     {
         StringBuilder       strsql = new StringBuilder();
         List <SqlParameter> list   = new List <SqlParameter>();
         if (model.CusName != "")
         {
             strsql.Append("CusName=@CusName,");
         }
         list.Add(new SqlParameter("@CusName", model.CusName));
         if (model.State != -1)
         {
             strsql.Append("[State]=@State,");
         }
         list.Add(new SqlParameter("@State", model.State));
         if (model.CusType != -1)
         {
             strsql.Append(" CusType=@CusType,");
         }
         list.Add(new SqlParameter("@CusType", model.CusType));
         if (model.CusLevel >= 0)
         {
             strsql.Append("CusLevel=@CusLevel,");
         }
         list.Add(new SqlParameter("@CusLevel", model.CusLevel));
         if (model.SalesmanId != 0)
         {
             strsql.Append("SalesmanId=@SalesmanId,");
         }
         list.Add(new SqlParameter("@SalesmanId", model.SalesmanId));
         if (model.ServicerId != 0)
         {
             strsql.Append("ServicerId=@ServicerId,");
         }
         list.Add(new SqlParameter("@ServicerId", model.ServicerId));
         if (model.Remark != null)
         {
             strsql.Append("Remark=@Remark,");
         }
         list.Add(new SqlParameter("@Remark", model.Remark));
         if (strsql.Length > 0)
         {
             strsql.Remove(strsql.Length - 1, 1);
             strsql.Append(" where  Id=@Id ");
             list.Add(new SqlParameter("@Id", model.Id));
             return(ZGZY.Common.SqlHelper.ExecuteNonQuery(ZGZY.Common.SqlHelper.connStr, CommandType.Text, "update Customers set " + strsql.ToString(), list.ToArray()));
         }
     }
     return(-1);
 }
Ejemplo n.º 6
0
        public void UpdateChancesOK(int ChanID)
        {
            JavaScriptSerializer json = new JavaScriptSerializer();


            Model.Chances model = new Model.Chances
            {
                ChanID    = ChanID,
                ChanState = 3,
            };
            int[] a = new int[4];
            a = GetRandomByGuid(a);


            string bh = "KH" + DateTime.Now.ToString("yyyyMMdd");

            for (int j = 0; j < a.Length; j++)
            {
                bh += a[j];
            }

            Model.Chances   add = new BLL.Chances().GetModel(ChanID);
            Model.Customers cus = new Model.Customers
            {
                CusName  = add.ChanName,
                CusID    = bh,
                UserID   = add.ChanDueMan,
                CusState = 1
            };

            bool check = new BLL.Chances().SetChanceSuccess(model);

            if (check)
            {
                bool i = new BLL.Customers().Add(cus);
                if (i)
                {
                    Context.Response.Write(0);
                }
            }
            else
            {
                Context.Response.Write(0);
            }
        }
Ejemplo n.º 7
0
        public List <Model.Customers> SelectAllCustomers(Model.Customers customers, int size, int pageindex)
        {
            StringBuilder str = new StringBuilder();

            if (!string.IsNullOrEmpty(customers.CusName))
            {
                str.AppendFormat(" and a.CusName like '%{0}%' ", customers.CusName);
            }
            if (!string.IsNullOrEmpty(customers.UserName))
            {
                str.AppendFormat(" and b.UserName like '%{0}%' ", customers.UserName);
            }
            if (!string.IsNullOrEmpty(Convert.ToString(customers.CusDate)))
            {
                var cusdate = Convert.ToDateTime(customers.CusDate).ToString("yyyy-MM-dd");
                str.AppendFormat(" and convert(varchar(10),CusDate,120)='{0}' ", cusdate);
            }

            BLL.Customers bookinfoBLL = new BLL.Customers();

            return(bookinfoBLL.GetModelList(str.ToString(), "1>0" + str.ToString(), size, pageindex));
        }
Ejemplo n.º 8
0
        public List <Model.Customers> GetCustomersTbaleNoP()
        {
            List <Model.Customers> list = new List <Model.Customers>();
            SqlDataReader          read = dal.GetCustomersTbaleNoP();

            while (read.Read())
            {
                Model.Customers modelcus = new Model.Customers();

                modelcus.Id         = Int32.Parse(read["Id"].ToString());
                modelcus.CusCode    = read["CusCode"].ToString();
                modelcus.CusName    = read["CusName"].ToString();
                modelcus.State      = Int32.Parse(read["State"].ToString());
                modelcus.CusType    = Int32.Parse(read["CusType"].ToString());
                modelcus.CusLevel   = Int32.Parse(read["CusLevel"].ToString());
                modelcus.CreateDate = DateTime.Parse(read["CreateDate"].ToString() == "" ? null : read["CreateDate"].ToString());
                modelcus.SalesmanId = Int32.Parse(read["SalesmanId"].ToString());
                modelcus.ServicerId = Int32.Parse(read["ServicerId"].ToString());
                modelcus.Remark     = read["Remark"].ToString();
                list.Add(modelcus);
            }

            return(list);
        }
Ejemplo n.º 9
0
        public bool Update(Model.Customers customers)
        {
            BLL.Customers bookinfoBLL = new BLL.Customers();

            return(bookinfoBLL.Update(customers));
        }
Ejemplo n.º 10
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            ZGZY.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                ZGZY.Model.User user = ZGZY.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;
                switch (action)
                {
                case "getbutton":                                            //根据用户的权限获取用户点击的菜单有权限的按钮
                    string    pageName = context.Request.Params["pagename"];
                    string    menuCode = context.Request.Params["menucode"]; //菜单标识码
                    DataTable dt       = new ZGZY.BLL.Customers().GetButtonByMenuCodeAndUserId(menuCode, user.Id);
                    context.Response.Write(ZGZY.Common.ToolbarHelper.GetToolBar(dt, pageName));
                    break;

                case "add":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("customers", "add", user.Id))
                    {
                        ZGZY.Model.Customers CustomersAdd = new Model.Customers();
                        CustomersAdd.CusName    = context.Request.Params["ui_Customers_CusName_add"] ?? "";
                        CustomersAdd.State      = Convert.ToInt32(context.Request.Params["ui_Cutomers_State_add"]);
                        CustomersAdd.CusType    = Convert.ToInt32(context.Request.Params["ui_Cutomers_CusType_add"]);
                        CustomersAdd.CusLevel   = Convert.ToInt32(context.Request.Params["ui_Customers_CusLevel"]);
                        CustomersAdd.Remark     = context.Request.Params["ui_Customers_Remark_add"] ?? "";
                        CustomersAdd.SalesmanId = 72;
                        CustomersAdd.ServicerId = 72;
                        CustomersAdd.CusCode    = DateTime.Now.ToString();
                        int departmentId = new ZGZY.BLL.Customers().AddCustomers(CustomersAdd);
                        if (departmentId > 0)
                        {
                            userOperateLog.OperateInfo = "添加客户";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,客户主键:" + departmentId;
                            context.Response.Write("{\"msg\":\"添加成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加客户";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加客户";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":true}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("customers", "edit", user.Id))
                    {
                        ZGZY.Model.Customers CustomersEdit = new Model.Customers();
                        CustomersEdit.Id       = Convert.ToInt32(context.Request.Params["id"]);
                        CustomersEdit.CusName  = context.Request.Params["ui_Customers_CusName_edit"] ?? "";
                        CustomersEdit.State    = Convert.ToInt32(context.Request.Params["ui_Cutomers_State_edit"]);
                        CustomersEdit.CusType  = Convert.ToInt32(context.Request.Params["ui_Cutomers_CusType_edit"]);
                        CustomersEdit.CusLevel = Convert.ToInt32(context.Request.Params["ui_Customers_CusLevel_edit"]);
                        CustomersEdit.Remark   = context.Request.Params["ui_Customers_Remark_edit"] ?? "";
                        int outputRow = new ZGZY.BLL.Customers().EditCustomers(CustomersEdit);
                        if (outputRow > 0)
                        {
                            userOperateLog.OperateInfo = "修改客户";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,客户主键:" + outputRow;
                            context.Response.Write("{\"msg\":\"添加成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改客户";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改客户";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":true}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    int    totalCount;    //输出参数
                    string strJson = new ZGZY.BLL.Button().GetPager("Customers", "Id, CusCode, CusName, State, CusType, CusLevel, CreateDate, SalesmanId, ServicerId, Remark", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");
                    userOperateLog.OperateInfo = "查询按钮";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("customers", "delete", user.Id))
                    {
                        object departmentIds = context.Request.Params["id"];
                        if (new ZGZY.BLL.Customers().DeleteCustomersById(departmentIds) == 1)
                        {
                            userOperateLog.OperateInfo = "删除客户";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,客户主键:" + departmentIds;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除客户";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败,客户主键:" + departmentIds;
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除客户";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"result\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + ZGZY.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "按钮功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = ZGZY.Common.JsonHelper.StringFilter(ex.Message);
                ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }