Пример #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txt_HospId.SelectedRow == null || string.IsNullOrEmpty(txt_HospId.SelectedRow["HospId"].ToString()))
            {
                if (txt_HospId.Tag != null)
                {
                    hospdep.HospId = txt_HospId.Tag.ToString();
                }
                else
                {
                    MessageBox.Show("请选择医院");
                    return;
                }
            }
            else
            {
                hospdep.HospId = txt_HospId.SelectedRow["HospId"].ToString();
            }



            hospdep.BasedepId   = "0000000001";
            hospdep.HospdepName = txt_HospdepName.Text.Trim();

            int DisplayOrder = 0;

            try
            {
                DisplayOrder = Convert.ToInt32(txt_DisplayOrder.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("排序编号输入错误");
            }


            hospdep.DisplayOrder = DisplayOrder;
            hospdep.Remarks      = txt_Remarks.Text.Trim();
            hospdep.OperatorId   = MainForm.user.ReUId;
            hospdep.OperatorDate = DateTime.Now;



            if (string.IsNullOrEmpty(hospdep.HospdepName))
            {
                MessageBox.Show("科室名称不能为空!");
                return;
            }



            if (state == FormState.Add)
            {
                int i = dal.Insert(hospdep);
                if (i > 0)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("增加失败!");
                }
            }
            else
            {
                int i = dal.Update(hospdep);
                if (i > 0)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("修改失败!");
                }
            }
        }