private void btnSubmit_Click(object sender, EventArgs e) { if (model == null) // add Industrial mode { model = new models.IndustrialModel(); //new model to assign data model.Province = cbProvince.SelectedValue.ToString(); // set province id model.NameEn = txtNameEnglish.Text.Trim(); //set english name model.NameTh = txtNameThai.Text.Trim(); // set thai name model.NameJp = txtNameJapan.Text.Trim(); // set japan name model.SearchKey = txtSearchName.Text.Trim(); // set search name IndustrialController.InsertData(model); // call update method } else // update (edit) Industrial mode { model.Province = cbProvince.SelectedValue.ToString(); // set province id model.NameEn = txtNameEnglish.Text.Trim(); //set english name model.NameTh = txtNameThai.Text.Trim(); // set thai name model.NameJp = txtNameJapan.Text.Trim(); // set japan name model.SearchKey = txtSearchName.Text.Trim(); // set search name IndustrialController.UpdateData(model); } }
/* New Form with selected Mode */ public AddEditIndustrial(models.IndustrialModel model) { this.model = model; // Assign Mode into this form InitializeComponent(); }
public static void UpdateData(models.IndustrialModel model) { //show message box when cannot insert data MessageBox.Show((models.IndustrialModel.updateIndustrial(model)) ? "Insert Success" : "Insert Failed, Please Check parameter or something"); }