/// <summary>
 /// 更新用户
 /// </summary>
 /// <returns></returns>
 public string UpdateUserInfo(Dictionary <string, string> Dic)
 {
     try
     {
         model.pbxdatasourceDataContext context = new model.pbxdatasourceDataContext();
         var q = from c in context.users where c.userName == Dic["UserName"] && c.userPwd == Dic["oldPwd"] select c;
         if (q.FirstOrDefault() != null)
         {
             foreach (var item in q)
             {
                 item.userRealName = Dic["RealName"];
                 item.userSex      = Convert.ToInt32(Dic["sex"]);
                 item.userPwd      = Dic["Pwd"];
                 item.UserPhone    = Dic["Phone"];
                 item.UserEmail    = Dic["Email"];
                 item.UserAddress  = Dic["Address"];
             }
             context.SubmitChanges();
             errordal.InsertErrorlog(new model.errorlog()
             {
                 errorSrc        = "pbxdata.dal->usersdal->UpdateUserInfo()",
                 ErrorMsg        = "修改",
                 errorTime       = DateTime.Now,
                 operation       = 2,
                 errorMsgDetails = "修改个人信息->" + Dic["UserName"],
                 UserId          = Convert.ToInt32(Dic["UserId"].ToString())
             });
             return("修改成功!");
         }
         else
         {
             return("密码错误!");
         }
     }
     catch (Exception ex)
     {
         errordal.InsertErrorlog(new model.errorlog()
         {
             errorSrc        = "pbxdata.dal->usersdal->UpdateUserInfo()",
             ErrorMsg        = "修改",
             errorTime       = DateTime.Now,
             operation       = 1,
             errorMsgDetails = ex.Message,
             UserId          = Convert.ToInt32(Dic["UserId"].ToString())
         });
         return("修改失败!");
     }
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filename">excel文件完全限定路径</param>
        /// <param name="workTableName">excel文件工作表名称</param>
        /// <returns></returns>
        public DataSet GetData(string filename, string workTableName, out Exception exx)
        {
            DataSet         ds;
            string          strCon = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Extended Properties=Excel 8.0;" + "data source=" + filename;
            OleDbConnection myConn = new OleDbConnection(strCon);
            string          strCom = " SELECT * FROM [" + workTableName + "]";

            try
            {
                Open(myConn);//打开数据库
                OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
                ds = new DataSet();
                myCommand.Fill(ds);
                myCommand.Dispose();
                exx = null;
                return(ds);
            }
            catch (Exception ex)
            {
                Errorlogdal dal = new Errorlogdal();
                dal.InsertErrorlog(new model.errorlog()
                {
                    errorSrc = "ExcelOperation->GetData", ErrorMsg = ex.Message, operation = 4
                });
                exx = ex;
                return(null);
            }
            finally
            {
                Close(myConn);
            }
        }
Пример #3
0
 /// <summary>
 /// 根据条件获取异常信息
 /// </summary>
 /// <param name="error">搜索实体</param>
 /// <param name="skip">跳过多少条数据</param>
 /// <param name="take">去多少条数据</param>
 /// <returns></returns>
 public DataTable GetItaly(string ItalyCode, DateTime?createTime, DateTime?createTimeEnd, int skip, int take, out int pageRowsCount)
 {
     try
     {
         DataTable dt   = new DataTable();
         var       temp = from c in pbx.ItalyUpdateError select c;
         if (!string.IsNullOrWhiteSpace(ItalyCode))
         {
             temp = temp.Where(a => a.ItalyCode.Contains(ItalyCode));
         }
         if (createTime != null)
         {
             temp = temp.Where(a => a.createTime >= createTime);
         }
         if (createTimeEnd != null)
         {
             temp = temp.Where(a => a.createTime <= createTimeEnd);
         }
         pageRowsCount = temp.ToList().Count;
         temp          = temp.OrderByDescending(a => a.createTime).Skip(skip).Take(take);
         ItalyUpdateError stock = new ItalyUpdateError();
         List <string>    list  = new List <string>();
         foreach (var s in stock.GetType().GetProperties())
         {
             DataColumn cl = new DataColumn();
             cl.ColumnName = s.Name;
             list.Add(s.Name);
             // cl.DataType = s.GetType();
             dt.Columns.Add(cl);
         }
         foreach (ItalyUpdateError i in temp)
         {
             DataRow row = dt.NewRow();
             foreach (string s in list)
             {
                 //给row赋值
                 row[s] = i.GetType().GetProperty(s).GetValue(i);
             }
             dt.Rows.Add(row);
         }
         return(dt);
     }
     catch (Exception ex)
     {
         pageRowsCount = 0;
         Errorlogdal err = new Errorlogdal();
         err.InsertErrorlog(new errorlog()
         {
             operation = 3, errorTime = DateTime.Now, errorSrc = "ItalyErrordal->GetItaly()", ErrorMsg = ex.Source, errorMsgDetails = ex.Message
         });
         return(null);
     }
 }
 /// <summary>
 ///添加表
 /// </summary>
 /// <returns></returns>
 public string AddTabName(string tableName, int UserId)
 {
     model.pbxdatasourceDataContext context = new model.pbxdatasourceDataContext();
     try
     {
         string check = @"select count(*)  from syscolumns where id=object_id('" + tableName + "')";
         if (DbHelperSQL.Query(check).Tables[0].Rows[0][0].ToString() == "0")
         {
             return("该表不存在!");
         }
         else
         {
             var p = (from c in context.tableFiledPerssion where c.tableName == tableName select c.tableName).FirstOrDefault();
             if (p == null)
             {
                 model.tableFiledPerssion tt = new model.tableFiledPerssion()
                 {
                     tableName       = tableName,
                     tableLevel      = 0,
                     tableNameState  = 1,
                     tableFiledState = 1,
                 };
                 context.tableFiledPerssion.InsertOnSubmit(tt);
                 context.SubmitChanges();
                 string sql = @"insert into tableFiledPerssion(tableName,tableLevel) select name,(select id from tableFiledPerssion where tableName='" + tableName + "') from sys.syscolumns where id =object_id('" + tableName + "')";
                 DbHelperSQL.ExecuteSql(sql);
                 errordal.InsertErrorlog(new model.errorlog()
                 {
                     errorSrc        = "pbxdata.dal->tablefiledPerssiondal->AddTabName()",
                     ErrorMsg        = "添加",
                     errorTime       = DateTime.Now,
                     operation       = 2,
                     errorMsgDetails = "添加表->" + tableName,
                     UserId          = UserId,
                 });
             }
             else
             {
                 return("该表已存在!");
             }
             return("");
         }
     }
     catch (Exception ex)
     {
         errordal.InsertErrorlog(new model.errorlog()
         {
             errorSrc        = "pbxdata.dal->tablefiledPerssiondal->AddTabName()",
             ErrorMsg        = "添加",
             errorTime       = DateTime.Now,
             operation       = 1,
             errorMsgDetails = "添加表失败->" + tableName + "->" + ex.Message,
             UserId          = UserId,
         });
         return("添加失败!");
     }
 }
 /// <summary>
 /// 更新供应商品牌表
 /// </summary>
 /// <returns></returns>
 public string UpdateBrandVen(Dictionary <string, string> dic, int UserId)
 {
     try
     {
         model.pbxdatasourceDataContext context = new pbxdatasourceDataContext();
         if (dic["Id"] == "0")//--判断是否存在 存在则更新不存在插入
         {
             var q = context.BrandVen.Where(a => a.BrandNameVen == dic["BrandNameVen"]).Where(a => a.Vencode == dic["Vencode"]).ToList();
             if (q.Count == 0)
             {
                 model.BrandVen BV = new model.BrandVen()
                 {
                     BrandName    = dic["BrandName"],
                     BrandAbridge = dic["BrandAbridge"],
                     BrandNameVen = dic["BrandNameVen"],
                     Vencode      = dic["Vencode"],
                 };
                 context.BrandVen.InsertOnSubmit(BV);
                 context.SubmitChanges();
                 dal.InsertErrorlog(new model.errorlog()
                 {
                     errorSrc        = "pbxdata.dal->BrandDal->UpdateProducttypeVen()",
                     ErrorMsg        = "修改",
                     errorTime       = DateTime.Now,
                     operation       = 2,
                     errorMsgDetails = "添加供应商品牌表->" + dic["BrandNameVen"],
                     UserId          = UserId,
                 });
             }
             else
             {
                 return("该品牌已存在!");
             }
         }
         else
         {
             var q = from c in context.BrandVen where c.Id == Convert.ToInt32(dic["Id"].ToString()) select c;
             foreach (var i in q)
             {
                 i.BrandName    = dic["BrandName"];
                 i.BrandAbridge = dic["BrandAbridge"];
                 i.BrandNameVen = dic["BrandNameVen"];
                 i.Vencode      = dic["Vencode"];
             }
             context.SubmitChanges();
             dal.InsertErrorlog(new model.errorlog()
             {
                 errorSrc        = "pbxdata.dal->BrandDal->UpdateProducttypeVen()",
                 ErrorMsg        = "修改",
                 errorTime       = DateTime.Now,
                 operation       = 2,
                 errorMsgDetails = "修改供应商品牌表->" + dic["BrandNameVen"],
                 UserId          = UserId,
             });
         }
         return("修改成功!");
     }
     catch (Exception ex)
     {
         dal.InsertErrorlog(new model.errorlog()
         {
             errorSrc        = "pbxdata.dal->BrandDal->UpdateProducttypeVen()",
             ErrorMsg        = "修改",
             errorTime       = DateTime.Now,
             operation       = 1,
             errorMsgDetails = ex.Message,
             UserId          = UserId,
         });
         return("修改失败!");
     }
 }
 /// <summary>
 /// 更新供应商季节
 /// </summary>
 /// <returns></returns>
 public string UpdateSeasonVen(Dictionary <string, string> dic, int UserId)
 {
     try
     {
         model.pbxdatasourceDataContext context = new pbxdatasourceDataContext();
         if (dic["Id"] == "0")//通过id来获取是Update还是insert
         {
             var q = context.SeasonVen.Where(a => a.Cat1Ven == dic["Cat1Ven"]).Where(a => a.Vencode == dic["Vencode"]).ToList();
             if (q.Count == 0)//判断是否已存在
             {
                 model.SeasonVen mc = new model.SeasonVen()
                 {
                     Cat1    = dic["Cat1"],    //季节
                     Cat1Ven = dic["Cat1Ven"], //供应商季节
                     Vencode = dic["Vencode"], //供应商
                 };
                 context.SeasonVen.InsertOnSubmit(mc);
                 context.SubmitChanges();
                 dal.InsertErrorlog(new model.errorlog()
                 {
                     errorSrc        = "pbxdata.dal->SeasonDal->UpdateSeasonVen()",
                     ErrorMsg        = "修改",
                     errorTime       = DateTime.Now,
                     operation       = 2,
                     errorMsgDetails = "添加供应季节表->" + dic["Cat1Ven"],
                     UserId          = UserId,
                 });
             }
             else
             {
                 return("该季节已存在!");
             }
         }
         else
         {
             var q = from c in context.SeasonVen where c.Id == Convert.ToInt32(dic["Id"].ToString()) select c;
             foreach (var i in q)
             {
                 i.Cat1    = dic["Cat1"];
                 i.Cat1Ven = dic["Cat1Ven"];
                 i.Vencode = dic["Vencode"];
             }
             context.SubmitChanges();
             dal.InsertErrorlog(new model.errorlog()
             {
                 errorSrc        = "pbxdata.dal->SeasonDal->UpdateSeasonVen()",
                 ErrorMsg        = "修改",
                 errorTime       = DateTime.Now,
                 operation       = 2,
                 errorMsgDetails = "修改供应季节表->" + dic["Cat1Ven"],
                 UserId          = UserId,
             });
         }
         return("修改成功!");
     }
     catch (Exception ex)
     {
         dal.InsertErrorlog(new model.errorlog()
         {
             errorSrc        = "pbxdata.dal->SeasonDal->UpdateSeasonVen()",
             ErrorMsg        = "修改",
             errorTime       = DateTime.Now,
             operation       = 1,
             errorMsgDetails = ex.Message,
             UserId          = UserId,
         });
         return("修改失败!");
     }
 }
Пример #7
0
        /// <summary>
        /// 根据子订单ID修改此商品相关信息
        /// </summary>
        /// <returns></returns>
        public string orderUpdate(string orderchildenid, Dictionary <string, string> Dic)
        {
            //Dic["orderXSFS1"].ToString()销售方式------------暂未用到
            //Dic["orderCHCK1"].ToString()出库源头------------暂未用到
            DataTable dt = new DataTable();

            try
            {
                model.pbxdatasourceDataContext context = new model.pbxdatasourceDataContext();
                var c = context.OrderDetails.Where(a => a.OrderChildenId == orderchildenid);
                foreach (var a in c)
                {
                    a.OrderScode = Dic["orderScode1"].ToString();//--货号
                }
                //var o = context.porder.Where(a => a.OrderId == Dic["orderid1"]);
                //foreach (var a in o)
                //{
                //    a.CustomServerId = Convert.ToInt32(Dic["orderSSKF1"].ToString());//--所属客服

                //}
                var e = (context.OrderExpress.Where(a => a.OrderId == Dic["orderid1"])).FirstOrDefault();
                e.ExpressName = Dic["CourierCompanies1"].ToString(); //--快递公司
                e.ExpressNo   = Dic["CourierNo1"].ToString();        //--快递编号
                //context.OrderExpress.Attach(e);
                //if (Dic["CourierCompanies1"].ToString() != "")
                //{
                //
                //}
                //if (Dic["CourierNo1"].ToString() != "")
                //{
                //
                //}


                if (Dic["orderSSKF1"].ToString() != "-1")
                {
                    var o = (context.porder.Where(a => a.OrderId == Dic["orderid1"])).FirstOrDefault();
                    o.CustomServerId = Convert.ToInt32(Dic["orderSSKF1"].ToString());
                }
                //foreach (var a in e)
                //{
                //    a.ExpressName = Dic["CourierCompanies1"].ToString();//--快递公司
                //    a.ExpressNo = Dic["CourierNo1"].ToString();//--快递编号

                //}
                var oc = context.orderComments.Where(a => a.ocOrderId == Dic["orderid1"]);
                foreach (var a in oc)
                {
                    a.ocOtherPrice = Convert.ToDecimal(Dic["orderOtherMoney1"].ToString()); //--其他费用
                    a.ocRemark     = Dic["orderRemark"].ToString();                         //--备注
                    a.ocPostPrice  = Convert.ToDecimal(Dic["orderPostage1"].ToString());    //--邮费
                }

                context.SubmitChanges();
                errordal.InsertErrorlog(new model.errorlog()
                {
                    errorSrc        = "pbxdata.dal->shoporderdal->orderUpdate()",
                    ErrorMsg        = "修改",
                    errorTime       = DateTime.Now,
                    operation       = 2,
                    errorMsgDetails = "通过子订单号修改信息->" + orderchildenid,
                    UserId          = Convert.ToInt32(Dic["UserId"].ToString())
                });
                return("修改成功!");
            }
            catch (Exception ex)
            {
                errordal.InsertErrorlog(new model.errorlog()
                {
                    errorSrc        = "pbxdata.dal->shoporderdal->orderUpdate()",
                    ErrorMsg        = "修改",
                    errorTime       = DateTime.Now,
                    operation       = 1,
                    errorMsgDetails = ex.Message,
                    UserId          = Convert.ToInt32(Dic["UserId"].ToString())
                });
                return("修改失败!");
            }
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="Id">商品id</param>
        /// <returns></returns>
        public bool UpdateProduct(model.product mm, string AttrId, string ComAttrvalues, string PropertyId, int UserId)
        {
            try
            {
                IDataParameter[] pro = new IDataParameter[] {
                    new SqlParameter("Cdescript", mm.Cdescript),
                    new SqlParameter("Cat1", mm.Cat1),
                    new SqlParameter("Cat2", mm.Cat2),
                    new SqlParameter("Rolevel", mm.Rolevel),
                    new SqlParameter("Scode", mm.Scode),
                    new SqlParameter("ciqProductId", mm.ciqProductId),
                    new SqlParameter("ciqSpec", mm.ciqSpec),
                    new SqlParameter("ciqHSNo", mm.ciqHSNo),
                    new SqlParameter("ciqAssemCountry", mm.ciqAssemCountry),
                    new SqlParameter("Def9", mm.Def9),
                    new SqlParameter("Def10", mm.Def10),
                    new SqlParameter("sql", ""),
                    new SqlParameter("Imagefile", mm.Imagefile),
                    new SqlParameter("QtyUnit", mm.QtyUnit),
                    new SqlParameter("Def15", mm.Def15),
                    new SqlParameter("Def16", mm.Def16),
                };
                string n = Update(pro, "UpdateProductinfo");//根据货号更新product表的信息

                Dictionary <string, string> dic = new Dictionary <string, string>();
                if (AttrId != "")
                {
                    string[] ArryComAttrvalues, ArryAttrId, ArryPropertyId;
                    ArryAttrId        = AttrId.Split(',');
                    ArryComAttrvalues = ComAttrvalues.Split(',');
                    ArryPropertyId    = PropertyId.Split(',');
                    for (int i = 0; i < ArryAttrId.Length; i++)
                    {
                        string check = @"select * from productPorpertyValue where Id='" + ArryAttrId[i] + "' "; //判断该属性是否存在

                        if (DbHelperSQL.Query(check).Tables[0].Rows.Count == 0)                                 //不存在则根据货号以及类别添加属性以及属性值 存在则跟新属性值
                        {
                            IDataParameter[] pro1 = new IDataParameter[] {
                                new SqlParameter("Cat2", mm.Cat2),
                                new SqlParameter("PropertyId ", ArryPropertyId[i]),
                                new SqlParameter("Scode", mm.Scode),
                                new SqlParameter("PropertyValue", ArryComAttrvalues[i]),
                                new SqlParameter("PropertyIndex", "1"),
                                new SqlParameter("UserId", UserId),
                            };
                            string m = Add(pro1, "InsertPropertyValue");
                        }
                        else
                        {
                            IDataParameter[] pro1 = new IDataParameter[] {
                                new SqlParameter("PropertyValue", ArryComAttrvalues[i]),
                                new SqlParameter("Id", ArryAttrId[i]),
                                new SqlParameter("sql", ""),
                            };
                            string m = Update(pro1, "UpdatePropertyValue");
                        }
                    }
                }
                dal.InsertErrorlog(new model.errorlog()
                {
                    errorSrc        = "pbxdata.dal->AttributeDal->UpdateProduct()",
                    ErrorMsg        = "修改",
                    errorTime       = DateTime.Now,
                    operation       = 2,
                    errorMsgDetails = "通过货号修改商品信息->" + mm.Scode,
                    UserId          = UserId,
                });
                return(true);
            }
            catch (Exception ex)
            {
                dal.InsertErrorlog(new model.errorlog()
                {
                    errorSrc        = "pbxdata.dal->AttributeDal->UpdateProduct()",
                    ErrorMsg        = "修改",
                    errorTime       = DateTime.Now,
                    operation       = 1,
                    errorMsgDetails = ex.Message,
                    UserId          = UserId,
                });
                return(false);
            }
        }