示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool      bResult = false;
                FactoryVO VO      = new FactoryVO();
                if (cboFactoryGrade.Text != "")
                {
                    VO.factory_grade = cboFactoryGrade.SelectedValue.ToString();
                }

                if (cboParent.Text == "미선택" || cboParent.Text == "")
                {
                    VO.factory_parent = "";
                }
                else
                {
                    VO.factory_parent = cboParent.SelectedValue.ToString();
                }
                VO.factory_name = txtNameFactory.Text;
                VO.factory_type = cboTypeFactory.SelectedValue.ToString();
                if (cboCompany.SelectedIndex == 0)
                {
                    VO.company_id = 0;
                }
                else
                {
                    VO.company_id = (int)cboCompany.SelectedValue;
                }
                VO.factory_yn     = cboYN.SelectedValue.ToString();
                VO.factory_udate  = string.Format("{0:yyyy-MM-dd HH:mm:ss}", today);
                VO.factory_uadmin = txtUadmin.Text;
                VO.factory_code   = txtCodeFactory.Text;

                if (txtComment.Text.Trim() == "")
                {
                    VO.factory_comment = "";
                }
                else
                {
                    VO.factory_comment = txtComment.Text;
                }



                if (mode == EditMode.Input)
                {
                    bResult = Fac_service.InsertFactory(VO);
                    if (bResult)
                    {
                        MessageBox.Show("등록성공");
                        this.DialogResult = DialogResult.OK;
                    }
                    else if (!bResult)
                    {
                        MessageBox.Show("등록실패");
                        this.DialogResult = DialogResult.None;
                        return;
                    }
                }
                if (mode == EditMode.Update)
                {
                    VO.factory_id = Convert.ToInt32(lblID.Text);
                    bResult       = Fac_service.UpdateFactory(VO);
                    if (bResult)
                    {
                        MessageBox.Show("수정성공");
                        this.DialogResult = DialogResult.OK;
                    }
                    else if (!bResult)
                    {
                        MessageBox.Show("수정실패");
                        this.DialogResult = DialogResult.None;
                        return;
                    }
                }
            }
            catch (NullReferenceException err)
            {
                MessageBox.Show("입력되지 않은값이 있습니다, 다시 확인해주세요", "입력확인", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.DialogResult = DialogResult.None;
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
                this.DialogResult = DialogResult.None;
            }
        }