コード例 #1
0
ファイル: Bll_Comp.cs プロジェクト: youthjoy/cshelper
 /// <summary>
 /// 零件图号添加
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int AddComp(Tpl_Components model)
 {
     model.CreateTime = DateTime.Now;
     model.UpdateTime = DateTime.Now;
     var re = tcInstance.AddWithReturn(model);
     return TypeConverter.ObjectToInt(re);
 }
コード例 #2
0
ファイル: CompOp.cs プロジェクト: youthjoy/cshelper
        public CompOp(Tpl_Components item, OperationTypeEnum op)
        {
            InitializeComponent();
            opType = op;

            GModel = item;

            this.Load += new EventHandler(Form_Load);
            this.FormClosed += new FormClosedEventHandler(CompOp_FormClosed);
            BindTopTool();
        }
コード例 #3
0
ファイル: Bll_Comp.cs プロジェクト: youthjoy/cshelper
        /// <summary>
        /// 图号模板相关文档更新
        /// </summary>
        /// <param name="main"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public bool AddOrUpdateCDoc(Tpl_Components main, List<Tpl_ReqDoc> list)
        {
            bool flag = true;

            List<Tpl_ReqDoc> oldSIList = GetReqDocByComp(main.TPLC_Code);

            try
            {
                foreach (Tpl_ReqDoc r in oldSIList)
                {
                    var temp = list.FirstOrDefault(o => o.TPRD_ID == r.TPRD_ID);
                    //如果存在则更新
                    if (temp != null)
                    {
                        temp.CreateTime = DateTime.Now;
                        temp.UpdateTime = DateTime.Now;
                        temp.TPRD_ID = r.TPRD_ID;
                        ReqDocUpdate(temp);
                        list.Remove(temp);

                    }//不存在则删除
                    else
                    {
                        r.DeleteTime = DateTime.Now;
                        ReqDocDelete(r);
                    }
                }

                foreach (Tpl_ReqDoc detail in list)
                {
                    //如果有编码生成,则在此处完成

                    detail.CreateTime = DateTime.Now;
                    detail.UpdateTime = DateTime.Now;
                    detail.TPRD_Code = GenerateDocCode();
                    detail.TPRD_CompCode = main.TPLC_Code;
                    ReqDocInsert(detail);
                }
            }
            catch
            {
                flag = false;
            }
            return flag;
        }
