/// <summary> /// 得到一个对象实体 主表 /// </summary> public SCZM.Model.Repair.repair_Scheme GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,IntentionId,SchemeCode,RepairContent,FlagENGKC,FlagPPMKC,FlagENG,FlagPPM,FlagMCV,FlagELE,FlagVM,FlagRM,FlagSM,FlagUM,FlagVR,FlagSP,FlagOther,SchemeDate,PromiseLeaveDate,TimeFee,PartFee,SchemeFee,FlagDel,OperaDepId,OperaId,OperaName,OperaTime,SchemeDate_predict,AttachmentId_Scheme_predict,SchemeFee_predict,Memo from repair_Scheme "); strSql.Append(" where FlagDel=0 and ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; SCZM.Model.Repair.repair_Scheme model = new SCZM.Model.Repair.repair_Scheme(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { #region 父表信息 model = DataRowToModel(ds.Tables[0].Rows[0]); #endregion 父表信息end return(model); } else { return(null); } }
private void SaveData(HttpContext context, string btn) { if (btn != "btnSave") { context.Response.Write("{\"status\":\"0.2\",\"msg\":\"对不起,您没有操作权限!\"}"); return; } string ID = RequestHelper.GetString("ID"); string IntentionId = RequestHelper.GetString("IntentionId"); string SchemeType = RequestHelper.GetString("SchemeType"); string SchemeCode = RequestHelper.GetString("SchemeCode"); string RepairContent = RequestHelper.GetString("RepairContent"); string FlagENGKC = RequestHelper.GetString("FlagENGKC"); string FlagPPMKC = RequestHelper.GetString("FlagPPMKC"); string FlagENG = RequestHelper.GetString("FlagENG"); string FlagPPM = RequestHelper.GetString("FlagPPM"); string FlagMCV = RequestHelper.GetString("FlagMCV"); string FlagELE = RequestHelper.GetString("FlagELE"); string FlagVM = RequestHelper.GetString("FlagVM"); string FlagRM = RequestHelper.GetString("FlagRM"); string FlagSM = RequestHelper.GetString("FlagSM"); string FlagUM = RequestHelper.GetString("FlagUM"); string FlagVR = RequestHelper.GetString("FlagVR"); string FlagSP = RequestHelper.GetString("FlagSP"); string FlagOther = RequestHelper.GetString("FlagOther"); string SchemeDate = RequestHelper.GetString("SchemeDate"); string PromiseLeaveDate = RequestHelper.GetString("PromiseLeaveDate"); string TimeFee = RequestHelper.GetString("TimeFee"); string PartFee = RequestHelper.GetString("PartFee"); string SchemeFee = RequestHelper.GetString("SchemeFee"); string OperaDepId = RequestHelper.GetString("OperaDepId"); string AttachmentId_Scheme = RequestHelper.GetString("AttachmentId_Scheme").Trim(); string SchemeDate_predict = RequestHelper.GetString("SchemeDate_predict").Trim(); string SchemeFee_predict = RequestHelper.GetString("SchemeFee_predict"); string AttachmentId_Scheme_predict = RequestHelper.GetString("AttachmentId_Scheme_predict"); string AttachmentId_Agreement = RequestHelper.GetString("AttachmentId_Agreement"); string Memo = RequestHelper.GetString("Memo").Trim(); Model.System.sys_LoginUser loginUserModel = BaseWeb.GetLoginInfo(); SCZM.Model.Repair.repair_Scheme model = new SCZM.Model.Repair.repair_Scheme(); SCZM.BLL.Repair.repair_Scheme bll = new SCZM.BLL.Repair.repair_Scheme(); model.ID = Utils.StrToInt(ID, 0); model.IntentionId = Utils.StrToInt(IntentionId, 0); if (SchemeCode == "") { SchemeCode = "FA" + DateTime.Now.ToString("yyyyMMdd") + bll.GetMaxId(); } model.SchemeCode = SchemeCode; model.RepairContent = RepairContent; model.FlagENGKC = Utils.StrToInt(FlagENGKC, 0); model.FlagPPMKC = Utils.StrToInt(FlagPPMKC, 0); model.FlagENG = Utils.StrToInt(FlagENG, 0); model.FlagPPM = Utils.StrToInt(FlagPPM, 0); model.FlagMCV = Utils.StrToInt(FlagMCV, 0); model.FlagELE = Utils.StrToInt(FlagELE, 0); model.FlagVM = Utils.StrToInt(FlagVM, 0); model.FlagRM = Utils.StrToInt(FlagRM, 0); model.FlagSM = Utils.StrToInt(FlagSM, 0); model.FlagUM = Utils.StrToInt(FlagUM, 0); model.FlagVR = Utils.StrToInt(FlagVR, 0); model.FlagSP = Utils.StrToInt(FlagSP, 0); model.FlagOther = Utils.StrToInt(FlagOther, 0); if (SchemeDate != "") { model.SchemeDate = Utils.StrToDateTime(SchemeDate); } //else { // model.SchemeDate = DateTime.Now; //} if (PromiseLeaveDate != "") { model.PromiseLeaveDate = Utils.StrToDateTime(PromiseLeaveDate); } if (SchemeDate_predict != "") { model.SchemeDate_predict = Utils.StrToDateTime(SchemeDate_predict); } model.AttachmentId_Scheme_predict = AttachmentId_Scheme_predict; model.AttachmentId_Scheme = AttachmentId_Scheme; model.AttachmentId_Agreement = AttachmentId_Agreement; model.TimeFee = Utils.StrToDecimal(TimeFee, 0); model.PartFee = Utils.StrToDecimal(PartFee, 0); model.SchemeFee = Utils.StrToDecimal(SchemeFee, 0); model.SchemeFee_predict = Utils.StrToDecimal(SchemeFee_predict, 0); model.FlagDel = 0; model.OperaDepId = Utils.StrToInt(OperaDepId, 0); model.OperaId = loginUserModel.ID; model.OperaName = loginUserModel.PerName; model.OperaTime = DateTime.Now; model.Memo = Memo; string operaMessage = ""; string status = "0"; string operaAction = ""; string operaMemo = ""; try { if (ID == "") { model.ID = bll.Add(model, out operaMessage); if (model.ID > 0) { status = "1"; operaAction = Enums.ActionEnum.Add.ToString(); operaMemo = "新增维修方案:" + model.ID; } } else { if (bll.Update(model, out operaMessage)) { status = "1"; operaAction = Enums.ActionEnum.Edit.ToString(); operaMemo = "修改维修方案:" + model.ID; } } if (status == "1") { //写入操作日志 BaseWeb.AddOpera(loginUserModel, int.Parse(RequestHelper.GetQueryString("MenuId")), operaAction, operaMemo); } context.Response.Write("{\"status\":\"" + status + "\",\"msg\":\"" + operaMessage + "\"}"); return; } catch (Exception e) { context.Response.Write("{\"status\":\"0\",\"msg\":\"对不起,系统出错:" + Utils.HtmlEncode(e.Message) + "\"}"); return; } }
/// <summary> /// 增加一条数据,及其子表数据 /// </summary> public int Add(SCZM.Model.Repair.repair_Scheme model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into repair_Scheme("); strSql.Append("IntentionId,SchemeCode,RepairContent,FlagENGKC,FlagPPMKC,FlagENG,FlagPPM,FlagMCV,FlagELE,FlagVM,FlagRM,FlagSM,FlagUM,FlagVR,SchemeDate,PromiseLeaveDate,TimeFee,PartFee,SchemeFee,FlagDel,OperaDepId,OperaId,OperaName,OperaTime,FlagSP,FlagOther,AttachmentId_Scheme,SchemeDate_predict,AttachmentId_Scheme_predict,SchemeFee_predict,Memo)"); strSql.Append(" values ("); strSql.Append("@IntentionId,@SchemeCode,@RepairContent,@FlagENGKC,@FlagPPMKC,@FlagENG,@FlagPPM,@FlagMCV,@FlagELE,@FlagVM,@FlagRM,@FlagSM,@FlagUM,@FlagVR,@SchemeDate,@PromiseLeaveDate,@TimeFee,@PartFee,@SchemeFee,@FlagDel,@OperaDepId,@OperaId,@OperaName,@OperaTime,@FlagSP,@FlagOther,@AttachmentId_Scheme,@SchemeDate_predict,@AttachmentId_Scheme_predict,@SchemeFee_predict,@Memo )"); strSql.Append(";set @ReturnValue= @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@IntentionId", SqlDbType.Int, 4), new SqlParameter("@SchemeCode", SqlDbType.VarChar, 20), new SqlParameter("@RepairContent", SqlDbType.NVarChar, 200), new SqlParameter("@FlagENGKC", SqlDbType.Int, 4), new SqlParameter("@FlagPPMKC", SqlDbType.Int, 4), new SqlParameter("@FlagENG", SqlDbType.Int, 4), new SqlParameter("@FlagPPM", SqlDbType.Int, 4), new SqlParameter("@FlagMCV", SqlDbType.Int, 4), new SqlParameter("@FlagELE", SqlDbType.Int, 4), new SqlParameter("@FlagVM", SqlDbType.Int, 4), new SqlParameter("@FlagRM", SqlDbType.Int, 4), new SqlParameter("@FlagSM", SqlDbType.Int, 4), new SqlParameter("@FlagUM", SqlDbType.Int, 4), new SqlParameter("@FlagVR", SqlDbType.Int, 4), new SqlParameter("@SchemeDate", SqlDbType.SmallDateTime), new SqlParameter("@PromiseLeaveDate", SqlDbType.SmallDateTime), new SqlParameter("@TimeFee", SqlDbType.Decimal, 9), new SqlParameter("@PartFee", SqlDbType.Decimal, 9), new SqlParameter("@SchemeFee", SqlDbType.Decimal, 9), new SqlParameter("@FlagDel", SqlDbType.Int, 4), new SqlParameter("@OperaDepId", SqlDbType.Int, 4), new SqlParameter("@OperaId", SqlDbType.Int, 4), new SqlParameter("@OperaName", SqlDbType.NVarChar, 10), new SqlParameter("@OperaTime", SqlDbType.DateTime), new SqlParameter("@FlagSP", SqlDbType.Int, 4), new SqlParameter("@FlagOther", SqlDbType.Int, 4), new SqlParameter("@AttachmentId_Scheme", SqlDbType.VarChar, 100), new SqlParameter("@SchemeDate_predict", SqlDbType.SmallDateTime), //AttachmentId_Scheme_predict,SchemeFee_predict,Memo new SqlParameter("@AttachmentId_Scheme_predict", SqlDbType.VarChar, 100), new SqlParameter("@SchemeFee_predict", SqlDbType.Decimal, 18), new SqlParameter("@Memo", SqlDbType.NVarChar, 200), new SqlParameter("@ReturnValue", SqlDbType.Int) }; parameters[0].Value = model.IntentionId; parameters[1].Value = model.SchemeCode; parameters[2].Value = model.RepairContent; parameters[3].Value = model.FlagENGKC; parameters[4].Value = model.FlagPPMKC; parameters[5].Value = model.FlagENG; parameters[6].Value = model.FlagPPM; parameters[7].Value = model.FlagMCV; parameters[8].Value = model.FlagELE; parameters[9].Value = model.FlagVM; parameters[10].Value = model.FlagRM; parameters[11].Value = model.FlagSM; parameters[12].Value = model.FlagUM; parameters[13].Value = model.FlagVR; parameters[14].Value = model.SchemeDate; parameters[15].Value = model.PromiseLeaveDate; parameters[16].Value = model.TimeFee; parameters[17].Value = model.PartFee; parameters[18].Value = model.SchemeFee; parameters[19].Value = model.FlagDel; parameters[20].Value = model.OperaDepId; parameters[21].Value = model.OperaId; parameters[22].Value = model.OperaName; parameters[23].Value = model.OperaTime; parameters[24].Value = model.FlagSP; parameters[25].Value = model.FlagOther; parameters[26].Value = model.AttachmentId_Scheme; parameters[27].Value = model.SchemeDate_predict; parameters[28].Value = model.AttachmentId_Scheme_predict; parameters[29].Value = model.SchemeFee_predict; parameters[30].Value = model.Memo; parameters[31].Direction = ParameterDirection.Output; List <CommandInfo> sqllist = new List <CommandInfo>(); CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(cmd); StringBuilder strSql4 = new StringBuilder(); strSql4.Append("Update repair_Intention set RepairState=30 where ID=@IntentionId and FlagDel=0"); SqlParameter[] parameters4 = { new SqlParameter("@IntentionId", SqlDbType.Int, 4) }; parameters4[0].Value = model.IntentionId; cmd = new CommandInfo(strSql4.ToString(), parameters4); sqllist.Add(cmd); DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist); return((int)parameters[31].Value); }
/// <summary> /// 得到一个对象实体 子方法 从DataRow中 /// </summary> public SCZM.Model.Repair.repair_Scheme DataRowToModel(DataRow row) { SCZM.Model.Repair.repair_Scheme model = new SCZM.Model.Repair.repair_Scheme(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["IntentionId"] != null && row["IntentionId"].ToString() != "") { model.IntentionId = int.Parse(row["IntentionId"].ToString()); } if (row["SchemeCode"] != null) { model.SchemeCode = row["SchemeCode"].ToString(); } if (row["RepairContent"] != null) { model.RepairContent = row["RepairContent"].ToString(); } if (row["FlagENGKC"] != null && row["FlagENGKC"].ToString() != "") { model.FlagENGKC = int.Parse(row["FlagENGKC"].ToString()); } if (row["FlagPPMKC"] != null && row["FlagPPMKC"].ToString() != "") { model.FlagPPMKC = int.Parse(row["FlagPPMKC"].ToString()); } if (row["FlagENG"] != null && row["FlagENG"].ToString() != "") { model.FlagENG = int.Parse(row["FlagENG"].ToString()); } if (row["FlagPPM"] != null && row["FlagPPM"].ToString() != "") { model.FlagPPM = int.Parse(row["FlagPPM"].ToString()); } if (row["FlagMCV"] != null && row["FlagMCV"].ToString() != "") { model.FlagMCV = int.Parse(row["FlagMCV"].ToString()); } if (row["FlagELE"] != null && row["FlagELE"].ToString() != "") { model.FlagELE = int.Parse(row["FlagELE"].ToString()); } if (row["FlagVM"] != null && row["FlagVM"].ToString() != "") { model.FlagVM = int.Parse(row["FlagVM"].ToString()); } if (row["FlagRM"] != null && row["FlagRM"].ToString() != "") { model.FlagRM = int.Parse(row["FlagRM"].ToString()); } if (row["FlagSM"] != null && row["FlagSM"].ToString() != "") { model.FlagSM = int.Parse(row["FlagSM"].ToString()); } if (row["FlagUM"] != null && row["FlagUM"].ToString() != "") { model.FlagUM = int.Parse(row["FlagUM"].ToString()); } if (row["FlagVR"] != null && row["FlagVR"].ToString() != "") { model.FlagVR = int.Parse(row["FlagVR"].ToString()); } if (row["FlagSP"] != null && row["FlagSP"].ToString() != "") { model.FlagSP = int.Parse(row["FlagSP"].ToString()); } if (row["FlagOther"] != null && row["FlagOther"].ToString() != "") { model.FlagOther = int.Parse(row["FlagOther"].ToString()); } if (row["SchemeDate"] != null && row["SchemeDate"].ToString() != "") { model.SchemeDate = DateTime.Parse(row["SchemeDate"].ToString()); } if (row["PromiseLeaveDate"] != null && row["PromiseLeaveDate"].ToString() != "") { model.PromiseLeaveDate = DateTime.Parse(row["PromiseLeaveDate"].ToString()); } if (row["TimeFee"] != null && row["TimeFee"].ToString() != "") { model.TimeFee = decimal.Parse(row["TimeFee"].ToString()); } if (row["PartFee"] != null && row["PartFee"].ToString() != "") { model.PartFee = decimal.Parse(row["PartFee"].ToString()); } if (row["SchemeFee"] != null && row["SchemeFee"].ToString() != "") { model.SchemeFee = decimal.Parse(row["SchemeFee"].ToString()); } if (row["FlagDel"] != null && row["FlagDel"].ToString() != "") { model.FlagDel = int.Parse(row["FlagDel"].ToString()); } if (row["OperaDepId"] != null && row["OperaDepId"].ToString() != "") { model.OperaDepId = int.Parse(row["OperaDepId"].ToString()); } if (row["OperaId"] != null && row["OperaId"].ToString() != "") { model.OperaId = int.Parse(row["OperaId"].ToString()); } if (row["OperaName"] != null) { model.OperaName = row["OperaName"].ToString(); } if (row["OperaTime"] != null && row["OperaTime"].ToString() != "") { model.OperaTime = DateTime.Parse(row["OperaTime"].ToString()); } if (row["SchemeDate_predict"] != null && row["SchemeDate_predict"].ToString() != "") { model.SchemeDate_predict = DateTime.Parse(row["SchemeDate_predict"].ToString()); } if (row["AttachmentId_Scheme_predict"] != null && row["AttachmentId_Scheme_predict"].ToString() != "") { model.AttachmentId_Scheme_predict = row["AttachmentId_Scheme_predict"].ToString(); } if (row["SchemeFee_predict"] != null && row["SchemeFee_predict"].ToString() != "") { model.SchemeFee = decimal.Parse(row["SchemeFee_predict"].ToString()); } if (row["Memo"] != null && row["Memo"].ToString() != "") { model.Memo = row["Memo"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(SCZM.Model.Repair.repair_Scheme model) { List <CommandInfo> sqllist = new List <CommandInfo>(); CommandInfo cmd = null; StringBuilder strSql = new StringBuilder(); strSql.Append("update repair_Scheme set "); strSql.Append("IntentionId=@IntentionId,"); strSql.Append("SchemeCode=@SchemeCode,"); strSql.Append("RepairContent=@RepairContent,"); strSql.Append("FlagENGKC=@FlagENGKC,"); strSql.Append("FlagPPMKC=@FlagPPMKC,"); strSql.Append("FlagENG=@FlagENG,"); strSql.Append("FlagPPM=@FlagPPM,"); strSql.Append("FlagMCV=@FlagMCV,"); strSql.Append("FlagELE=@FlagELE,"); strSql.Append("FlagVM=@FlagVM,"); strSql.Append("FlagRM=@FlagRM,"); strSql.Append("FlagSM=@FlagSM,"); strSql.Append("FlagUM=@FlagUM,"); strSql.Append("FlagVR=@FlagVR,"); strSql.Append("SchemeDate=@SchemeDate,"); strSql.Append("PromiseLeaveDate=@PromiseLeaveDate,"); strSql.Append("TimeFee=@TimeFee,"); strSql.Append("PartFee=@PartFee,"); strSql.Append("SchemeFee=@SchemeFee,"); strSql.Append("FlagDel=@FlagDel,"); strSql.Append("OperaDepId=@OperaDepId,"); strSql.Append("OperaId=@OperaId,"); strSql.Append("OperaName=@OperaName,"); strSql.Append("OperaTime=@OperaTime,"); strSql.Append("FlagSP=@FlagSP,"); strSql.Append("FlagOther=@FlagOther,"); strSql.Append("AttachmentId_Scheme=@AttachmentId_Scheme,"); strSql.Append("SchemeDate_predict=@SchemeDate_predict,"); strSql.Append("AttachmentId_Scheme_predict=@AttachmentId_Scheme_predict,"); strSql.Append("SchemeFee_predict=@SchemeFee_predict,"); strSql.Append("Memo=@Memo"); strSql.Append(" where FlagDel=0 and ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@IntentionId", SqlDbType.Int, 4), new SqlParameter("@SchemeCode", SqlDbType.VarChar, 20), new SqlParameter("@RepairContent", SqlDbType.NVarChar, 200), new SqlParameter("@FlagENGKC", SqlDbType.Int, 4), new SqlParameter("@FlagPPMKC", SqlDbType.Int, 4), new SqlParameter("@FlagENG", SqlDbType.Int, 4), new SqlParameter("@FlagPPM", SqlDbType.Int, 4), new SqlParameter("@FlagMCV", SqlDbType.Int, 4), new SqlParameter("@FlagELE", SqlDbType.Int, 4), new SqlParameter("@FlagVM", SqlDbType.Int, 4), new SqlParameter("@FlagRM", SqlDbType.Int, 4), new SqlParameter("@FlagSM", SqlDbType.Int, 4), new SqlParameter("@FlagUM", SqlDbType.Int, 4), new SqlParameter("@FlagVR", SqlDbType.Int, 4), new SqlParameter("@SchemeDate", SqlDbType.SmallDateTime), new SqlParameter("@PromiseLeaveDate", SqlDbType.SmallDateTime), new SqlParameter("@TimeFee", SqlDbType.Decimal, 9), new SqlParameter("@PartFee", SqlDbType.Decimal, 9), new SqlParameter("@SchemeFee", SqlDbType.Decimal, 9), new SqlParameter("@FlagDel", SqlDbType.Int, 4), new SqlParameter("@OperaDepId", SqlDbType.Int, 4), new SqlParameter("@OperaId", SqlDbType.Int, 4), new SqlParameter("@OperaName", SqlDbType.NVarChar, 10), new SqlParameter("@OperaTime", SqlDbType.DateTime), new SqlParameter("@FlagSP", SqlDbType.Int, 4), new SqlParameter("@FlagOther", SqlDbType.Int, 4), new SqlParameter("@AttachmentId_Scheme", SqlDbType.VarChar, 100), new SqlParameter("@SchemeDate_predict", SqlDbType.SmallDateTime), new SqlParameter("@AttachmentId_Scheme_predict", SqlDbType.VarChar, 100), new SqlParameter("@SchemeFee_predict", SqlDbType.Decimal, 18), new SqlParameter("@Memo", SqlDbType.NVarChar, 200), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.IntentionId; parameters[1].Value = model.SchemeCode; parameters[2].Value = model.RepairContent; parameters[3].Value = model.FlagENGKC; parameters[4].Value = model.FlagPPMKC; parameters[5].Value = model.FlagENG; parameters[6].Value = model.FlagPPM; parameters[7].Value = model.FlagMCV; parameters[8].Value = model.FlagELE; parameters[9].Value = model.FlagVM; parameters[10].Value = model.FlagRM; parameters[11].Value = model.FlagSM; parameters[12].Value = model.FlagUM; parameters[13].Value = model.FlagVR; parameters[14].Value = model.SchemeDate; parameters[15].Value = model.PromiseLeaveDate; parameters[16].Value = model.TimeFee; parameters[17].Value = model.PartFee; parameters[18].Value = model.SchemeFee; parameters[19].Value = model.FlagDel; parameters[20].Value = model.OperaDepId; parameters[21].Value = model.OperaId; parameters[22].Value = model.OperaName; parameters[23].Value = model.OperaTime; parameters[24].Value = model.FlagSP; parameters[25].Value = model.FlagOther; parameters[26].Value = model.AttachmentId_Scheme; parameters[27].Value = model.SchemeDate_predict; parameters[28].Value = model.AttachmentId_Scheme_predict; parameters[29].Value = model.SchemeFee_predict; parameters[30].Value = model.Memo; parameters[31].Value = model.ID; cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(cmd); StringBuilder strSql6 = new StringBuilder(); strSql6.Append("Update repair_Intention set RepairState=30 where ID=@IntentionId and FlagDel=0"); SqlParameter[] parameters6 = { new SqlParameter("@IntentionId", SqlDbType.Int, 4) }; parameters6[0].Value = model.IntentionId; cmd = new CommandInfo(strSql6.ToString(), parameters6); sqllist.Add(cmd); int rows = DbHelperSQL.ExecuteSqlTran(sqllist); return(rows); }