Esempio n. 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string resp = "";
                if (txtCompany.Text == string.Empty)
                {
                    MessageError("Fill the fields");
                    errorIcon.SetError(txtCompany, "Insert the Company's name");
                }
                else
                {
                    if (this.eNew)
                    {
                        resp = BSupplier.Insert(this.txtCompany.Text, this.cbComercialSector.Text,
                                                this.cbDocumentType.Text, this.txtDocNumber.Text, this.txtAddress.Text, "1234", this.txtEmail.Text, this.txtUrl.Text
                                                );
                    }
                    else
                    {
                        resp = BSupplier.Edit(Convert.ToInt32(this.txtId.Text),
                                              this.txtCompany.Text, this.cbComercialSector.Text,
                                              this.cbDocumentType.Text, this.txtDocNumber.Text.Trim(), this.txtAddress.Text, "1234", this.txtEmail.Text, this.txtUrl.Text);
                    }

                    if (resp.Equals("OK"))
                    {
                        if (this.eNew)
                        {
                            this.MessageOk("Register saved");
                        }
                        else
                        {
                            this.MessageOk("Register Edited");
                        }
                    }
                    else
                    {
                        this.MessageError(resp);
                    }

                    this.eNew  = false;
                    this.eEdit = false;
                    this.Enabledbuttons();
                    this.Clean();
                    this.ShowValues();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }