Пример #1
0
        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");
        }
Пример #2
0
 private void showErrors(Supplier supp, int code)
 {
     if (code == -2)
     {
         if (this.txtCompName.Text.Equals(""))
             this.errorProvider.SetError(txtCompName,
                     supp.getErrorMessage(code));
         if (this.txtContname.Text.Equals(""))
             this.errorProvider.SetError(txtContname,
                     supp.getErrorMessage(code));
         if (this.txtContTitle.Text.Equals(""))
             this.errorProvider.SetError(txtContTitle,
                     supp.getErrorMessage(code));
         if (this.txtAddr.Text.Equals(""))
             this.errorProvider.SetError(txtAddr,
                     supp.getErrorMessage(code));
         if (this.txtCity.Text.Equals(""))
             this.errorProvider.SetError(txtCity,
                     supp.getErrorMessage(code));
         if (this.cbCountry.Text.Equals(""))
             this.errorProvider.SetError(cbCountry,
                     supp.getErrorMessage(code));
         if (this.txtPhone.Text.Equals(""))
             this.errorProvider.SetError(txtPhone,
                     supp.getErrorMessage(code));
     }
 }
Пример #3
0
        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();
            }
        }