protected void btnSave_Click(object sender, EventArgs e) { Supplier dataObj = new Supplier(); dataObj.SupplierID = -1; dataObj.CompanyName = this.txtCompanyName.Text; dataObj.Contactname = this.txtContactName.Text; dataObj.ContactTitle = this.txtTitle.Text; dataObj.Address = this.txtAddress.Text; dataObj.City = this.txtCity.Text; dataObj.Region = this.txtRegion.Text; dataObj.Postalcode = this.txtPostalCode.Text; dataObj.Country = this.txtCountry.Text; dataObj.Phone = this.txtPhone.Text; dataObj.Fax = this.txtFax.Text; try { int check = dataObj.isValid(); if (check < 0) { //MessageBox.Show(newEmp.getErrorMessage(check)); this.script.Text = "<script>alert(\""+dataObj.getErrorMessage(check)+"\");</script>"; return; } else { if (this.newEmpMode == true) this.dataModel.insertNewRow(dataObj); else { dataObj.SupplierID = this.suppID; this.dataModel.updateRow(dataObj); } //Server.Transfer("Suppliers.aspx", true); } } catch (Exception ex) { Session["current_error"] = ex.Message; Response.Redirect("serverError.aspx"); } Response.Redirect("Suppliers.aspx"); }
private void doSave_Update() { this.errorProvider.Clear(); Supplier dataObj = new Supplier(); dataObj.SupplierID = -1; dataObj.CompanyName = this.txtCompName.Text; dataObj.Contactname = this.txtContname.Text; dataObj.ContactTitle = this.txtContTitle.Text; dataObj.Address = this.txtAddr.Text; dataObj.City = this.txtCity.Text; dataObj.Region = this.txtRegion.Text; dataObj.Postalcode = this.txtPos.Text; dataObj.Country = this.cbCountry.Text; dataObj.Phone = this.txtPhone.Text; dataObj.Fax = this.txtFax.Text; int check = dataObj.isValid(); if (check < 0) { showErrors(dataObj, check); } else { try { if (this.AddNewMode == true) this.dataModel.insertNewRow(dataObj); else { dataObj.SupplierID = int.Parse(this.txtSupID.Text); this.dataModel.updateRow(dataObj); } this.clearForm(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } } }
private void btnAdd_Click(object sender, EventArgs e) { Supplier newSup = new Supplier(); newSup.SupplierID = -1; newSup.CompanyName = this.txtCompName.Text; newSup.Contactname = this.txtContname.Text; newSup.ContactTitle = this.txtContTitle.Text; newSup.Address = this.txtAddr.Text; newSup.City = this.txtCity.Text; newSup.Region = this.txtRegion.Text; newSup.Postalcode = this.txtPos.Text; newSup.Country = this.cbCountry.Text; newSup.Phone = this.txtPhone.Text; newSup.Fax = this.txtFax.Text; int check = newSup.isValid(); if (check < 0) { MessageBox.Show(newSup.getErrorMessage(check)); } else { this.dataModel.insertNewRow(newSup); MessageBox.Show("Completed"); clearAll(); } }