コード例 #4
0
        /// <summary>
        /// 更新Tpl_Components对象(即:一条记录
        /// </summary>
        public int Update(Tpl_Components tpl_Components)
        {
            StringBuilder sbParameter=new StringBuilder();
              StringBuilder sb=new StringBuilder();
              sb.Append(@"UPDATE       Tpl_Components       SET ");
            if(tpl_Components.TPLC_Code_IsChanged){sbParameter.Append("TPLC_Code=@TPLC_Code, ");}
              if(tpl_Components.TPLC_Name_IsChanged){sbParameter.Append("TPLC_Name=@TPLC_Name, ");}
              if(tpl_Components.TPLC_Cat_IsChanged){sbParameter.Append("TPLC_Cat=@TPLC_Cat, ");}
              if(tpl_Components.TPLC_Tec_IsChanged){sbParameter.Append("TPLC_Tec=@TPLC_Tec, ");}
              if(tpl_Components.TPLC_Raw_IsChanged){sbParameter.Append("TPLC_Raw=@TPLC_Raw, ");}
              if(tpl_Components.TPLC_Plant_IsChanged){sbParameter.Append("TPLC_Plant=@TPLC_Plant, ");}
              if(tpl_Components.TPLC_iType_IsChanged){sbParameter.Append("TPLC_iType=@TPLC_iType, ");}
              if(tpl_Components.Stat_IsChanged){sbParameter.Append("Stat=@Stat, ");}
              if(tpl_Components.Creator_IsChanged){sbParameter.Append("Creator=@Creator, ");}
              if(tpl_Components.CreateTime_IsChanged){sbParameter.Append("CreateTime=@CreateTime, ");}
              if(tpl_Components.UpdateTime_IsChanged){sbParameter.Append("UpdateTime=@UpdateTime, ");}
              if(tpl_Components.DeleteTime_IsChanged){sbParameter.Append("DeleteTime=@DeleteTime ");}
          sb.Append(sbParameter.ToString().Trim().TrimEnd(','));
              sb.Append(      " WHERE 1=1 AND ((Stat is null) or (Stat=0))   and TPLC_ID=@TPLC_ID; " );
              string sql=sb.ToString();
             if(tpl_Components.TPLC_Code_IsChanged)
             {
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Code))
             {
            idb.AddParameter("@TPLC_Code", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Code", tpl_Components.TPLC_Code);
             }
              }
             if(tpl_Components.TPLC_Name_IsChanged)
             {
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Name))
             {
            idb.AddParameter("@TPLC_Name", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Name", tpl_Components.TPLC_Name);
             }
              }
             if(tpl_Components.TPLC_Cat_IsChanged)
             {
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Cat))
             {
            idb.AddParameter("@TPLC_Cat", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Cat", tpl_Components.TPLC_Cat);
             }
              }
             if(tpl_Components.TPLC_Tec_IsChanged)
             {
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Tec))
             {
            idb.AddParameter("@TPLC_Tec", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Tec", tpl_Components.TPLC_Tec);
             }
              }
             if(tpl_Components.TPLC_Raw_IsChanged)
             {
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Raw))
             {
            idb.AddParameter("@TPLC_Raw", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Raw", tpl_Components.TPLC_Raw);
             }
              }
             if(tpl_Components.TPLC_Plant_IsChanged)
             {
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Plant))
             {
            idb.AddParameter("@TPLC_Plant", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Plant", tpl_Components.TPLC_Plant);
             }
              }
             if(tpl_Components.TPLC_iType_IsChanged)
             {
             if (string.IsNullOrEmpty(tpl_Components.TPLC_iType))
             {
            idb.AddParameter("@TPLC_iType", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_iType", tpl_Components.TPLC_iType);
             }
              }
             if(tpl_Components.Stat_IsChanged)
             {
             if (tpl_Components.Stat == 0)
             {
            idb.AddParameter("@Stat", 0);
             }
             else
             {
            idb.AddParameter("@Stat", tpl_Components.Stat);
             }
              }
             if(tpl_Components.Creator_IsChanged)
             {
             if (string.IsNullOrEmpty(tpl_Components.Creator))
             {
            idb.AddParameter("@Creator", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@Creator", tpl_Components.Creator);
             }
              }
             if(tpl_Components.CreateTime_IsChanged)
             {
             if (tpl_Components.CreateTime == DateTime.MinValue)
             {
            idb.AddParameter("@CreateTime", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@CreateTime", tpl_Components.CreateTime);
             }
              }
             if(tpl_Components.UpdateTime_IsChanged)
             {
             if (tpl_Components.UpdateTime == DateTime.MinValue)
             {
            idb.AddParameter("@UpdateTime", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@UpdateTime", tpl_Components.UpdateTime);
             }
              }
             if(tpl_Components.DeleteTime_IsChanged)
             {
             if (tpl_Components.DeleteTime == DateTime.MinValue)
             {
            idb.AddParameter("@DeleteTime", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@DeleteTime", tpl_Components.DeleteTime);
             }
              }

             idb.AddParameter("@TPLC_ID", tpl_Components.TPLC_ID);

            int Re = 0;
            //SQL日志记录
            var RunMethod = System.Reflection.MethodBase.GetCurrentMethod();
            System.Collections.Hashtable param = new System.Collections.Hashtable();
            string Ex = string.Empty;
            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;
            }
            finally
            {
                SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType +"." + RunMethod.Name,Ex);
            }            return Re;
コード例 #5
0
 /// <summary>
 /// 获取指定的Tpl_Components对象集合
 /// </summary>
 public List<Tpl_Components> GetListByWhere(string strCondition)
 {
     List<Tpl_Components> ret = new List<Tpl_Components>();
      string sql = "SELECT  TPLC_ID,TPLC_Code,TPLC_Name,TPLC_Cat,TPLC_Tec,TPLC_Raw,TPLC_Plant,TPLC_iType,Stat,Creator,CreateTime,UpdateTime,DeleteTime FROM Tpl_Components 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())
      {
     Tpl_Components tpl_Components = new Tpl_Components();
     if (dr["TPLC_ID"] != DBNull.Value) tpl_Components.TPLC_ID = Convert.ToDecimal(dr["TPLC_ID"]);
     if (dr["TPLC_Code"] != DBNull.Value) tpl_Components.TPLC_Code = Convert.ToString(dr["TPLC_Code"]);
     if (dr["TPLC_Name"] != DBNull.Value) tpl_Components.TPLC_Name = Convert.ToString(dr["TPLC_Name"]);
     if (dr["TPLC_Cat"] != DBNull.Value) tpl_Components.TPLC_Cat = Convert.ToString(dr["TPLC_Cat"]);
     if (dr["TPLC_Tec"] != DBNull.Value) tpl_Components.TPLC_Tec = Convert.ToString(dr["TPLC_Tec"]);
     if (dr["TPLC_Raw"] != DBNull.Value) tpl_Components.TPLC_Raw = Convert.ToString(dr["TPLC_Raw"]);
     if (dr["TPLC_Plant"] != DBNull.Value) tpl_Components.TPLC_Plant = Convert.ToString(dr["TPLC_Plant"]);
     if (dr["TPLC_iType"] != DBNull.Value) tpl_Components.TPLC_iType = Convert.ToString(dr["TPLC_iType"]);
     if (dr["Stat"] != DBNull.Value) tpl_Components.Stat = Convert.ToInt32(dr["Stat"]);
     if (dr["Creator"] != DBNull.Value) tpl_Components.Creator = Convert.ToString(dr["Creator"]);
     if (dr["CreateTime"] != DBNull.Value) tpl_Components.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
     if (dr["UpdateTime"] != DBNull.Value) tpl_Components.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]);
     if (dr["DeleteTime"] != DBNull.Value) tpl_Components.DeleteTime = Convert.ToDateTime(dr["DeleteTime"]);
     ret.Add(tpl_Components);
      }
       }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;
 }
