Example #1
0
        /// <summary>
        /// 更新车辆调度表 PCT_Schedule对象(即:一条记录
        /// </summary>
        public int Update(PCT_Schedule pCT_Schedule)
        {
            StringBuilder sbParameter = new StringBuilder();
            StringBuilder sb          = new StringBuilder();

            sb.Append(@"UPDATE       PCT_Schedule       SET ");
            if (pCT_Schedule.PCTS_Code_IsChanged)
            {
                sbParameter.Append("PCTS_Code=@PCTS_Code, ");
            }
            if (pCT_Schedule.PCTS_ICode_IsChanged)
            {
                sbParameter.Append("PCTS_ICode=@PCTS_ICode, ");
            }
            if (pCT_Schedule.PCTS_NO_IsChanged)
            {
                sbParameter.Append("PCTS_NO=@PCTS_NO, ");
            }
            if (pCT_Schedule.PCTS_INO_IsChanged)
            {
                sbParameter.Append("PCTS_INO=@PCTS_INO, ");
            }
            if (pCT_Schedule.PCTS_Driver_IsChanged)
            {
                sbParameter.Append("PCTS_Driver=@PCTS_Driver, ");
            }
            if (pCT_Schedule.PCTS_Aim_IsChanged)
            {
                sbParameter.Append("PCTS_Aim=@PCTS_Aim, ");
            }
            if (pCT_Schedule.PCTS_AType_IsChanged)
            {
                sbParameter.Append("PCTS_AType=@PCTS_AType, ");
            }
            if (pCT_Schedule.PCTS_SType_IsChanged)
            {
                sbParameter.Append("PCTS_SType=@PCTS_SType, ");
            }
            if (pCT_Schedule.PCTS_Date_IsChanged)
            {
                sbParameter.Append("PCTS_Date=@PCTS_Date, ");
            }
            if (pCT_Schedule.PCTS_Emp_IsChanged)
            {
                sbParameter.Append("PCTS_Emp=@PCTS_Emp, ");
            }
            if (pCT_Schedule.PCTS_ADate_IsChanged)
            {
                sbParameter.Append("PCTS_ADate=@PCTS_ADate, ");
            }
            if (pCT_Schedule.Stat_IsChanged)
            {
                sbParameter.Append("Stat=@Stat, ");
            }
            if (pCT_Schedule.PCTS_Stat_IsChanged)
            {
                sbParameter.Append("PCTS_Stat=@PCTS_Stat, ");
            }
            if (pCT_Schedule.PCTS_TankerStat_IsChanged)
            {
                sbParameter.Append("PCTS_TankerStat=@PCTS_TankerStat, ");
            }
            if (pCT_Schedule.PCTS_Udef1_IsChanged)
            {
                sbParameter.Append("PCTS_Udef1=@PCTS_Udef1, ");
            }
            if (pCT_Schedule.PCTS_Udef2_IsChanged)
            {
                sbParameter.Append("PCTS_Udef2=@PCTS_Udef2, ");
            }
            if (pCT_Schedule.PCTS_Udef3_IsChanged)
            {
                sbParameter.Append("PCTS_Udef3=@PCTS_Udef3, ");
            }
            if (pCT_Schedule.PCTS_Udef4_IsChanged)
            {
                sbParameter.Append("PCTS_Udef4=@PCTS_Udef4, ");
            }
            if (pCT_Schedule.PCTS_Udef5_IsChanged)
            {
                sbParameter.Append("PCTS_Udef5=@PCTS_Udef5 ");
            }
            sb.Append(sbParameter.ToString().Trim().TrimEnd(','));
            sb.Append(" WHERE 1=1 AND ((Stat is null) or (Stat=0))   and PCTS_ID=@PCTS_ID; ");
            string sql = sb.ToString();

            if (pCT_Schedule.PCTS_Code_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Code))
                {
                    idb.AddParameter("@PCTS_Code", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Code", pCT_Schedule.PCTS_Code);
                }
            }
            if (pCT_Schedule.PCTS_ICode_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_ICode))
                {
                    idb.AddParameter("@PCTS_ICode", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_ICode", pCT_Schedule.PCTS_ICode);
                }
            }
            if (pCT_Schedule.PCTS_NO_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_NO))
                {
                    idb.AddParameter("@PCTS_NO", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_NO", pCT_Schedule.PCTS_NO);
                }
            }
            if (pCT_Schedule.PCTS_INO_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_INO))
                {
                    idb.AddParameter("@PCTS_INO", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_INO", pCT_Schedule.PCTS_INO);
                }
            }
            if (pCT_Schedule.PCTS_Driver_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Driver))
                {
                    idb.AddParameter("@PCTS_Driver", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Driver", pCT_Schedule.PCTS_Driver);
                }
            }
            if (pCT_Schedule.PCTS_Aim_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Aim))
                {
                    idb.AddParameter("@PCTS_Aim", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Aim", pCT_Schedule.PCTS_Aim);
                }
            }
            if (pCT_Schedule.PCTS_AType_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_AType))
                {
                    idb.AddParameter("@PCTS_AType", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_AType", pCT_Schedule.PCTS_AType);
                }
            }
            if (pCT_Schedule.PCTS_SType_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_SType))
                {
                    idb.AddParameter("@PCTS_SType", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_SType", pCT_Schedule.PCTS_SType);
                }
            }
            if (pCT_Schedule.PCTS_Date_IsChanged)
            {
                if (pCT_Schedule.PCTS_Date == DateTime.MinValue)
                {
                    idb.AddParameter("@PCTS_Date", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Date", pCT_Schedule.PCTS_Date);
                }
            }
            if (pCT_Schedule.PCTS_Emp_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Emp))
                {
                    idb.AddParameter("@PCTS_Emp", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Emp", pCT_Schedule.PCTS_Emp);
                }
            }
            if (pCT_Schedule.PCTS_ADate_IsChanged)
            {
                if (pCT_Schedule.PCTS_ADate == DateTime.MinValue)
                {
                    idb.AddParameter("@PCTS_ADate", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_ADate", pCT_Schedule.PCTS_ADate);
                }
            }
            if (pCT_Schedule.Stat_IsChanged)
            {
                if (pCT_Schedule.Stat == 0)
                {
                    idb.AddParameter("@Stat", 0);
                }
                else
                {
                    idb.AddParameter("@Stat", pCT_Schedule.Stat);
                }
            }
            if (pCT_Schedule.PCTS_Stat_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Stat))
                {
                    idb.AddParameter("@PCTS_Stat", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Stat", pCT_Schedule.PCTS_Stat);
                }
            }
            if (pCT_Schedule.PCTS_TankerStat_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_TankerStat))
                {
                    idb.AddParameter("@PCTS_TankerStat", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_TankerStat", pCT_Schedule.PCTS_TankerStat);
                }
            }
            if (pCT_Schedule.PCTS_Udef1_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Udef1))
                {
                    idb.AddParameter("@PCTS_Udef1", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Udef1", pCT_Schedule.PCTS_Udef1);
                }
            }
            if (pCT_Schedule.PCTS_Udef2_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Udef2))
                {
                    idb.AddParameter("@PCTS_Udef2", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Udef2", pCT_Schedule.PCTS_Udef2);
                }
            }
            if (pCT_Schedule.PCTS_Udef3_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Udef3))
                {
                    idb.AddParameter("@PCTS_Udef3", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Udef3", pCT_Schedule.PCTS_Udef3);
                }
            }
            if (pCT_Schedule.PCTS_Udef4_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Udef4))
                {
                    idb.AddParameter("@PCTS_Udef4", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Udef4", pCT_Schedule.PCTS_Udef4);
                }
            }
            if (pCT_Schedule.PCTS_Udef5_IsChanged)
            {
                if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Udef5))
                {
                    idb.AddParameter("@PCTS_Udef5", DBNull.Value);
                }
                else
                {
                    idb.AddParameter("@PCTS_Udef5", pCT_Schedule.PCTS_Udef5);
                }
            }

            idb.AddParameter("@PCTS_ID", pCT_Schedule.PCTS_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);
        }
