/// <summary> /// 更新数据 /// </summary> /// <param name='model'>实体</param> /// <returns>bool</returns> public bool Update(Audit_Template model) { bool result = false; var e = new ModelExceptions(); int _rseult = instance.Update(model); if (_rseult > 0) { result = true; } return(result); }
/// <summary> /// 获取实体数据 /// </summary> /// <param name='strCondition'>条件(AND Code='11')</param> /// <returns>model</returns> public Audit_Template GetModel(string strCondition) { List <Audit_Template> list = instance.GetListByWhere(strCondition); Audit_Template model = new Audit_Template(); if (list != null && list.Count > 0) { model = list[0]; } else { model = null; } return(model); }
/// <summary> /// 插入数据 /// </summary> /// <param name='model'>实体</param> /// <param name='model'>是否完成验证</param> /// <returns>bool</returns> public bool Insert(Audit_Template model, bool IsValid) { var e = new ModelExceptions(); bool result = false; if (e.IsValid && IsValid) { //完成了验证,开始更新数据库了 int _result = instance.Add(model); if (_result > 0) { result = true; } } return(result); }
/// <summary> /// 添加或更新工艺节点列表信息 /// </summary> /// <param name="comptCode">零件图号</param> /// <param name="nodeDict">Key-工艺节点编码 value-order(顺序)</param> /// <returns></returns> public int AddOrUpdateConfig(Audit_Template curTemplate,Dictionary<string,Verify_TemplateConfig> list) { int flag = 1; try { List<Verify_TemplateConfig> oldTempList = this.GetNodesForTemplateCode(curTemplate.Template_Key); //获取该零件图号原来对应的工艺路线 foreach (Verify_TemplateConfig vt in oldTempList) { //如果不存在则删除 if (!list.ContainsKey(vt.VT_VerifyNode_Code)) { this.DeleteTempldateNode(vt); }//如果存在则把其从模板阶段列表众移除,并更新其信息 else { var tmp = list[vt.VT_VerifyNode_Code]; tmp.VT_ID = vt.VT_ID; UpdateTemplateConfig(tmp); list.Remove(tmp.VT_VerifyNode_Code); } } //添加 foreach (KeyValuePair<string,Verify_TemplateConfig> kv in list) { Verify_TemplateConfig config = kv.Value; config.VT_Template_Code = GenerateConfigCode(); var re=AddTemplateNode(kv.Value); } } catch (Exception e) { flag = 0; } return flag; }
/// <summary> /// 逻辑删除数据 /// </summary> /// <param name='model'>model</param> /// <returns>bool</returns> public bool Delete(string Condition) { bool result = false; List <Audit_Template> list = instance.GetListByWhere(Condition); if (list.Count > 0) { Audit_Template model = list[0]; model.Stat = 1; int _rseult = instance.Update(model); if (_rseult > 0) { result = true; } } return(result); }
/// <summary> /// 插入数据 /// </summary> /// <param name='model'>实体</param> /// <returns>bool</returns> public bool Insert(Audit_Template model) { bool result = false; try { int _result = instance.Add(model); if (_result > 0) { result = true; } } catch (Exception ex) { throw ex; } return(result); }
private void Init() { Bll_Sys_Map mapInst = new Bll_Sys_Map(); Map = mapInst.GetModel(string.Format(" AND Map_Module='{0}' AND Map_Source='{0}'", "SmsTemplate")); Bll_Audit auditInst = new Bll_Audit(); TemlateKey = auditInst.GetTemplateModel(ModuleCode); GridHelper gen = new GridHelper(); uGridUser = gen.GenerateGrid("CList_VUser", this.panel1, new Point(6, 20)); var dt = adInstance.GetNextVerifyUser(AuditNode, SessionConfig.UserCode); uGridUser.DataSource = dt; uGridUser.DoubleClickRow += new DoubleClickRowEventHandler(uGridUser_DoubleClickRow); gen.SetGridReadOnly(uGridUser, true); gen.SetGridColumnStyle(uGridUser, AutoFitStyle.ResizeAllColumns); AddCustomCol(); }
/// <summary> /// 获取实体数据 /// </summary> /// <param name='strCondition'>条件(AND Code='11')</param> /// <returns>model</returns> public Audit_Template GetModel(int id) { Audit_Template model = instance.GetByKey(id); return(model); }
/// <summary> /// 更新审核模板 /// </summary> /// <param name="vt"></param> /// <returns></returns> public int UpdateTemplate(Audit_Template vt) { return atInstance.Update(vt); }
/// <summary> /// 获取所有的审核模板列表 Audit_Template对象(即:一条记录 /// </summary> public List <Audit_Template> GetAll() { List <Audit_Template> ret = new List <Audit_Template>(); string sql = "SELECT Template_ID,Template_Code,Template_Key,Template_Name,Template_Remark,Stat,Template_Table,Template_Column,Template_ColumnType,Template_CheckSQL FROM Audit_Template where 1=1 AND ((Stat is null) or (Stat=0) ) order by Template_ID desc "; SqlDataReader dr = null; try { dr = (SqlDataReader)idb.ReturnReader(sql); while (dr.Read()) { Audit_Template audit_Template = new Audit_Template(); if (dr["Template_ID"] != DBNull.Value) { audit_Template.Template_ID = Convert.ToDecimal(dr["Template_ID"]); } if (dr["Template_Code"] != DBNull.Value) { audit_Template.Template_Code = Convert.ToString(dr["Template_Code"]); } if (dr["Template_Key"] != DBNull.Value) { audit_Template.Template_Key = Convert.ToString(dr["Template_Key"]); } if (dr["Template_Name"] != DBNull.Value) { audit_Template.Template_Name = Convert.ToString(dr["Template_Name"]); } if (dr["Template_Remark"] != DBNull.Value) { audit_Template.Template_Remark = Convert.ToString(dr["Template_Remark"]); } if (dr["Stat"] != DBNull.Value) { audit_Template.Stat = Convert.ToInt32(dr["Stat"]); } if (dr["Template_Table"] != DBNull.Value) { audit_Template.Template_Table = Convert.ToString(dr["Template_Table"]); } if (dr["Template_Column"] != DBNull.Value) { audit_Template.Template_Column = Convert.ToString(dr["Template_Column"]); } if (dr["Template_ColumnType"] != DBNull.Value) { audit_Template.Template_ColumnType = Convert.ToString(dr["Template_ColumnType"]); } if (dr["Template_CheckSQL"] != DBNull.Value) { audit_Template.Template_CheckSQL = Convert.ToString(dr["Template_CheckSQL"]); } ret.Add(audit_Template); } }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> /// 获取指定的审核模板列表 Audit_Template对象集合 /// </summary> public List <Audit_Template> GetListByWhere(string strCondition) { List <Audit_Template> ret = new List <Audit_Template>(); string sql = "SELECT Template_ID,Template_Code,Template_Key,Template_Name,Template_Remark,Stat,Template_Table,Template_Column,Template_ColumnType,Template_CheckSQL FROM Audit_Template WHERE 1=1 AND ((Stat is null) or (Stat=0) ) "; if (!string.IsNullOrEmpty(strCondition)) { strCondition.Replace('\'', '"'); //防sql注入 sql += strCondition; } SqlDataReader dr = null; try { dr = (SqlDataReader)idb.ReturnReader(sql); while (dr.Read()) { Audit_Template audit_Template = new Audit_Template(); if (dr["Template_ID"] != DBNull.Value) { audit_Template.Template_ID = Convert.ToDecimal(dr["Template_ID"]); } if (dr["Template_Code"] != DBNull.Value) { audit_Template.Template_Code = Convert.ToString(dr["Template_Code"]); } if (dr["Template_Key"] != DBNull.Value) { audit_Template.Template_Key = Convert.ToString(dr["Template_Key"]); } if (dr["Template_Name"] != DBNull.Value) { audit_Template.Template_Name = Convert.ToString(dr["Template_Name"]); } if (dr["Template_Remark"] != DBNull.Value) { audit_Template.Template_Remark = Convert.ToString(dr["Template_Remark"]); } if (dr["Stat"] != DBNull.Value) { audit_Template.Stat = Convert.ToInt32(dr["Stat"]); } if (dr["Template_Table"] != DBNull.Value) { audit_Template.Template_Table = Convert.ToString(dr["Template_Table"]); } if (dr["Template_Column"] != DBNull.Value) { audit_Template.Template_Column = Convert.ToString(dr["Template_Column"]); } if (dr["Template_ColumnType"] != DBNull.Value) { audit_Template.Template_ColumnType = Convert.ToString(dr["Template_ColumnType"]); } if (dr["Template_CheckSQL"] != DBNull.Value) { audit_Template.Template_CheckSQL = Convert.ToString(dr["Template_CheckSQL"]); } ret.Add(audit_Template); } }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> /// 获取指定的审核模板列表 Audit_Template对象(即:一条记录 /// </summary> public Audit_Template GetByKey(decimal template_ID) { Audit_Template audit_Template = new Audit_Template(); string sql = "SELECT Template_ID,Template_Code,Template_Key,Template_Name,Template_Remark,Stat,Template_Table,Template_Column,Template_ColumnType,Template_CheckSQL FROM Audit_Template WHERE 1=1 AND ((Stat is null) or (Stat=0) ) AND Template_ID=@Template_ID "; idb.AddParameter("@Template_ID", template_ID); SqlDataReader dr = null; try { dr = (SqlDataReader)idb.ReturnReader(sql); while (dr.Read()) { if (dr["Template_ID"] != DBNull.Value) { audit_Template.Template_ID = Convert.ToDecimal(dr["Template_ID"]); } if (dr["Template_Code"] != DBNull.Value) { audit_Template.Template_Code = Convert.ToString(dr["Template_Code"]); } if (dr["Template_Key"] != DBNull.Value) { audit_Template.Template_Key = Convert.ToString(dr["Template_Key"]); } if (dr["Template_Name"] != DBNull.Value) { audit_Template.Template_Name = Convert.ToString(dr["Template_Name"]); } if (dr["Template_Remark"] != DBNull.Value) { audit_Template.Template_Remark = Convert.ToString(dr["Template_Remark"]); } if (dr["Stat"] != DBNull.Value) { audit_Template.Stat = Convert.ToInt32(dr["Stat"]); } if (dr["Template_Table"] != DBNull.Value) { audit_Template.Template_Table = Convert.ToString(dr["Template_Table"]); } if (dr["Template_Column"] != DBNull.Value) { audit_Template.Template_Column = Convert.ToString(dr["Template_Column"]); } if (dr["Template_ColumnType"] != DBNull.Value) { audit_Template.Template_ColumnType = Convert.ToString(dr["Template_ColumnType"]); } if (dr["Template_CheckSQL"] != DBNull.Value) { audit_Template.Template_CheckSQL = Convert.ToString(dr["Template_CheckSQL"]); } } }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(audit_Template); }
/// <summary> /// 更新审核模板列表 Audit_Template对象(即:一条记录 /// </summary> public int Update(Audit_Template audit_Template) { StringBuilder sbParameter = new StringBuilder(); StringBuilder sb = new StringBuilder(); sb.Append(@"UPDATE Audit_Template SET "); if (audit_Template.Template_Code_IsChanged) { sbParameter.Append("Template_Code=@Template_Code, "); } if (audit_Template.Template_Key_IsChanged) { sbParameter.Append("Template_Key=@Template_Key, "); } if (audit_Template.Template_Name_IsChanged) { sbParameter.Append("Template_Name=@Template_Name, "); } if (audit_Template.Template_Remark_IsChanged) { sbParameter.Append("Template_Remark=@Template_Remark, "); } if (audit_Template.Stat_IsChanged) { sbParameter.Append("Stat=@Stat, "); } if (audit_Template.Template_Table_IsChanged) { sbParameter.Append("Template_Table=@Template_Table, "); } if (audit_Template.Template_Column_IsChanged) { sbParameter.Append("Template_Column=@Template_Column, "); } if (audit_Template.Template_ColumnType_IsChanged) { sbParameter.Append("Template_ColumnType=@Template_ColumnType, "); } if (audit_Template.Template_CheckSQL_IsChanged) { sbParameter.Append("Template_CheckSQL=@Template_CheckSQL "); } sb.Append(sbParameter.ToString().Trim().TrimEnd(',')); sb.Append(" WHERE 1=1 AND ((Stat is null) or (Stat=0)) and Template_ID=@Template_ID; "); string sql = sb.ToString(); if (audit_Template.Template_Code_IsChanged) { if (string.IsNullOrEmpty(audit_Template.Template_Code)) { idb.AddParameter("@Template_Code", DBNull.Value); } else { idb.AddParameter("@Template_Code", audit_Template.Template_Code); } } if (audit_Template.Template_Key_IsChanged) { if (string.IsNullOrEmpty(audit_Template.Template_Key)) { idb.AddParameter("@Template_Key", DBNull.Value); } else { idb.AddParameter("@Template_Key", audit_Template.Template_Key); } } if (audit_Template.Template_Name_IsChanged) { if (string.IsNullOrEmpty(audit_Template.Template_Name)) { idb.AddParameter("@Template_Name", DBNull.Value); } else { idb.AddParameter("@Template_Name", audit_Template.Template_Name); } } if (audit_Template.Template_Remark_IsChanged) { if (string.IsNullOrEmpty(audit_Template.Template_Remark)) { idb.AddParameter("@Template_Remark", DBNull.Value); } else { idb.AddParameter("@Template_Remark", audit_Template.Template_Remark); } } if (audit_Template.Stat_IsChanged) { if (audit_Template.Stat == 0) { idb.AddParameter("@Stat", 0); } else { idb.AddParameter("@Stat", audit_Template.Stat); } } if (audit_Template.Template_Table_IsChanged) { if (string.IsNullOrEmpty(audit_Template.Template_Table)) { idb.AddParameter("@Template_Table", DBNull.Value); } else { idb.AddParameter("@Template_Table", audit_Template.Template_Table); } } if (audit_Template.Template_Column_IsChanged) { if (string.IsNullOrEmpty(audit_Template.Template_Column)) { idb.AddParameter("@Template_Column", DBNull.Value); } else { idb.AddParameter("@Template_Column", audit_Template.Template_Column); } } if (audit_Template.Template_ColumnType_IsChanged) { if (string.IsNullOrEmpty(audit_Template.Template_ColumnType)) { idb.AddParameter("@Template_ColumnType", DBNull.Value); } else { idb.AddParameter("@Template_ColumnType", audit_Template.Template_ColumnType); } } if (audit_Template.Template_CheckSQL_IsChanged) { if (string.IsNullOrEmpty(audit_Template.Template_CheckSQL)) { idb.AddParameter("@Template_CheckSQL", DBNull.Value); } else { idb.AddParameter("@Template_CheckSQL", audit_Template.Template_CheckSQL); } } idb.AddParameter("@Template_ID", audit_Template.Template_ID); int Re = 0; //SQL日志记录 var RunMethod = System.Reflection.MethodBase.GetCurrentMethod(); System.Collections.Hashtable param = new System.Collections.Hashtable(); string Ex = "0"; foreach (System.Collections.DictionaryEntry item in idb.GetParameters()) { param.Add(item.Key, item.Value); } try { Re = idb.ExeCmd(sql); Ex = Re.ToString(); } catch (Exception ex) { Ex = ex.Message; } SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name, Ex); return(Re); }
/// <summary> /// 添加审核模板列表 Audit_Template对象(即:一条记录) /// </summary> public int Add(Audit_Template audit_Template) { string sql = "INSERT INTO Audit_Template (Template_Code,Template_Key,Template_Name,Template_Remark,Stat,Template_Table,Template_Column,Template_ColumnType,Template_CheckSQL) VALUES (@Template_Code,@Template_Key,@Template_Name,@Template_Remark,@Stat,@Template_Table,@Template_Column,@Template_ColumnType,@Template_CheckSQL)"; if (string.IsNullOrEmpty(audit_Template.Template_Code)) { idb.AddParameter("@Template_Code", DBNull.Value); } else { idb.AddParameter("@Template_Code", audit_Template.Template_Code); } if (string.IsNullOrEmpty(audit_Template.Template_Key)) { idb.AddParameter("@Template_Key", DBNull.Value); } else { idb.AddParameter("@Template_Key", audit_Template.Template_Key); } if (string.IsNullOrEmpty(audit_Template.Template_Name)) { idb.AddParameter("@Template_Name", DBNull.Value); } else { idb.AddParameter("@Template_Name", audit_Template.Template_Name); } if (string.IsNullOrEmpty(audit_Template.Template_Remark)) { idb.AddParameter("@Template_Remark", DBNull.Value); } else { idb.AddParameter("@Template_Remark", audit_Template.Template_Remark); } if (audit_Template.Stat == 0) { idb.AddParameter("@Stat", 0); } else { idb.AddParameter("@Stat", audit_Template.Stat); } if (string.IsNullOrEmpty(audit_Template.Template_Table)) { idb.AddParameter("@Template_Table", DBNull.Value); } else { idb.AddParameter("@Template_Table", audit_Template.Template_Table); } if (string.IsNullOrEmpty(audit_Template.Template_Column)) { idb.AddParameter("@Template_Column", DBNull.Value); } else { idb.AddParameter("@Template_Column", audit_Template.Template_Column); } if (string.IsNullOrEmpty(audit_Template.Template_ColumnType)) { idb.AddParameter("@Template_ColumnType", DBNull.Value); } else { idb.AddParameter("@Template_ColumnType", audit_Template.Template_ColumnType); } if (string.IsNullOrEmpty(audit_Template.Template_CheckSQL)) { idb.AddParameter("@Template_CheckSQL", DBNull.Value); } else { idb.AddParameter("@Template_CheckSQL", audit_Template.Template_CheckSQL); } int Re = 0; //SQL日志记录 var RunMethod = System.Reflection.MethodBase.GetCurrentMethod(); System.Collections.Hashtable param = new System.Collections.Hashtable(); string Ex = "0"; foreach (System.Collections.DictionaryEntry item in idb.GetParameters()) { param.Add(item.Key, item.Value); } try { Re = idb.ExeCmd(sql); Ex = Re.ToString(); } catch (Exception ex) { Ex = ex.Message; } SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name, Ex); return(Re); }