コード例 #6
0
        /// <summary>
        /// 获取指定的Tpl_Components对象(即:一条记录
        /// </summary>
        public Tpl_Components GetByKey(decimal tPLC_ID)
        {
            Tpl_Components tpl_Components = new Tpl_Components();
             string sql = "SELECT  TPLC_ID,TPLC_Code,TPLC_Name,TPLC_Cat,TPLC_Tec,TPLC_Raw,TPLC_Plant,TPLC_iType,Stat,Creator,CreateTime,UpdateTime,DeleteTime FROM Tpl_Components WHERE 1=1 AND ((Stat is null) or (Stat=0) )  AND TPLC_ID=@TPLC_ID ";
             idb.AddParameter("@TPLC_ID", tPLC_ID);

              SqlDataReader dr=null;
               try {
              dr=(SqlDataReader)idb.ReturnReader(sql);
             while(dr.Read())
             {
            if (dr["TPLC_ID"] != DBNull.Value) tpl_Components.TPLC_ID = Convert.ToDecimal(dr["TPLC_ID"]);
            if (dr["TPLC_Code"] != DBNull.Value) tpl_Components.TPLC_Code = Convert.ToString(dr["TPLC_Code"]);
            if (dr["TPLC_Name"] != DBNull.Value) tpl_Components.TPLC_Name = Convert.ToString(dr["TPLC_Name"]);
            if (dr["TPLC_Cat"] != DBNull.Value) tpl_Components.TPLC_Cat = Convert.ToString(dr["TPLC_Cat"]);
            if (dr["TPLC_Tec"] != DBNull.Value) tpl_Components.TPLC_Tec = Convert.ToString(dr["TPLC_Tec"]);
            if (dr["TPLC_Raw"] != DBNull.Value) tpl_Components.TPLC_Raw = Convert.ToString(dr["TPLC_Raw"]);
            if (dr["TPLC_Plant"] != DBNull.Value) tpl_Components.TPLC_Plant = Convert.ToString(dr["TPLC_Plant"]);
            if (dr["TPLC_iType"] != DBNull.Value) tpl_Components.TPLC_iType = Convert.ToString(dr["TPLC_iType"]);
            if (dr["Stat"] != DBNull.Value) tpl_Components.Stat = Convert.ToInt32(dr["Stat"]);
            if (dr["Creator"] != DBNull.Value) tpl_Components.Creator = Convert.ToString(dr["Creator"]);
            if (dr["CreateTime"] != DBNull.Value) tpl_Components.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
            if (dr["UpdateTime"] != DBNull.Value) tpl_Components.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]);
            if (dr["DeleteTime"] != DBNull.Value) tpl_Components.DeleteTime = Convert.ToDateTime(dr["DeleteTime"]);
             }
              }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 tpl_Components;
        }
