Beispiel #1
0
        private void btnMod_Click(object sender, EventArgs e)
        {
            int count = this.gdvInfo.SelectedRowsCount;

            if (count == 0)
            {
                MessageBox.Show("请先搜索/刷新并选择需要修改的行", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Mo_Project myMo_Project = new Mo_Project();

            myMo_Project.projectNo        = this.gdvInfo.GetFocusedRowCellValue("project_no").ToString();
            myMo_Project.projectName      = this.gdvInfo.GetFocusedRowCellValue("project_name").ToString();
            myMo_Project.projectHeader    = this.gdvInfo.GetFocusedRowCellValue("project_header").ToString();
            myMo_Project.projectStartDate = Convert.ToDateTime(this.gdvInfo.GetFocusedRowCellValue("project_start_date"));
            myMo_Project.projectEndDate   = Convert.ToDateTime(this.gdvInfo.GetFocusedRowCellValue("project_end_date"));
            myMo_Project.projectCompany   = this.gdvInfo.GetFocusedRowCellValue("project_company").ToString();
            myMo_Project.projectContact   = this.gdvInfo.GetFocusedRowCellValue("project_contact").ToString();
            myMo_Project.contactPhone     = this.gdvInfo.GetFocusedRowCellValue("contact_phone").ToString();
            myMo_Project.remark           = this.gdvInfo.GetFocusedRowCellValue("remark").ToString();

            IsUpdate = true;

            frmProjectAdd myfrmCustomerAdd = new frmProjectAdd(myMo_Project, IsUpdate);

            if (myfrmCustomerAdd.ShowDialog() == DialogResult.Yes)
            {
                btnSearch_Click(sender, e);
            }
        }
        private void btnSure_Click(object sender, EventArgs e)
        {
            try
            {
                //输入判断
                if (CheckInput())
                {
                    return;
                }

                Mo_Project myMo_Project    = new Mo_Project();
                bool       ResultValue     = false;
                string     paramMessageBox = string.Empty;
                this.myMo_Project = GetMo_Project();
                ResultValue       = IsUpdate == false?myProject.Add(this.myMo_Project) : myProject.Update(this.myMo_Project);

                paramMessageBox = ResultValue == true ?"操作成功!" : "操作成功!";
                MessageBox.Show(paramMessageBox);
                this.DialogResult = ResultValue == true ? DialogResult.Yes :  DialogResult.No;
            }
            catch
            {
                MessageBox.Show("操作异常,请确认是否用户编号重复!", "温馨提示!");
            }
        }
        public frmProjectAdd(Mo_Project myMo_Customer, bool IsUpdate)
        {
            InitializeComponent();
            this.myMo_Project = myMo_Customer;

            txtProjectNo.Focus();
            this.IsUpdate             = IsUpdate;
            this.txtProjectNo.Enabled = false;
        }
        /// <summary>
        /// 获取到 Customer 实体
        /// </summary>
        /// <returns></returns>
        public Mo_Project GetMo_Project( )
        {
            Mo_Project myMo_Project = new Mo_Project();

            myMo_Project.projectNo        = this.txtProjectNo.Text.Trim();
            myMo_Project.projectName      = this.txtProjectName.Text.Trim();
            myMo_Project.projectHeader    = this.txtProjectHeader.Text.Trim();
            myMo_Project.projectStartDate = Convert.ToDateTime(this.startTime.EditValue);
            myMo_Project.projectEndDate   = Convert.ToDateTime(this.endTime.EditValue);
            myMo_Project.projectCompany   = this.txtProjectCompany.Text.Trim();
            myMo_Project.projectContact   = this.txtContact.Text.Trim();
            myMo_Project.contactPhone     = this.txtContactPhone.Text.Trim();
            myMo_Project.remark           = this.txtRemark.Text.Trim();
            return(myMo_Project);
        }