コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CADS.Model.SwitchManageInfoList model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.PreLeader != null)
            {
                strSql1.Append("PreLeader,");
                strSql2.Append("'" + model.PreLeader + "',");
            }
            if (model.PreName != null)
            {
                strSql1.Append("PreName,");
                strSql2.Append("'" + model.PreName + "',");
            }
            if (model.NextLeader != null)
            {
                strSql1.Append("NextLeader,");
                strSql2.Append("'" + model.NextLeader + "',");
            }
            if (model.NextName != null)
            {
                strSql1.Append("NextName,");
                strSql2.Append("'" + model.NextName + "',");
            }
            if (model.SwtichTime != null)
            {
                strSql1.Append("SwtichTime,");
                strSql2.Append("'" + model.SwtichTime + "',");
            }
            if (model.SwitchContent != null)
            {
                strSql1.Append("SwitchContent,");
                strSql2.Append("'" + model.SwitchContent + "',");
            }
            if (model.Mark != null)
            {
                strSql1.Append("Mark,");
                strSql2.Append("'" + model.Mark + "',");
            }
            strSql.Append("insert into SwitchManageInfoList(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperOleDb.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: Form_SwitchManage.cs プロジェクト: liuslayer/RCCP
                /// <summary>
        /// 数据操作
        /// </summary>
        /// <param name="Mess">区别编辑还是新增还是删除</param>
        private void OpreationDB(string Mess) 
        {
            CADS.Model.SwitchManageInfoList switchManageInfoList = new CADS.Model.SwitchManageInfoList();
            try
            {
                switchManageInfoList.PreLeader = this.tbx_PreLeader.Text.Trim();
                switchManageInfoList.PreName = this.tbx_NextName.Text.Trim();
                switchManageInfoList.NextLeader = this.tbx_NextLeader.Text.Trim();
                switchManageInfoList.NextName = this.tbx_NextName.Text.Trim();
                switchManageInfoList.SwtichTime = this.dtp_SwtichTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
                switchManageInfoList.SwitchContent = this.tbx_SwitchContent.Text.Trim();
                if (!string.IsNullOrEmpty(editMark))
                {
                    switchManageInfoList.ID = int.Parse(editMark);
                }
                bool Result = false;
                if (Mess == "添加")
                {
                    Result = switchManage.Add(switchManageInfoList);
                }
                if (Mess == "编辑")
                {
                    Result = switchManage.Update(switchManageInfoList);
                }
                if (Mess == "删除")
                {

                    Result = switchManage.Delete(switchManageInfoList.ID);
                }
                if (Result == true)
                {
                    MessageBox.Show("交接班信息" + Mess + "成功");
                    ClearText(this.Content);
                }
                else
                {
                    MessageBox.Show("交接班信息" + Mess + "失败,请稍后再试!");
                    ClearText(this.Content);
                }  
            }
            catch (Exception e)
            {
                
                throw e;
            }


        }
コード例 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CADS.Model.SwitchManageInfoList GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  ");
            strSql.Append(" ID,PreLeader,PreName,NextLeader,NextName,SwtichTime,SwitchContent,Mark ");
            strSql.Append(" from SwitchManageInfoList ");
            strSql.Append(" where ID=" + ID + "");
            CADS.Model.SwitchManageInfoList model = new CADS.Model.SwitchManageInfoList();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CADS.Model.SwitchManageInfoList DataRowToModel(DataRow row)
 {
     CADS.Model.SwitchManageInfoList model = new CADS.Model.SwitchManageInfoList();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["PreLeader"] != null)
         {
             model.PreLeader = row["PreLeader"].ToString();
         }
         if (row["PreName"] != null)
         {
             model.PreName = row["PreName"].ToString();
         }
         if (row["NextLeader"] != null)
         {
             model.NextLeader = row["NextLeader"].ToString();
         }
         if (row["NextName"] != null)
         {
             model.NextName = row["NextName"].ToString();
         }
         if (row["SwtichTime"] != null)
         {
             model.SwtichTime = row["SwtichTime"].ToString();
         }
         if (row["SwitchContent"] != null)
         {
             model.SwitchContent = row["SwitchContent"].ToString();
         }
         if (row["Mark"] != null)
         {
             model.Mark = row["Mark"].ToString();
         }
     }
     return(model);
 }
コード例 #5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CADS.Model.SwitchManageInfoList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SwitchManageInfoList set ");
            if (model.PreLeader != null)
            {
                strSql.Append("PreLeader='" + model.PreLeader + "',");
            }
            else
            {
                strSql.Append("PreLeader= null ,");
            }
            if (model.PreName != null)
            {
                strSql.Append("PreName='" + model.PreName + "',");
            }
            else
            {
                strSql.Append("PreName= null ,");
            }
            if (model.NextLeader != null)
            {
                strSql.Append("NextLeader='" + model.NextLeader + "',");
            }
            else
            {
                strSql.Append("NextLeader= null ,");
            }
            if (model.NextName != null)
            {
                strSql.Append("NextName='" + model.NextName + "',");
            }
            else
            {
                strSql.Append("NextName= null ,");
            }
            if (model.SwtichTime != null)
            {
                strSql.Append("SwtichTime='" + model.SwtichTime + "',");
            }
            else
            {
                strSql.Append("SwtichTime= null ,");
            }
            if (model.SwitchContent != null)
            {
                strSql.Append("SwitchContent='" + model.SwitchContent + "',");
            }
            else
            {
                strSql.Append("SwitchContent= null ,");
            }
            if (model.Mark != null)
            {
                strSql.Append("Mark='" + model.Mark + "',");
            }
            else
            {
                strSql.Append("Mark= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where ID=" + model.ID + "");
            int rowsAffected = DbHelperOleDb.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }