예제 #1
0
        //构造函数
        public DepartmentForm(BathDBDataContext dc, Department department, DepartLogMgForm form)
        {
            db = dc;
            m_form = form;
            if (department != null)
            {
                newDepartment = false;
                m_Department = department;
            }

            InitializeComponent();
        }
예제 #2
0
 partial void DeleteDepartment(Department instance);
예제 #3
0
 partial void UpdateDepartment(Department instance);
예제 #4
0
 partial void InsertDepartment(Department instance);
예제 #5
0
        //确定
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (TextName.Text.Trim() == "")
            {
                BathClass.printErrorMsg("需要输入部门名称");
                TextName.SelectAll();
                TextName.Focus();
                return;
            }

            m_Department.name = TextName.Text.Trim();

            if (TextNote.Text.Trim() != "")
                m_Department.note = TextNote.Text.Trim();

            if (newDepartment)
            {
                if (db.Department.FirstOrDefault(x => x.name == TextName.Text) != null)
                {
                    BathClass.printErrorMsg("已经存在此名称的部门");
                    TextName.SelectAll();
                    TextName.Focus();
                    return;
                }

                db.Department.InsertOnSubmit(m_Department);
                db.SubmitChanges();

                m_form.createTree();
                m_Department = new Department();
                TextName.Text = "";
                TextNote.Text = "";
                TextName.Focus();
            }
            else
            {
                db.SubmitChanges();
                this.DialogResult = DialogResult.OK;
            }
        }