Example #1
0
 /// <summary>
 /// 数据操作
 /// </summary>
 /// <param name="Mess">区别编辑还是新增还是删除</param>
 private bool OpreationDB(string Mess, CADS.Model.MessManageInfoList MessManageInfo)
 {
     try
     {
         string Error  = "";
         bool   Result = false;
         if (Mess == "添加")
         {
             Result = MessManage.Add(MessManageInfo);
         }
         if (Mess == "编辑")
         {
             Result = MessManage.Update(MessManageInfo);
         }
         if (Mess == "删除")
         {
             Result = MessManage.Delete(MessManageInfo.MessID);
         }
         if (Result == true)
         {
             MessageBox.Show("文电信息" + Mess + "成功");
             return(true);
         }
         else
         {
             MessageBox.Show("文电信息" + Mess + "失败,请稍后再试!");
             return(false);
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("文电信息" + Mess + "失败:" + e.Message);
         return(false);
     }
 }
Example #2
0
        private void btn_Edit_Click(object sender, EventArgs e)
        {
            if (DataView.SelectedRows.Count < 1)
            {
                MessageBox.Show("请选中一行数据!");
                return;
            }
            CADS.Model.MessManageInfoList MessManageInfo = new CADS.Model.MessManageInfoList();
            MessManageInfo.ID          = Convert.ToInt32(DataView.CurrentRow.Cells[0].Value);
            MessManageInfo.MessID      = DataView.CurrentRow.Cells[1].Value.ToString();
            MessManageInfo.Receiver    = DataView.CurrentRow.Cells[2].Value.ToString();
            MessManageInfo.ReceiveOrg  = DataView.CurrentRow.Cells[3].Value.ToString();
            MessManageInfo.MessType    = DataView.CurrentRow.Cells[4].Value.ToString();
            MessManageInfo.IsHandle    = DataView.CurrentRow.Cells[5].Value.ToString();
            MessManageInfo.MessTitle   = DataView.CurrentRow.Cells[6].Value.ToString();
            MessManageInfo.MessContent = DataView.CurrentRow.Cells[7].Value.ToString();
            MessManageInfo.Attachment  = DataView.CurrentRow.Cells[8].Value.ToString();
            Form_MsSearchAdd addOrEdit = new Form_MsSearchAdd("edit", MessManageInfo);

            addOrEdit.ShowDialog();
            if (addOrEdit.DialogResult == DialogResult.OK)
            {
                OpreationDB("编辑", addOrEdit.MessManageInfo);
                RefreshDataGridView();
            }
        }
Example #3
0
 public Form_MsSearchAdd(string operType, CADS.Model.MessManageInfoList MessManageInfo)
 {
     InitializeComponent();
     this.operType = operType;
     if (operType == "add")
     {
         Title_Label.Text = "文电管理添加";
     }
     else
     {
         Title_Label.Text    = "文电管理修改";
         this.MessManageInfo = MessManageInfo;
     }
 }
Example #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CADS.Model.MessManageInfoList DataRowToModel(DataRow row)
 {
     CADS.Model.MessManageInfoList model = new CADS.Model.MessManageInfoList();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["MessID"] != null)
         {
             model.MessID = row["MessID"].ToString();
         }
         if (row["Receiver"] != null)
         {
             model.Receiver = row["Receiver"].ToString();
         }
         if (row["ReceiveOrg"] != null)
         {
             model.ReceiveOrg = row["ReceiveOrg"].ToString();
         }
         if (row["MessType"] != null)
         {
             model.MessType = row["MessType"].ToString();
         }
         if (row["IsHandle"] != null)
         {
             model.IsHandle = row["IsHandle"].ToString();
         }
         if (row["MessTitle"] != null)
         {
             model.MessTitle = row["MessTitle"].ToString();
         }
         if (row["MessContent"] != null)
         {
             model.MessContent = row["MessContent"].ToString();
         }
         if (row["Attachment"] != null)
         {
             model.Attachment = row["Attachment"].ToString();
         }
         if (row["mark"] != null)
         {
             model.mark = row["mark"].ToString();
         }
     }
     return(model);
 }
