/// <summary> /// 获取采购商默认模板信息业务实体 /// </summary> /// <param name="cgsId">采购商编号</param> /// <returns></returns> public EyouSoft.Model.MCaiGouMoBanInfo GetMoRenMoBanInfo(string cgsId) { EyouSoft.Model.MCaiGouMoBanInfo info = null; var cmd = _db.GetSqlStringCommand("SELECT TOP(1) A.*,B.Name AS CaoZuoRenName,C.Name AS CgsName FROM tbl_CaiGouMoBan AS A INNER JOIN tbl_YongHu AS B ON A.CaoZuoRenId=B.YongHuId INNER JOIN tbl_GongSi AS C ON C.GongSiId=A.CgsId WHERE A.CgsId=@CgsId AND IsMoRen='1'"); _db.AddInParameter(cmd, "@CgsId", DbType.AnsiStringFixedLength, cgsId); using (var rdr = DbHelper.ExecuteReader(cmd, _db)) { if (rdr.Read()) { info = new EyouSoft.Model.MCaiGouMoBanInfo(); info.CaoZuoRenId = rdr["CaoZuoRenId"].ToString(); info.CgsId = rdr["CgsId"].ToString(); info.ChanPins = null; info.IssueTime = rdr.GetDateTime(rdr.GetOrdinal("IssueTime")); info.MoBanId = rdr["MoBanId"].ToString(); info.Name = rdr["Name"].ToString(); info.CaoZuoRenName = rdr["CaoZuoRenName"].ToString(); info.CgsName = rdr["CgsName"].ToString(); info.IsMoRen = rdr["IsMoRen"].ToString() == "1"; } } if (info != null) { info.ChanPins = GetMoBanChanPins(info.MoBanId); } return(info); }
/// <summary> /// 采购模板添加,返回1成功,其它失败 /// </summary> /// <param name="info">实体</param> /// <returns></returns> public int MoBan_C(EyouSoft.Model.MCaiGouMoBanInfo info) { if (info == null || string.IsNullOrEmpty(info.CaoZuoRenId) || string.IsNullOrEmpty(info.Name) || string.IsNullOrEmpty(info.CgsId)) { return(0); } if (info.ChanPins == null || info.ChanPins.Count == 0) { return(0); } info.MoBanId = Guid.NewGuid().ToString(); info.IssueTime = DateTime.Now; foreach (var item in info.ChanPins) { item.Id = Guid.NewGuid().ToString(); } int dalRetCode = dal.MoBan_CU(info); if (dalRetCode == 1) { var logInfo = new EyouSoft.Model.MCaoZuoLogInfo(); logInfo.BiaoTi = "添加采购模板"; logInfo.NeiRong = "添加采购模板,模板编号:" + info.MoBanId + "。"; logInfo.GuanLianId = info.MoBanId; BCaoZuoLog.Log_C(logInfo); } return(dalRetCode); }
/// <summary> /// 采购模板添加、修改,返回1成功,其它失败 /// </summary> /// <param name="info">实体</param> /// <returns></returns> public int MoBan_CU(EyouSoft.Model.MCaiGouMoBanInfo info) { var cmd = _db.GetStoredProcCommand("proc_CaiGouMoBan_CU"); _db.AddInParameter(cmd, "@MoBanId", DbType.AnsiStringFixedLength, info.MoBanId); _db.AddInParameter(cmd, "@CgsId", DbType.AnsiStringFixedLength, info.CgsId); _db.AddInParameter(cmd, "@Name", DbType.String, info.Name); _db.AddInParameter(cmd, "@CaoZuoRenId", DbType.AnsiStringFixedLength, info.CaoZuoRenId); _db.AddInParameter(cmd, "@IssueTime", DbType.DateTime, info.IssueTime); _db.AddInParameter(cmd, "@ChanPinXml", DbType.String, CreateMoBanChanPinXml(info.ChanPins)); _db.AddOutParameter(cmd, "@RetCode", DbType.Int32, 4); int sqlExceptionCode = 0; try { DbHelper.RunProcedure(cmd, _db); } catch (System.Data.SqlClient.SqlException e) { sqlExceptionCode = 0 - e.Number; } if (sqlExceptionCode < 0) { return(sqlExceptionCode); } return(Convert.ToInt32(_db.GetParameterValue(cmd, "@RetCode"))); }
/// <summary> /// 获取采购模板信息集合 /// </summary> /// <param name="pageSize">页记录数</param> /// <param name="pageIndex">页序号</param> /// <param name="recordCount">总记录数</param> /// <param name="chaXun">查询</param> /// <returns></returns> public IList <EyouSoft.Model.MCaiGouMoBanInfo> GetMoBans(int pageSize, int pageIndex, ref int recordCount, EyouSoft.Model.MCaiGouMoBanChaXunInfo chaXun) { IList <EyouSoft.Model.MCaiGouMoBanInfo> items = new List <EyouSoft.Model.MCaiGouMoBanInfo>(); string fields = "*,(SELECT A1.Name FROM tbl_YongHu AS A1 WHERE A1.YongHuId=tbl_CaiGouMoBan.CaoZuoRenId) AS CaoZuoRenName,(SELECT A1.Name FROM tbl_GongSi AS A1 WHERE A1.GongSiId=tbl_CaiGouMoBan.CgsId) AS CgsName"; StringBuilder sql = new StringBuilder(); string tableName = "tbl_CaiGouMoBan"; string orderByString = " IssueTime DESC "; string heJiString = ""; #region sql sql.Append(" IsDelete='0' "); if (chaXun != null) { if (!string.IsNullOrEmpty(chaXun.CgsId)) { sql.AppendFormat(" AND (CgsId='{0}') ", chaXun.CgsId); } if (!string.IsNullOrEmpty(chaXun.Name)) { sql.AppendFormat(" AND Name LIKE '%{0}%' ", chaXun.Name); } } #endregion using (IDataReader rdr = DbHelper.ExecuteReader1(_db, pageSize, pageIndex, ref recordCount, tableName, fields, sql.ToString(), orderByString, heJiString)) { while (rdr.Read()) { var info = new EyouSoft.Model.MCaiGouMoBanInfo(); info.CaoZuoRenId = rdr["CaoZuoRenId"].ToString(); info.CgsId = rdr["CgsId"].ToString(); info.ChanPins = null; info.IssueTime = rdr.GetDateTime(rdr.GetOrdinal("IssueTime")); info.MoBanId = rdr["MoBanId"].ToString(); info.Name = rdr["Name"].ToString(); info.CaoZuoRenName = rdr["CaoZuoRenName"].ToString(); info.CgsName = rdr["CgsName"].ToString(); info.IsMoRen = rdr["IsMoRen"].ToString() == "1"; items.Add(info); } } return(items); }
/// <summary> /// get form info /// </summary> /// <returns></returns> EyouSoft.Model.MCaiGouMoBanInfo GetFormInfo() { var info = new EyouSoft.Model.MCaiGouMoBanInfo(); info.CaoZuoRenId = YongHuInfo.YongHuId; info.CgsId = YongHuInfo.GongSiId; info.ChanPins = new List <EyouSoft.Model.MCaiGouMoBanChanPinInfo>(); info.IsMoRen = false; info.IssueTime = DateTime.Now; info.MoBanId = EditId; info.Name = Utils.GetFormValue(txtMoBanName.UniqueID); var txt_moban_gysid = Utils.GetFormValues("txt_moban_gysid"); var txt_moban_chanpinid = Utils.GetFormValues("txt_moban_chanpinid"); var txt_moban_shuliang = Utils.GetFormValues("txt_moban_shuliang"); if (txt_moban_gysid.Length != txt_moban_chanpinid.Length || txt_moban_gysid.Length != txt_moban_shuliang.Length) { Utils.RCWE_AJAX("0", "表单异常"); } for (int i = 0; i < txt_moban_gysid.Length; i++) { var item = new EyouSoft.Model.MCaiGouMoBanChanPinInfo(); item.GysId = txt_moban_gysid[i]; item.ChanPinId = txt_moban_chanpinid[i]; item.ShuLiang = Utils.GetDecimal(txt_moban_shuliang[i]); if (string.IsNullOrEmpty(item.GysId) || string.IsNullOrEmpty(item.ChanPinId)) { continue; } bool isExists = false; foreach (var item1 in info.ChanPins) { if (item1.ChanPinId == item.ChanPinId) { isExists = true; } } if (isExists) { continue; } info.ChanPins.Add(item); } if (info.ChanPins == null || info.ChanPins.Count == 0) { Utils.RCWE_AJAX("0", "至少要选择一个有效产品"); } return(info); }