public bool AddAllot(Doc_Allot info) { int result = 0; if (info != null) { result = daInstance.Add(info); } return result > 0 ? true : false; }
public JsonResult AllotOperation(FormCollection formCollect) { Doc_Allot doc = new Doc_Allot(); string id = formCollect["DA_Code"]; doc = diInstance.GetAllotModel(string.Format("AND DA_Code='{0}'", id)); doc.DA_Opinion = formCollect["DA_Opinion"]; doc.DA_IsHandle = "Handle"; doc.DA_IsHandleName = "处理"; diInstance.UpdateAllot(doc); return new JsonResult { Data = new { result = "success", Msg = "数据更新成功!" } }; }
public ActionResult DocCC(string code, string name, string doc, string module) { if (!string.IsNullOrEmpty(code)) { string[] codeArray = code.Split(','); string[] nameArray = name.Split(','); for (int i = 0; i < codeArray.Length; i++) { var c = codeArray[i]; var na = nameArray[i]; Doc_Allot allot = new Doc_Allot(); allot.DA_Code = diInstance.GenerateAllotCode(); allot.DA_Module = module; //未处理 allot.DA_IsHandle = "NoHandle"; allot.DA_IsHandleName = "未处理"; //分发人编码 allot.DA_Allot = c; //分法人名字 allot.DA_Account = na; allot.DA_DocCode = doc; allot.DA_iType = AllotType.CC.ToString(); allot.DA_Date = DateTime.Now; diInstance.AddAllot(allot); BLL.Bll_Comm.OpLog("Allot", "Allot", string.Format("抄送:{0}", allot.DA_DocCode)); } return new JsonResult { Data = new { result = "success", Msg = "数据更新成功!" } }; } return new JsonResult { Data = new { result = "fail", Msg = "数据更新失败!" } }; }
/// <summary> /// 更新Doc_Allot对象(即:一条记录 /// </summary> public int Update(Doc_Allot doc_Allot) { StringBuilder sbParameter=new StringBuilder(); StringBuilder sb=new StringBuilder(); sb.Append(@"UPDATE Doc_Allot SET "); if(doc_Allot.DA_Code_IsChanged){sbParameter.Append("DA_Code=@DA_Code, ");} if(doc_Allot.DA_DocCode_IsChanged){sbParameter.Append("DA_DocCode=@DA_DocCode, ");} if(doc_Allot.DA_Module_IsChanged){sbParameter.Append("DA_Module=@DA_Module, ");} if(doc_Allot.DA_IsHandle_IsChanged){sbParameter.Append("DA_IsHandle=@DA_IsHandle, ");} if(doc_Allot.DA_IsHandleName_IsChanged){sbParameter.Append("DA_IsHandleName=@DA_IsHandleName, ");} if(doc_Allot.DA_Date_IsChanged){sbParameter.Append("DA_Date=@DA_Date, ");} if(doc_Allot.DA_Opinion_IsChanged){sbParameter.Append("DA_Opinion=@DA_Opinion, ");} if(doc_Allot.DA_Allot_IsChanged){sbParameter.Append("DA_Allot=@DA_Allot, ");} if(doc_Allot.DA_Account_IsChanged){sbParameter.Append("DA_Account=@DA_Account, ");} if(doc_Allot.DA_Type_IsChanged){sbParameter.Append("DA_Type=@DA_Type, ");} if(doc_Allot.DA_TypeName_IsChanged){sbParameter.Append("DA_TypeName=@DA_TypeName, ");} if(doc_Allot.DA_iType_IsChanged){sbParameter.Append("DA_iType=@DA_iType, ");} if(doc_Allot.DA_RefCode_IsChanged){sbParameter.Append("DA_RefCode=@DA_RefCode, ");} if(doc_Allot.Stat_IsChanged){sbParameter.Append("Stat=@Stat, ");} if(doc_Allot.CreateTime_IsChanged){sbParameter.Append("CreateTime=@CreateTime, ");} if(doc_Allot.UpdateTime_IsChanged){sbParameter.Append("UpdateTime=@UpdateTime, ");} if(doc_Allot.DeleteTime_IsChanged){sbParameter.Append("DeleteTime=@DeleteTime, ");} if(doc_Allot.DA_Udef1_IsChanged){sbParameter.Append("DA_Udef1=@DA_Udef1, ");} if(doc_Allot.DA_Udef2_IsChanged){sbParameter.Append("DA_Udef2=@DA_Udef2, ");} if(doc_Allot.DA_Udef3_IsChanged){sbParameter.Append("DA_Udef3=@DA_Udef3 ");} sb.Append(sbParameter.ToString().Trim().TrimEnd(',')); sb.Append( " WHERE 1=1 AND ((Stat is null) or (Stat=0)) and DA_ID=@DA_ID; " ); string sql=sb.ToString(); if(doc_Allot.DA_Code_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_Code)) { idb.AddParameter("@DA_Code", DBNull.Value); } else { idb.AddParameter("@DA_Code", doc_Allot.DA_Code); } } if(doc_Allot.DA_DocCode_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_DocCode)) { idb.AddParameter("@DA_DocCode", DBNull.Value); } else { idb.AddParameter("@DA_DocCode", doc_Allot.DA_DocCode); } } if(doc_Allot.DA_Module_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_Module)) { idb.AddParameter("@DA_Module", DBNull.Value); } else { idb.AddParameter("@DA_Module", doc_Allot.DA_Module); } } if(doc_Allot.DA_IsHandle_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_IsHandle)) { idb.AddParameter("@DA_IsHandle", DBNull.Value); } else { idb.AddParameter("@DA_IsHandle", doc_Allot.DA_IsHandle); } } if(doc_Allot.DA_IsHandleName_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_IsHandleName)) { idb.AddParameter("@DA_IsHandleName", DBNull.Value); } else { idb.AddParameter("@DA_IsHandleName", doc_Allot.DA_IsHandleName); } } if(doc_Allot.DA_Date_IsChanged) { if (doc_Allot.DA_Date == DateTime.MinValue) { idb.AddParameter("@DA_Date", DBNull.Value); } else { idb.AddParameter("@DA_Date", doc_Allot.DA_Date); } } if(doc_Allot.DA_Opinion_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_Opinion)) { idb.AddParameter("@DA_Opinion", DBNull.Value); } else { idb.AddParameter("@DA_Opinion", doc_Allot.DA_Opinion); } } if(doc_Allot.DA_Allot_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_Allot)) { idb.AddParameter("@DA_Allot", DBNull.Value); } else { idb.AddParameter("@DA_Allot", doc_Allot.DA_Allot); } } if(doc_Allot.DA_Account_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_Account)) { idb.AddParameter("@DA_Account", DBNull.Value); } else { idb.AddParameter("@DA_Account", doc_Allot.DA_Account); } } if(doc_Allot.DA_Type_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_Type)) { idb.AddParameter("@DA_Type", DBNull.Value); } else { idb.AddParameter("@DA_Type", doc_Allot.DA_Type); } } if(doc_Allot.DA_TypeName_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_TypeName)) { idb.AddParameter("@DA_TypeName", DBNull.Value); } else { idb.AddParameter("@DA_TypeName", doc_Allot.DA_TypeName); } } if(doc_Allot.DA_iType_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_iType)) { idb.AddParameter("@DA_iType", DBNull.Value); } else { idb.AddParameter("@DA_iType", doc_Allot.DA_iType); } } if(doc_Allot.DA_RefCode_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_RefCode)) { idb.AddParameter("@DA_RefCode", DBNull.Value); } else { idb.AddParameter("@DA_RefCode", doc_Allot.DA_RefCode); } } if(doc_Allot.Stat_IsChanged) { if (doc_Allot.Stat == 0) { idb.AddParameter("@Stat", 0); } else { idb.AddParameter("@Stat", doc_Allot.Stat); } } if(doc_Allot.CreateTime_IsChanged) { if (doc_Allot.CreateTime == DateTime.MinValue) { idb.AddParameter("@CreateTime", DBNull.Value); } else { idb.AddParameter("@CreateTime", doc_Allot.CreateTime); } } if(doc_Allot.UpdateTime_IsChanged) { if (doc_Allot.UpdateTime == DateTime.MinValue) { idb.AddParameter("@UpdateTime", DBNull.Value); } else { idb.AddParameter("@UpdateTime", doc_Allot.UpdateTime); } } if(doc_Allot.DeleteTime_IsChanged) { if (doc_Allot.DeleteTime == DateTime.MinValue) { idb.AddParameter("@DeleteTime", DBNull.Value); } else { idb.AddParameter("@DeleteTime", doc_Allot.DeleteTime); } } if(doc_Allot.DA_Udef1_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_Udef1)) { idb.AddParameter("@DA_Udef1", DBNull.Value); } else { idb.AddParameter("@DA_Udef1", doc_Allot.DA_Udef1); } } if(doc_Allot.DA_Udef2_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_Udef2)) { idb.AddParameter("@DA_Udef2", DBNull.Value); } else { idb.AddParameter("@DA_Udef2", doc_Allot.DA_Udef2); } } if(doc_Allot.DA_Udef3_IsChanged) { if (string.IsNullOrEmpty(doc_Allot.DA_Udef3)) { idb.AddParameter("@DA_Udef3", DBNull.Value); } else { idb.AddParameter("@DA_Udef3", doc_Allot.DA_Udef3); } } idb.AddParameter("@DA_ID", doc_Allot.DA_ID); return idb.ExeCmd(sql);
/// <summary> /// 获取指定的Doc_Allot对象集合 /// </summary> public List<Doc_Allot> GetListByWhere(string strCondition) { List<Doc_Allot> ret = new List<Doc_Allot>(); string sql = "SELECT DA_ID,DA_Code,DA_DocCode,DA_Module,DA_IsHandle,DA_IsHandleName,DA_Date,DA_Opinion,DA_Allot,DA_Account,DA_Type,DA_TypeName,DA_iType,DA_RefCode,Stat,CreateTime,UpdateTime,DeleteTime,DA_Udef1,DA_Udef2,DA_Udef3 FROM Doc_Allot WHERE 1=1 AND ((Stat is null) or (Stat=0) ) "; if(!string.IsNullOrEmpty(strCondition)) { strCondition.Replace('\'','"'); //防sql注入 sql += strCondition ; } sql += " ORDER BY DA_ID DESC "; SqlDataReader dr=null; try { dr=(SqlDataReader)idb.ReturnReader(sql); while(dr.Read()) { Doc_Allot doc_Allot = new Doc_Allot(); if (dr["DA_ID"] != DBNull.Value) doc_Allot.DA_ID = Convert.ToDecimal(dr["DA_ID"]); if (dr["DA_Code"] != DBNull.Value) doc_Allot.DA_Code = Convert.ToString(dr["DA_Code"]); if (dr["DA_DocCode"] != DBNull.Value) doc_Allot.DA_DocCode = Convert.ToString(dr["DA_DocCode"]); if (dr["DA_Module"] != DBNull.Value) doc_Allot.DA_Module = Convert.ToString(dr["DA_Module"]); if (dr["DA_IsHandle"] != DBNull.Value) doc_Allot.DA_IsHandle = Convert.ToString(dr["DA_IsHandle"]); if (dr["DA_IsHandleName"] != DBNull.Value) doc_Allot.DA_IsHandleName = Convert.ToString(dr["DA_IsHandleName"]); if (dr["DA_Date"] != DBNull.Value) doc_Allot.DA_Date = Convert.ToDateTime(dr["DA_Date"]); if (dr["DA_Opinion"] != DBNull.Value) doc_Allot.DA_Opinion = Convert.ToString(dr["DA_Opinion"]); if (dr["DA_Allot"] != DBNull.Value) doc_Allot.DA_Allot = Convert.ToString(dr["DA_Allot"]); if (dr["DA_Account"] != DBNull.Value) doc_Allot.DA_Account = Convert.ToString(dr["DA_Account"]); if (dr["DA_Type"] != DBNull.Value) doc_Allot.DA_Type = Convert.ToString(dr["DA_Type"]); if (dr["DA_TypeName"] != DBNull.Value) doc_Allot.DA_TypeName = Convert.ToString(dr["DA_TypeName"]); if (dr["DA_iType"] != DBNull.Value) doc_Allot.DA_iType = Convert.ToString(dr["DA_iType"]); if (dr["DA_RefCode"] != DBNull.Value) doc_Allot.DA_RefCode = Convert.ToString(dr["DA_RefCode"]); if (dr["Stat"] != DBNull.Value) doc_Allot.Stat = Convert.ToInt32(dr["Stat"]); if (dr["CreateTime"] != DBNull.Value) doc_Allot.CreateTime = Convert.ToDateTime(dr["CreateTime"]); if (dr["UpdateTime"] != DBNull.Value) doc_Allot.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]); if (dr["DeleteTime"] != DBNull.Value) doc_Allot.DeleteTime = Convert.ToDateTime(dr["DeleteTime"]); if (dr["DA_Udef1"] != DBNull.Value) doc_Allot.DA_Udef1 = Convert.ToString(dr["DA_Udef1"]); if (dr["DA_Udef2"] != DBNull.Value) doc_Allot.DA_Udef2 = Convert.ToString(dr["DA_Udef2"]); if (dr["DA_Udef3"] != DBNull.Value) doc_Allot.DA_Udef3 = Convert.ToString(dr["DA_Udef3"]); ret.Add(doc_Allot); } }catch (System.Exception ex){ throw ex; } finally { if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); } } return ret; }
/// <summary> /// 获取指定的Doc_Allot对象(即:一条记录 /// </summary> public Doc_Allot GetByKey(decimal dA_ID) { Doc_Allot doc_Allot = new Doc_Allot(); string sql = "SELECT DA_ID,DA_Code,DA_DocCode,DA_Module,DA_IsHandle,DA_IsHandleName,DA_Date,DA_Opinion,DA_Allot,DA_Account,DA_Type,DA_TypeName,DA_iType,DA_RefCode,Stat,CreateTime,UpdateTime,DeleteTime,DA_Udef1,DA_Udef2,DA_Udef3 FROM Doc_Allot WHERE 1=1 AND ((Stat is null) or (Stat=0) ) AND DA_ID=@DA_ID "; idb.AddParameter("@DA_ID", dA_ID); SqlDataReader dr=null; try { dr=(SqlDataReader)idb.ReturnReader(sql); while(dr.Read()) { if (dr["DA_ID"] != DBNull.Value) doc_Allot.DA_ID = Convert.ToDecimal(dr["DA_ID"]); if (dr["DA_Code"] != DBNull.Value) doc_Allot.DA_Code = Convert.ToString(dr["DA_Code"]); if (dr["DA_DocCode"] != DBNull.Value) doc_Allot.DA_DocCode = Convert.ToString(dr["DA_DocCode"]); if (dr["DA_Module"] != DBNull.Value) doc_Allot.DA_Module = Convert.ToString(dr["DA_Module"]); if (dr["DA_IsHandle"] != DBNull.Value) doc_Allot.DA_IsHandle = Convert.ToString(dr["DA_IsHandle"]); if (dr["DA_IsHandleName"] != DBNull.Value) doc_Allot.DA_IsHandleName = Convert.ToString(dr["DA_IsHandleName"]); if (dr["DA_Date"] != DBNull.Value) doc_Allot.DA_Date = Convert.ToDateTime(dr["DA_Date"]); if (dr["DA_Opinion"] != DBNull.Value) doc_Allot.DA_Opinion = Convert.ToString(dr["DA_Opinion"]); if (dr["DA_Allot"] != DBNull.Value) doc_Allot.DA_Allot = Convert.ToString(dr["DA_Allot"]); if (dr["DA_Account"] != DBNull.Value) doc_Allot.DA_Account = Convert.ToString(dr["DA_Account"]); if (dr["DA_Type"] != DBNull.Value) doc_Allot.DA_Type = Convert.ToString(dr["DA_Type"]); if (dr["DA_TypeName"] != DBNull.Value) doc_Allot.DA_TypeName = Convert.ToString(dr["DA_TypeName"]); if (dr["DA_iType"] != DBNull.Value) doc_Allot.DA_iType = Convert.ToString(dr["DA_iType"]); if (dr["DA_RefCode"] != DBNull.Value) doc_Allot.DA_RefCode = Convert.ToString(dr["DA_RefCode"]); if (dr["Stat"] != DBNull.Value) doc_Allot.Stat = Convert.ToInt32(dr["Stat"]); if (dr["CreateTime"] != DBNull.Value) doc_Allot.CreateTime = Convert.ToDateTime(dr["CreateTime"]); if (dr["UpdateTime"] != DBNull.Value) doc_Allot.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]); if (dr["DeleteTime"] != DBNull.Value) doc_Allot.DeleteTime = Convert.ToDateTime(dr["DeleteTime"]); if (dr["DA_Udef1"] != DBNull.Value) doc_Allot.DA_Udef1 = Convert.ToString(dr["DA_Udef1"]); if (dr["DA_Udef2"] != DBNull.Value) doc_Allot.DA_Udef2 = Convert.ToString(dr["DA_Udef2"]); if (dr["DA_Udef3"] != DBNull.Value) doc_Allot.DA_Udef3 = Convert.ToString(dr["DA_Udef3"]); } }catch (System.Exception ex){ throw ex; } finally { if (dr != null) { dr.Close(); } if (idb.GetConnection() != null && idb.GetConnection().State == ConnectionState.Open) { idb.GetConnection().Close(); } } return doc_Allot; }
/// <summary> /// 添加Doc_Allot对象(即:一条记录) /// </summary> public int Add(Doc_Allot doc_Allot) { string sql = "INSERT INTO Doc_Allot (DA_Code,DA_DocCode,DA_Module,DA_IsHandle,DA_IsHandleName,DA_Date,DA_Opinion,DA_Allot,DA_Account,DA_Type,DA_TypeName,DA_iType,DA_RefCode,Stat,CreateTime,UpdateTime,DeleteTime,DA_Udef1,DA_Udef2,DA_Udef3) VALUES (@DA_Code,@DA_DocCode,@DA_Module,@DA_IsHandle,@DA_IsHandleName,@DA_Date,@DA_Opinion,@DA_Allot,@DA_Account,@DA_Type,@DA_TypeName,@DA_iType,@DA_RefCode,@Stat,@CreateTime,@UpdateTime,@DeleteTime,@DA_Udef1,@DA_Udef2,@DA_Udef3)"; if (string.IsNullOrEmpty(doc_Allot.DA_Code)) { idb.AddParameter("@DA_Code", DBNull.Value); } else { idb.AddParameter("@DA_Code", doc_Allot.DA_Code); } if (string.IsNullOrEmpty(doc_Allot.DA_DocCode)) { idb.AddParameter("@DA_DocCode", DBNull.Value); } else { idb.AddParameter("@DA_DocCode", doc_Allot.DA_DocCode); } if (string.IsNullOrEmpty(doc_Allot.DA_Module)) { idb.AddParameter("@DA_Module", DBNull.Value); } else { idb.AddParameter("@DA_Module", doc_Allot.DA_Module); } if (string.IsNullOrEmpty(doc_Allot.DA_IsHandle)) { idb.AddParameter("@DA_IsHandle", DBNull.Value); } else { idb.AddParameter("@DA_IsHandle", doc_Allot.DA_IsHandle); } if (string.IsNullOrEmpty(doc_Allot.DA_IsHandleName)) { idb.AddParameter("@DA_IsHandleName", DBNull.Value); } else { idb.AddParameter("@DA_IsHandleName", doc_Allot.DA_IsHandleName); } if (doc_Allot.DA_Date == DateTime.MinValue) { idb.AddParameter("@DA_Date", DBNull.Value); } else { idb.AddParameter("@DA_Date", doc_Allot.DA_Date); } if (string.IsNullOrEmpty(doc_Allot.DA_Opinion)) { idb.AddParameter("@DA_Opinion", DBNull.Value); } else { idb.AddParameter("@DA_Opinion", doc_Allot.DA_Opinion); } if (string.IsNullOrEmpty(doc_Allot.DA_Allot)) { idb.AddParameter("@DA_Allot", DBNull.Value); } else { idb.AddParameter("@DA_Allot", doc_Allot.DA_Allot); } if (string.IsNullOrEmpty(doc_Allot.DA_Account)) { idb.AddParameter("@DA_Account", DBNull.Value); } else { idb.AddParameter("@DA_Account", doc_Allot.DA_Account); } if (string.IsNullOrEmpty(doc_Allot.DA_Type)) { idb.AddParameter("@DA_Type", DBNull.Value); } else { idb.AddParameter("@DA_Type", doc_Allot.DA_Type); } if (string.IsNullOrEmpty(doc_Allot.DA_TypeName)) { idb.AddParameter("@DA_TypeName", DBNull.Value); } else { idb.AddParameter("@DA_TypeName", doc_Allot.DA_TypeName); } if (string.IsNullOrEmpty(doc_Allot.DA_iType)) { idb.AddParameter("@DA_iType", DBNull.Value); } else { idb.AddParameter("@DA_iType", doc_Allot.DA_iType); } if (string.IsNullOrEmpty(doc_Allot.DA_RefCode)) { idb.AddParameter("@DA_RefCode", DBNull.Value); } else { idb.AddParameter("@DA_RefCode", doc_Allot.DA_RefCode); } if (doc_Allot.Stat == 0) { idb.AddParameter("@Stat", 0); } else { idb.AddParameter("@Stat", doc_Allot.Stat); } if (doc_Allot.CreateTime == DateTime.MinValue) { idb.AddParameter("@CreateTime", DBNull.Value); } else { idb.AddParameter("@CreateTime", doc_Allot.CreateTime); } if (doc_Allot.UpdateTime == DateTime.MinValue) { idb.AddParameter("@UpdateTime", DBNull.Value); } else { idb.AddParameter("@UpdateTime", doc_Allot.UpdateTime); } if (doc_Allot.DeleteTime == DateTime.MinValue) { idb.AddParameter("@DeleteTime", DBNull.Value); } else { idb.AddParameter("@DeleteTime", doc_Allot.DeleteTime); } if (string.IsNullOrEmpty(doc_Allot.DA_Udef1)) { idb.AddParameter("@DA_Udef1", DBNull.Value); } else { idb.AddParameter("@DA_Udef1", doc_Allot.DA_Udef1); } if (string.IsNullOrEmpty(doc_Allot.DA_Udef2)) { idb.AddParameter("@DA_Udef2", DBNull.Value); } else { idb.AddParameter("@DA_Udef2", doc_Allot.DA_Udef2); } if (string.IsNullOrEmpty(doc_Allot.DA_Udef3)) { idb.AddParameter("@DA_Udef3", DBNull.Value); } else { idb.AddParameter("@DA_Udef3", doc_Allot.DA_Udef3); } return idb.ExeCmd(sql); }