Example #5
0
 private void btn_Delete_Click(object sender, EventArgs e)
 {
     if (DataView.SelectedRows.Count < 1)
     {
         MessageBox.Show("请选中一行数据!");
         return;
     }
     if (MessageBox.Show("确定要删除该行数据?", null, MessageBoxButtons.YesNo) != DialogResult.Yes)
     {
         return;
     }
     CADS.Model.MessManageInfoList MessManageInfo = new CADS.Model.MessManageInfoList();
     MessManageInfo.MessID = DataView.CurrentRow.Cells[1].Value.ToString();
     OpreationDB("删除", MessManageInfo);
     RefreshDataGridView();
 }
Example #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CADS.Model.MessManageInfoList GetModel(string MessID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  ");
            strSql.Append(" ID,MessID,Receiver,ReceiveOrg,MessType,IsHandle,MessTitle,MessContent,Attachment,mark ");
            strSql.Append(" from MessManageInfoList ");
            strSql.Append(" where MessID='" + MessID + "' ");
            CADS.Model.MessManageInfoList model = new CADS.Model.MessManageInfoList();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #7
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CADS.Model.MessManageInfoList model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.MessID != null)
            {
                strSql1.Append("MessID,");
                strSql2.Append("'" + model.MessID + "',");
            }
            if (model.Receiver != null)
            {
                strSql1.Append("Receiver,");
                strSql2.Append("'" + model.Receiver + "',");
            }
            if (model.ReceiveOrg != null)
            {
                strSql1.Append("ReceiveOrg,");
                strSql2.Append("'" + model.ReceiveOrg + "',");
            }
            if (model.MessType != null)
            {
                strSql1.Append("MessType,");
                strSql2.Append("'" + model.MessType + "',");
            }
            if (model.IsHandle != null)
            {
                strSql1.Append("IsHandle,");
                strSql2.Append("'" + model.IsHandle + "',");
            }
            if (model.MessTitle != null)
            {
                strSql1.Append("MessTitle,");
                strSql2.Append("'" + model.MessTitle + "',");
            }
            if (model.MessContent != null)
            {
                strSql1.Append("MessContent,");
                strSql2.Append("'" + model.MessContent + "',");
            }
            if (model.Attachment != null)
            {
                strSql1.Append("Attachment,");
                strSql2.Append("'" + model.Attachment + "',");
            }
            if (model.mark != null)
            {
                strSql1.Append("mark,");
                strSql2.Append("'" + model.mark + "',");
            }
            strSql.Append("insert into MessManageInfoList(");
            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);
            }
        }
Example #8
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CADS.Model.MessManageInfoList model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update MessManageInfoList set ");
            if (model.Receiver != null)
            {
                strSql.Append("Receiver='" + model.Receiver + "',");
            }
            else
            {
                strSql.Append("Receiver= null ,");
            }
            if (model.ReceiveOrg != null)
            {
                strSql.Append("ReceiveOrg='" + model.ReceiveOrg + "',");
            }
            else
            {
                strSql.Append("ReceiveOrg= null ,");
            }
            if (model.MessType != null)
            {
                strSql.Append("MessType='" + model.MessType + "',");
            }
            else
            {
                strSql.Append("MessType= null ,");
            }
            if (model.IsHandle != null)
            {
                strSql.Append("IsHandle='" + model.IsHandle + "',");
            }
            else
            {
                strSql.Append("IsHandle= null ,");
            }
            if (model.MessTitle != null)
            {
                strSql.Append("MessTitle='" + model.MessTitle + "',");
            }
            else
            {
                strSql.Append("MessTitle= null ,");
            }
            if (model.MessContent != null)
            {
                strSql.Append("MessContent='" + model.MessContent + "',");
            }
            else
            {
                strSql.Append("MessContent= null ,");
            }
            if (model.Attachment != null)
            {
                strSql.Append("Attachment='" + model.Attachment + "',");
            }
            else
            {
                strSql.Append("Attachment= 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 MessID='" + model.MessID + "' ");
            int rowsAffected = DbHelperOleDb.ExecuteSql(strSql.ToString());

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