コード例 #7
0
        /// <summary>
        /// 添加Tpl_Components对象(即:一条记录)
        /// </summary>
        public int Add(Tpl_Components tpl_Components)
        {
            string sql = "INSERT INTO Tpl_Components (TPLC_Code,TPLC_Name,TPLC_Cat,TPLC_Tec,TPLC_Raw,TPLC_Plant,TPLC_iType,Stat,Creator,CreateTime,UpdateTime,DeleteTime) VALUES (@TPLC_Code,@TPLC_Name,@TPLC_Cat,@TPLC_Tec,@TPLC_Raw,@TPLC_Plant,@TPLC_iType,@Stat,@Creator,@CreateTime,@UpdateTime,@DeleteTime)";
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Code))
             {
            idb.AddParameter("@TPLC_Code", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Code", tpl_Components.TPLC_Code);
             }
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Name))
             {
            idb.AddParameter("@TPLC_Name", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Name", tpl_Components.TPLC_Name);
             }
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Cat))
             {
            idb.AddParameter("@TPLC_Cat", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Cat", tpl_Components.TPLC_Cat);
             }
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Tec))
             {
            idb.AddParameter("@TPLC_Tec", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Tec", tpl_Components.TPLC_Tec);
             }
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Raw))
             {
            idb.AddParameter("@TPLC_Raw", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Raw", tpl_Components.TPLC_Raw);
             }
             if (string.IsNullOrEmpty(tpl_Components.TPLC_Plant))
             {
            idb.AddParameter("@TPLC_Plant", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_Plant", tpl_Components.TPLC_Plant);
             }
             if (string.IsNullOrEmpty(tpl_Components.TPLC_iType))
             {
            idb.AddParameter("@TPLC_iType", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@TPLC_iType", tpl_Components.TPLC_iType);
             }
             if (tpl_Components.Stat == 0)
             {
            idb.AddParameter("@Stat", 0);
             }
             else
             {
            idb.AddParameter("@Stat", tpl_Components.Stat);
             }
             if (string.IsNullOrEmpty(tpl_Components.Creator))
             {
            idb.AddParameter("@Creator", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@Creator", tpl_Components.Creator);
             }
             if (tpl_Components.CreateTime == DateTime.MinValue)
             {
            idb.AddParameter("@CreateTime", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@CreateTime", tpl_Components.CreateTime);
             }
             if (tpl_Components.UpdateTime == DateTime.MinValue)
             {
            idb.AddParameter("@UpdateTime", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@UpdateTime", tpl_Components.UpdateTime);
             }
             if (tpl_Components.DeleteTime == DateTime.MinValue)
             {
            idb.AddParameter("@DeleteTime", DBNull.Value);
             }
             else
             {
            idb.AddParameter("@DeleteTime", tpl_Components.DeleteTime);
             }

            int Re = 0;
            //SQL日志记录
            var RunMethod = System.Reflection.MethodBase.GetCurrentMethod();
            System.Collections.Hashtable param = new System.Collections.Hashtable();
            string Ex = string.Empty;
            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;
            }
            finally
            {
                SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType +"." + RunMethod.Name,Ex);
             }            return Re;
        }
コード例 #8
0
ファイル: Bll_Comp.cs プロジェクト: youthjoy/cshelper
 /// <summary>
 /// 零件图号模板更新
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool UpdateComp(Tpl_Components model)
 {
     return CompUpdate(model);
 }
コード例 #9
0
ファイル: Bll_Comp.cs プロジェクト: youthjoy/cshelper
        public bool CompUpdate(Tpl_Components model)
        {
            model.UpdateTime = DateTime.Now;

            if (tcInstance.Update(model) > 0)
            {
                return true;
            }

            return false;
        }
コード例 #10
0
ファイル: Bll_Comp.cs プロジェクト: youthjoy/cshelper
        public bool CompInsert(Tpl_Components model)
        {
            model.CreateTime = DateTime.Now;

            model.UpdateTime = DateTime.Now;

            if (tcInstance.Add(model) > 0)
            {
                return true;
            }

            return false;
        }