private void BtnSave_Click(object sender, System.EventArgs e) { try { if (string.IsNullOrEmpty(this.breederCode)) { var breeder = new Breeder { //UnitCode = Convert.ToInt32(txtUnitCode.Text), BreederName = txtBreederName.Text.Trim(), Active = chkActive.Checked, CreateBy = "system", }; BreederController.Insert(breeder); MessageBox.Show("บันทึกข้อมูลเรียบร้อย.", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var breeder = new Breeder { BreederCode = Convert.ToInt32(txtBreederCode.Text), BreederName = txtBreederName.Text.Trim(), Active = chkActive.Checked, ModifiedBy = "system", }; BreederController.Update(breeder); MessageBox.Show("บันทึกข้อมูลเรียบร้อย.", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.DialogResult = DialogResult.OK; this.Close(); } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnSaveAndNew_Click(object sender, System.EventArgs e) { try { var breeder = new Breeder { //UnitCode = Convert.ToInt32(txtUnitCode.Text), BreederName = txtBreederName.Text.Trim(), Active = chkActive.Checked, CreateBy = "system", }; BreederController.Insert(breeder); MessageBox.Show("บันทึกข้อมูลเรียบร้อย.", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information); txtBreederCode.Text = ""; txtBreederCode.Focus(); txtBreederName.Text = ""; chkActive.Checked = true; } catch (System.Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }