protected void btnSave_Click(object sender, EventArgs e) { Shipper dataObj = new Shipper(); dataObj.CompanyName = this.txtCatName.Text; dataObj.Phone = this.txtDescription.Text; /*dataObj.ShipperID = -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.ShipperID = this.suppID; this.dataModel.updateRow(dataObj); } //Server.Transfer("Shippers.aspx", true); } } catch (Exception ex) { Session["current_error"] = ex.Message; Response.Redirect("serverError.aspx"); } Response.Redirect("Shippers.aspx"); }
protected void doAdd_Update() { this.errorProvider.Clear(); Shipper dataObj = new Shipper(); dataObj.ShipperID = -1; dataObj.CompanyName = this.txtCatName.Text; dataObj.Phone = this.txtPhone.Text; int check = dataObj.isValid(); if (check < 0) { this.showErrors(); return; } try { if (this.AddNewMode == true) { this.dataModel.insertNewRow(dataObj); } else { dataObj.ShipperID = int.Parse(this.txtCatID.Text); this.dataModel.updateRow(dataObj); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.clearForm(); this.Close(); } }
private void EditCatForm_Load(object sender, EventArgs e) { this.errorProvider.Clear(); if (AddNewMode == true) { currentData = null; this.clearForm(); } else this.loadCurrentData(); }