Example #2
0
        /// <summary>
        /// 添加车辆调度表 PCT_Schedule对象(即:一条记录)
        /// </summary>
        public object AddWithReturn(PCT_Schedule pCT_Schedule)
        {
            string sql = "INSERT INTO PCT_Schedule (PCTS_Code,PCTS_ICode,PCTS_NO,PCTS_INO,PCTS_Driver,PCTS_Aim,PCTS_AType,PCTS_SType,PCTS_Date,PCTS_Emp,PCTS_ADate,Stat,PCTS_Stat,PCTS_TankerStat,PCTS_Udef1,PCTS_Udef2,PCTS_Udef3,PCTS_Udef4,PCTS_Udef5) VALUES (@PCTS_Code,@PCTS_ICode,@PCTS_NO,@PCTS_INO,@PCTS_Driver,@PCTS_Aim,@PCTS_AType,@PCTS_SType,@PCTS_Date,@PCTS_Emp,@PCTS_ADate,@Stat,@PCTS_Stat,@PCTS_TankerStat,@PCTS_Udef1,@PCTS_Udef2,@PCTS_Udef3,@PCTS_Udef4,@PCTS_Udef5);SELECT @@IDENTITY AS ReturnID;";

            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Code))
            {
                idb.AddParameter("@PCTS_Code", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Code", pCT_Schedule.PCTS_Code);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_ICode))
            {
                idb.AddParameter("@PCTS_ICode", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_ICode", pCT_Schedule.PCTS_ICode);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_NO))
            {
                idb.AddParameter("@PCTS_NO", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_NO", pCT_Schedule.PCTS_NO);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_INO))
            {
                idb.AddParameter("@PCTS_INO", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_INO", pCT_Schedule.PCTS_INO);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Driver))
            {
                idb.AddParameter("@PCTS_Driver", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Driver", pCT_Schedule.PCTS_Driver);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Aim))
            {
                idb.AddParameter("@PCTS_Aim", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Aim", pCT_Schedule.PCTS_Aim);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_AType))
            {
                idb.AddParameter("@PCTS_AType", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_AType", pCT_Schedule.PCTS_AType);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_SType))
            {
                idb.AddParameter("@PCTS_SType", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_SType", pCT_Schedule.PCTS_SType);
            }
            if (pCT_Schedule.PCTS_Date == DateTime.MinValue)
            {
                idb.AddParameter("@PCTS_Date", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Date", pCT_Schedule.PCTS_Date);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Emp))
            {
                idb.AddParameter("@PCTS_Emp", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Emp", pCT_Schedule.PCTS_Emp);
            }
            if (pCT_Schedule.PCTS_ADate == DateTime.MinValue)
            {
                idb.AddParameter("@PCTS_ADate", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_ADate", pCT_Schedule.PCTS_ADate);
            }
            if (pCT_Schedule.Stat == 0)
            {
                idb.AddParameter("@Stat", 0);
            }
            else
            {
                idb.AddParameter("@Stat", pCT_Schedule.Stat);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Stat))
            {
                idb.AddParameter("@PCTS_Stat", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Stat", pCT_Schedule.PCTS_Stat);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_TankerStat))
            {
                idb.AddParameter("@PCTS_TankerStat", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_TankerStat", pCT_Schedule.PCTS_TankerStat);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Udef1))
            {
                idb.AddParameter("@PCTS_Udef1", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Udef1", pCT_Schedule.PCTS_Udef1);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Udef2))
            {
                idb.AddParameter("@PCTS_Udef2", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Udef2", pCT_Schedule.PCTS_Udef2);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Udef3))
            {
                idb.AddParameter("@PCTS_Udef3", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Udef3", pCT_Schedule.PCTS_Udef3);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Udef4))
            {
                idb.AddParameter("@PCTS_Udef4", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Udef4", pCT_Schedule.PCTS_Udef4);
            }
            if (string.IsNullOrEmpty(pCT_Schedule.PCTS_Udef5))
            {
                idb.AddParameter("@PCTS_Udef5", DBNull.Value);
            }
            else
            {
                idb.AddParameter("@PCTS_Udef5", pCT_Schedule.PCTS_Udef5);
            }


            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
            {
                var Return = idb.ReturnValue(sql);
                Ex = Return.ToString();
            }
            catch (Exception ex)
            {
                Ex = ex.Message;
            }

            SysRunLog.InsertRunSql(sql, param, RunMethod.DeclaringType + "." + RunMethod.Name, Ex);

            return(Re);
        }