/// <summary> /// 更新管理员信息 /// </summary> /// <param name="model">管理员实体</param> /// <returns>更新成功返回true 否则返回false</returns> public bool Update(Admins model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update Admins set "); strSql.Append("LoginName=@LoginName,"); strSql.Append("RealName=@RealName,"); strSql.Append("Pwd=@Pwd,"); strSql.Append("Addr=@Addr,"); strSql.Append("Phone=@Phone,"); strSql.Append("Fax=@Fax,"); strSql.Append("Email=@Email"); strSql.Append(" where AID=@AID"); Dictionary <string, object> paras = new Dictionary <string, object>(); paras.Add("@LoginName", model.LoginName); paras.Add("@LoginName", model.RealName); paras.Add("@Pwd", model.Pwd); paras.Add("@Addr", model.Addr); paras.Add("@Phone", model.Phone); paras.Add("@Fax", model.Fax); paras.Add("@Email", model.Email); paras.Add("@AID", model.AID); int rows = SqlHelper.ExecuteNonQuery(strSql.ToString(), paras); return(rows > 0); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(false); } }
/// <summary> /// 获取当天交易的所有蔬菜 /// </summary> /// <returns></returns> public List <Vegetable> GetAllVegetableDayTrading() { try { StringBuilder strbd = new StringBuilder(); strbd.Append(@" select distinct v.VID,VName,WholesalePrice from Vegetable as v join OrderDetail as od on v.VID=od.VID join Orders as o on od.OID = o.OID join UnitPrice as u on u.VID = v.VID where datediff(day,o.OrderTime,GETDATE())=0 and o.OrderState=1"); Dictionary <string, string> outDic = new Dictionary <string, string>(); outDic.Add("VID", "VID"); outDic.Add("VName", "VName"); outDic.Add("WholesalePrice", "WholesalePrice"); List <Vegetable> list = SqlHelper.GetDataListByString <Vegetable>(strbd.ToString(), null, outDic); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 获取蔬菜代码 /// </summary> /// <param name="veg">蔬菜实体</param> /// <returns></returns> public string GetVCode(Vegetable veg) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("select MAX(VID) from Vegetable "); string vid = SqlHelper.ExecuteScalarByString(strSql.ToString(), null).ToString(); string temp = (int.Parse(vid) + 1).ToString(); if (temp.Length < 5) { int count = temp.Length; for (int i = 0; i < 5 - count; i++) { temp = "0" + temp; } } string cid = veg.CID.ToString(); if (cid.Length < 2) { cid = "0" + cid; } return(veg.Keys + cid + temp); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 更新蔬菜 /// </summary> /// <param name="model">蔬菜实体</param> /// <returns>更新成功返回true 否则返回false</returns> public bool Update(Vegetable model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update Vegetable set "); strSql.Append("VCode=@VCode,"); strSql.Append("CID=@CID,"); strSql.Append("Keys=@Keys,"); strSql.Append("VName=@VName,"); strSql.Append("VOrder=@VOrder,"); strSql.Append("Specification = @Specification,"); strSql.Append("Deleted=@Deleted"); //strSql.Append("ModifyTime=@ModifyTime"); strSql.Append(" where VID=@VID"); Dictionary <string, object> paraDic = new Dictionary <string, object>(); paraDic.Add("VCode", model.VCode); paraDic.Add("CID", model.CID); paraDic.Add("Keys", model.Keys); paraDic.Add("VName", model.VName); paraDic.Add("VOrder", model.VOrder); paraDic.Add("Specification", model.Specification); paraDic.Add("Deleted", model.Deleted); // paraDic.Add("ModifyTime", model.ModifyTime); paraDic.Add("VID", model.VID); int rows = SqlHelper.ExecuteNonQuery(strSql.ToString(), paraDic); return(rows > 0); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(false); } }
/// <summary> /// 根据编号获取其对应的蔬菜名称 /// </summary> /// <param name="name">编号</param> /// <returns>若存在则返回其蔬菜名称 否则返回-1</returns> public string GetNameByID(int vid) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("select VName from Vegetable "); strSql.Append(" where VID=@VID "); Dictionary <string, object> paraDic = new Dictionary <string, object>(); paraDic.Add("VID", vid); object obj = SqlHelper.ExecuteScalarByString(strSql.ToString(), paraDic); if (obj == null) { return(null); } string ret = (string)obj; return(ret); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Update(OrderDetail model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update OrderDetail set "); strSql.Append(" OID = @OID , "); strSql.Append(" VID = @VID , "); strSql.Append(" OrderCount = @OrderCount , "); strSql.Append(" RealCount = @RealCount ,"); strSql.Append(" Remarks = @Remarks "); strSql.Append(" where OID=@OID "); Dictionary <string, object> paraDic = new Dictionary <string, object>(); paraDic.Add("@OID", model.OID); paraDic.Add("@VID", model.VID); paraDic.Add("@OrderCount", model.OrderCount); paraDic.Add("@RealCount", model.RealCount); paraDic.Add("@Remarks", model.Remarks); int ret = int.Parse(SqlHelper.ExecuteScalarByString(strSql.ToString(), paraDic).ToString()); return(ret > 0); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(false); } }
/// <summary> /// 获得利润管理列表 /// </summary> /// <param name="spid">售价表id</param> /// <returns>返回利润管理列表</returns> public List <ProfitMessageModels> ChangeMessage(int did) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("select d.DID,p.Profit,v.VName,v.Keys,v.VID,p.PID from Vegetable as v"); strSql.Append(" join Profit as p on p.VID=v.VID"); strSql.Append(" join Department as d on p.DID=d.DID"); strSql.Append(" where p.DID=@DID"); Dictionary <string, object> inputDic = new Dictionary <string, object>(); inputDic.Add("DID", did); Dictionary <string, string> outDic = new Dictionary <string, string>(); outDic.Add("PID", "PID"); outDic.Add("Profit", "Profit"); outDic.Add("VName", "VName"); outDic.Add("Keys", "Keys"); outDic.Add("VID", "VID"); List <ProfitMessageModels> list = SqlHelper.GetDataListByString <ProfitMessageModels>(strSql.ToString(), inputDic, outDic); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); throw ex; } }
/// <summary> /// 获取当天所有交易的企业 /// </summary> /// <returns></returns> public List <Enterprise> GetAllEnterpriceDayTrading() { try { StringBuilder strbd = new StringBuilder(); strbd.Append(@" select distinct EName,e.EID from Enterprise as e join Department as d on e.EID = d.EID join Orders as o on d.DID = o.DID where datediff(day,o.OrderTime,getdate())=0 order by e.EID "); Dictionary <string, string> outDic = new Dictionary <string, string>(); outDic.Add("EID", "EID"); outDic.Add("EName", "EName"); List <Enterprise> list = SqlHelper.GetDataListByString <Enterprise>(strbd.ToString(), null, outDic); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 获取将要添加的订单编号 /// </summary> /// <returns>返回最新订单编号 </returns> private string GetOID() { try { DateTime time = DateTime.Now; string month = time.Month.ToString(); if (month.Length == 1) { month = "0" + month; } string preID = time.Year.ToString() + month + time.Day.ToString(); StringBuilder strSql = new StringBuilder(); strSql.Append("select max(OID) from Orders"); string maxOid = SqlHelper.ExecuteScalarByString(strSql.ToString(), new Dictionary <string, object>()).ToString(); if (maxOid == "") { maxOid = "2012071700000";//前8位随意值 } int num = int.Parse(maxOid.Substring(8, 5)) + 1; string oid = "0000" + num.ToString(); oid = oid.Substring(oid.Length - 5, 5); return(preID + oid); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 获取所有送货单列表 /// </summary> /// <returns></returns> public List <DeliveryNote> GetAllDeliveryNote() { try { StringBuilder strbd = new StringBuilder(); strbd.Append(@" select o.OID,e.EName,e.EID,d.DName from Orders as o join OrderDetail as od on od.OID=o.OID join Vegetable as v on v.VID=od.VID join Department as d on d.DID=o.DID join Enterprise as e on e.EID=d.EID group by o.OID,e.EName,d.DName,o.OrderState,OrderTime,e.EID having DATEDIFF(DAY,o.OrderTime,GETDATE())=0 and OrderState=1 "); Dictionary <string, string> outDic = new Dictionary <string, string>(); outDic.Add("OID", "OID"); outDic.Add("DName", "DName"); outDic.Add("EName", "EName"); outDic.Add("EID", "EID"); List <DeliveryNote> list = SqlHelper.GetDataListByString <DeliveryNote>(strbd.ToString(), null, outDic); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 获取检货单数据列表 检货单 /// </summary> /// <returns></returns> public List <InspectionSheet> GetInspectionSheet() { try { StringBuilder strSql = new StringBuilder(); strSql.Append(@" select EName,DName,VName,OrderCount,od.OID,od.VID from Orders as o join OrderDetail as od on od.OID = o.OID join Department as d on d.DID=o.DID join Enterprise as e on e.EID = d.EID join Vegetable as v on v.VID =od.VID where datediff(day,o.OrderTime,getdate())=0 group by EName,DName,VName,OrderCount,od.OID,od.VID "); Dictionary <string, string> outDic = new Dictionary <string, string>(); outDic.Add("VName", "VName"); outDic.Add("DName", "DName"); outDic.Add("EName", "EName"); outDic.Add("OrderCount", "OrderCount"); List <InspectionSheet> list = SqlHelper.GetDataListByString <InspectionSheet>(strSql.ToString(), null, outDic); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 更新订单 /// </summary> /// <param name="model">订单实体</param> /// <returns>更新成功返回true 否则返回false</returns> public bool Update(Orders model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update Orders set "); strSql.Append("OrderState=@OrderState,"); strSql.Append("Upaid=@Upaid,"); strSql.Append("UpaidTime=@UpaidTime,"); strSql.Append("Wpaid=@Wpaid,"); strSql.Append("WpaidTime=@WpaidTime,"); strSql.Append("Remarks=@Remarks,"); strSql.Append(" Recipient = @Recipient , "); strSql.Append(" HandledBy = @HandledBy , "); strSql.Append("DeliveryDate=@DeliveryDate"); strSql.Append(" where OID=@OID "); int rows = SqlHelper.ExecuteNonQuery(strSql.ToString(), GetInputDic(model)); return(rows > 0); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(false); } }
/// <summary> /// 根据部门编号获取部门信息 /// </summary> /// <param name="did">部门编号</param> /// <returns></returns> public Department GetDepartmentByID(int did) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT [DID],[EID],[DName] ,[Addr],[LabourCharges],[DisCount],[Phone],[MobilePhone],[Fax],[Email] ,[Deleted]"); strSql.Append(" FROM Department"); strSql.Append(" where DID=@DID"); Dictionary <string, object> inputDic = new Dictionary <string, object>(); inputDic.Add("@DID", did); List <Department> list = SqlHelper.GetDataListByString <Department>(strSql.ToString(), inputDic, GetOutDic()); if (list == null) { return(null); } return(list[0]); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 根据企业ID获取部门列表信息 /// </summary> /// <param name="Eid">企业ID</param> /// <returns></returns> public List <Department> GetDepartmentListByEnterpriseID(int Eid) { try { StringBuilder strSql = new StringBuilder(); strSql.Append(" select * "); strSql.Append(" from Department "); strSql.Append(" WHERE EID=@EID"); Dictionary <string, string> returnValueBingding = new Dictionary <string, string>(); returnValueBingding.Add("DID", "DID"); returnValueBingding.Add("EID", "EID"); returnValueBingding.Add("DName", "DName"); returnValueBingding.Add("Addr", "Addr"); returnValueBingding.Add("DisCount", "DisCount"); returnValueBingding.Add("LabourCharges", "LabourCharges"); returnValueBingding.Add("phone", "Phone"); returnValueBingding.Add("MobilePhone", "MobilePhone"); returnValueBingding.Add("Fax", "Fax"); returnValueBingding.Add("Email", "Email"); returnValueBingding.Add("Deleted", "Deleted"); Dictionary <string, object> paramsValue = new Dictionary <string, object>(); paramsValue.Add("EID", Eid); List <Department> list = SqlHelper.GetDataListByString <Department>(strSql.ToString(), paramsValue, returnValueBingding); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 获取指定订单明细列表 /// </summary> /// <param name="oid">订单编号</param> /// <returns></returns> public List <OrderDetail> GetList(string oid) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("select ODID, OID, VID, OrderCount, RealCount,Remarks,ActualPrice "); strSql.Append(" from OrderDetail "); strSql.Append(" where OID=@OID "); Dictionary <string, object> inputDic = new Dictionary <string, object>(); inputDic.Add("OID", oid); Dictionary <string, string> outDic = new Dictionary <string, string>(); outDic.Add("ODID", "ODID"); outDic.Add("OID", "OID"); outDic.Add("VID", "VID"); outDic.Add("OrderCount", "OrderCount"); outDic.Add("RealCount", "RealCount"); outDic.Add("Remarks", "Remarks"); outDic.Add("ActualPrice", "ActualPrice"); List <OrderDetail> list = SqlHelper.GetDataListByString <OrderDetail>(strSql.ToString(), inputDic, outDic); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 获取所有企业 包括部门 /// </summary> /// <returns></returns> public List <Enterprise> GetAllModel() { try { string cmd = @"SELECT e.[EID],[EName], [DID],[DName],d.Deleted FROM [Enterprise] as e join Department as d on d.EID = e.EID order by e.EID asc "; Dictionary <string, string> outDic = new Dictionary <string, string>(); outDic.Add("DID", "DID"); outDic.Add("DName", "DName"); outDic.Add("EID", "EID"); outDic.Add("EName", "EName"); outDic.Add("Deleted", "Deleted"); List <Enterprise> list = SqlHelper.GetDataListByString <Enterprise>(cmd, null, outDic); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 添加订单明细 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Add(OrderDetail model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into OrderDetail("); strSql.Append("OID,VID,OrderCount,RealCount,Remarks"); strSql.Append(") values ("); strSql.Append("@OID,@VID,@OrderCount,@RealCount,@Remarks"); strSql.Append(") "); Dictionary <string, object> paraDic = new Dictionary <string, object>(); paraDic.Add("@OID", model.OID); paraDic.Add("@VID", model.VID); paraDic.Add("@OrderCount", model.OrderCount); paraDic.Add("@RealCount", model.RealCount); paraDic.Add("@Remarks", model.Remarks); object obj = SqlHelper.ExecuteNonQuery(strSql.ToString(), paraDic); if (obj == null) { return(false); } else { return(true); } } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(false); } }
/// <summary> /// 添加企业 /// </summary> /// <param name="model">企业实体</param> /// <returns>添加成功返回最新企业的编号 否则返回-1</returns> public int Add(Enterprise model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Enterprise("); strSql.Append("EName,Addr,MobilePhone,Fax,Email,DisCount)"); strSql.Append(" values ("); strSql.Append("@EName,@Addr,@MobilePhone,@Fax,@Email,DisCount)"); strSql.Append(";select @@IDENTITY"); Dictionary <string, object> paraDic = GetInputDic(model); int rows = (int)SqlHelper.ExecuteNonQuery(strSql.ToString(), paraDic); if (rows <= 0) { return(-1); } string cmd = "select MAX(EID) from Enterprise "; return((int)SqlHelper.ExecuteScalarByString(cmd, new Dictionary <string, object>())); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(-1); } }
/// <summary> /// 录入实收量 /// </summary> /// <param name="oid">订单编号</param> /// <param name="listVID">蔬菜编号列表</param> /// <param name="counts">实收量列表</param> public void TypeInRealCount(string oid, List <string> listVID, List <double> counts) { try { StringBuilder strbd = new StringBuilder(); strbd.Append(@" set xact_abort on begin transaction "); for (int i = 0; i < counts.Count; i++) { strbd.Append(@" update OrderDetail set RealCount= " + counts[i]); strbd.Append(@" where OID= " + oid + " and VID=" + listVID[i]); } strbd.Append(" update Orders set OrderState=2 where OID=" + oid); //生成总额 总成本 strbd.Append(GenerateTotal(oid)); strbd.Append(@" commit transaction set xact_abort off"); int ret = dao.ExecuteNoQurey(strbd.ToString(), new Dictionary <string, object>()); if (ret <= 0) { return; } } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return; } }
/// <summary> /// 更新企业 /// </summary> /// <param name="model">企业实体</param> /// <returns>更新成功返回true 否则返回false</returns> public bool Update(Enterprise model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update Enterprise set "); strSql.Append("EName=@EName,"); // strSql.Append("LoginName=@LoginName,"); //strSql.Append("Pwd=@Pwd,"); //strSql.Append("Manager=@Manager,"); strSql.Append("Addr=@Addr,"); // strSql.Append("Phone=@Phone,"); strSql.Append("MobilePhone=@MobilePhone,"); strSql.Append("Fax=@Fax,"); strSql.Append("Email=@Email,"); strSql.Append("DisCount=@DisCount "); //strSql.Append("Deleted=@Deleted"); strSql.Append(" where EID=@EID"); Dictionary <string, object> paraDic = GetInputDic(model); paraDic.Add("@EID", model.EID); int rows = (int)SqlHelper.ExecuteNonQuery(strSql.ToString(), paraDic); return(rows > 0); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(false); } }
/// <summary> /// 添加蔬菜 /// </summary> /// <param name="model">蔬菜</param> /// <returns>添加成功返回当前编号 否则返回-1</returns> public int Add(Vegetable model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Vegetable("); strSql.Append("[VCode],[CID],[Keys],[VName],[Specification])"); strSql.Append(" values ("); strSql.Append("@VCode,@CID,@Keys,@VName,@Specification)"); Dictionary <string, object> paraDic = new Dictionary <string, object>(); paraDic.Add("@VCode", GetVCode(model)); paraDic.Add("@CID", model.CID); paraDic.Add("@Keys", model.Keys); paraDic.Add("@VName", model.VName); paraDic.Add("@Specification", model.Specification); int rows = SqlHelper.ExecuteNonQuery(strSql.ToString(), paraDic); if (rows <= 0) { return(-1); } string cmd = "select MAX(VID) from Vegetable "; return((int)SqlHelper.ExecuteScalarByString(cmd, new Dictionary <string, object>())); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(-1); } }
/// <summary> /// 更新蔬菜种类 /// </summary> /// <param name="model">种类实体</param> /// <returns>更新成功返回true 否则返回false</returns> public bool Update(Category model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("update Category set "); strSql.Append("CName=@CName"); strSql.Append("PCID=@PCID"); strSql.Append("COrder=@COrder,"); strSql.Append(" where CID=@CID"); Dictionary <string, object> paraDic = new Dictionary <string, object>(); paraDic.Add("@PCID", model.PCID); paraDic.Add("@CName", model.CName); paraDic.Add("@COrder", model.COrder); paraDic.Add("@CID", model.CID); int rows = SqlHelper.ExecuteNonQuery(strSql.ToString(), paraDic); return(rows > 0); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(false); } }
/// <summary> /// 根据蔬菜名称获取其对应的编号 /// </summary> /// <param name="name">蔬菜名称</param> /// <returns>若存在则返回其编号 否则返回-1</returns> public int GetIDByName(string name) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("select VID from Vegetable "); strSql.Append(" where VName=@VName "); Dictionary <string, object> paraDic = new Dictionary <string, object>(); paraDic.Add("VName", name); object obj = SqlHelper.ExecuteScalarByString(strSql.ToString(), paraDic); if (obj == null) { return(-1); } int ret = (int)obj; return(ret); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(-1); } }
/// <summary> /// 根据类别名称 获取类别信息 /// </summary> /// <param name="name">类别名称</param> /// <returns></returns> public List <Category> GetModels() { try { StringBuilder strSql = new StringBuilder(); strSql.Append(@" select PCID,CID ,CName,COrder from Category group by PCID,CID,CName,COrder order by PCID asc "); Dictionary <string, string> retDic = new Dictionary <string, string>(); retDic.Add("PCID", "PCID"); retDic.Add("CID", "CID"); retDic.Add("CName", "CName"); retDic.Add("COrder", "COrder"); List <Category> list = SqlHelper.GetDataListByString <Category>(strSql.ToString(), null, retDic); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 获取检货单蔬菜名称列表 /// </summary> /// <returns></returns> public List <Vegetable> GetInspectionSheetVegetables() { try { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select VName from Orders as o ,OrderDetail as od, Vegetable as v where od.OID=o.OID and v.VID = od.VID --and datediff(day,o.OrderTime,getdate())=0 group by VName"); Dictionary <string, string> outDic = new Dictionary <string, string>(); outDic.Add("VName", "VName"); List <Vegetable> list = SqlHelper.GetDataListByString <Vegetable>(strSql.ToString(), null, outDic); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 根据类别编号获取类别信息 /// </summary> /// <param name="name">类别编号</param> /// <returns></returns> public Category GetModel(int cid) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("select CID,PCID,CName,COrder from Category "); strSql.Append(" where CID=@CID"); Dictionary <string, object> inputDic = new Dictionary <string, object>(); inputDic.Add("@CID", cid); List <Category> list = GetList(strSql.ToString(), inputDic); if (list == null) { return(null); } return(list[0]); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 获取企业和企业所订购蔬菜的映射关系 实体映射 /// </summary> /// <returns></returns> public List <MapModel> GetMapModels() { try { StringBuilder strbd = new StringBuilder(); strbd.Append(@" select distinct od.VID,e.EID from Orders as o join OrderDetail as od on od.OID=o.OID join Department as d on d.DID=o.DID join Enterprise as e on e.EID= d.EID where datediff(day,o.OrderTime,getdate())=0 and OrderState=1 group by od.VID,e.EID"); Dictionary <string, string> outDic = new Dictionary <string, string>(); outDic.Add("VID", "VID"); outDic.Add("EID", "EID"); List <MapModel> list = SqlHelper.GetDataListByString <MapModel>(strbd.ToString(), null, outDic); if (list == null) { return(null); } return(list); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(null); } }
/// <summary> /// 添加父类别 类别的编号和父类的编号一致时表示该类为父类 /// </summary> /// <param name="name">父类名称</param> /// <returns>添加成功当前编号 否则-1</returns> public int AddParent(string name) { try { StringBuilder strSql = new StringBuilder(); strSql.Append(@"declare @cid int select @cid=MAX(cid) from Category insert into Category(CID , PCID,CName) values (@cid+1,@cid+1,@CName)"); Dictionary <string, object> paraDic = new Dictionary <string, object>(); paraDic.Add("@CName", name); int ret = (int)SqlHelper.InsertDataByString(strSql.ToString(), paraDic); if (ret <= 0) { return(-1); } string cmd = " select MAX(CID) from Category"; int cid = (int)SqlHelper.ExecuteScalarByString(cmd, null); return(cid); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(-1); } }
/// <summary> /// 获取蔬菜代码 /// </summary> /// <param name="veg">蔬菜实体</param> /// <returns></returns> public string SetVCode(Vegetable veg) { try { string temp = (veg.VID + 1).ToString(); if (temp.Length < 5) { int count = temp.Length; for (int i = 0; i < 5 - count; i++) { temp = "0" + temp; } } string cid = veg.CID.ToString(); if (cid.Length < 2) { cid = "0" + cid; } return(veg.Keys + cid + temp); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(veg.VCode); } }
/// <summary> /// 添加数据 /// </summary> /// <param name="model">管理员实体类</param> /// <returns>添加成功返回true 否则返回false</returns> public bool Add(Admins model) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Admins("); strSql.Append("LoginName,RealName,Pwd,Addr,Phone,Fax,Email)"); strSql.Append(" values ("); strSql.Append("@LoginName,@RealName,@Pwd,@Addr,@Phone,@Fax,@Email)"); strSql.Append(";select @@IDENTITY"); Dictionary <string, object> paraDic = new Dictionary <string, object>(); paraDic.Add("@LoginName", model.LoginName); paraDic.Add("@RealName", model.RealName); paraDic.Add("@Pwd", model.Pwd); paraDic.Add("@Addr", model.Addr); paraDic.Add("@Phone", model.Phone); paraDic.Add("@Fax", model.Fax); paraDic.Add("@Email", model.Email); int row = (int)SqlHelper.ExecuteNonQuery(strSql.ToString(), paraDic); return(row > 0); } catch (Exception ex) { XphpTool.CreateErrorLog(ex.ToString()); return(false); } }