private void btnSave_Click(object sender, EventArgs e)
        {
            int er = 0;

            ep.Clear();

            if (cmbProduct.SelectedValue == null || cmbProduct.SelectedValue == null)
            {
                er++;
                ep.SetError(cmbProduct, "Product Required");
            }

            if (txtTitle.Text == "")
            {
                er++;
                ep.SetError(txtTitle, "Title Required");
            }

            if (pbImage.Image == null)
            {
                er++;
                ep.SetError(pbImage, "Image Required");
            }

            if (er > 0)
            {
                return;
            }

            ProductImage productImage = new ProductImage();

            productImage.ProductId = Convert.ToInt32(cmbProduct.SelectedValue);
            productImage.Title     = txtTitle.Text;
            productImage.Image     = FileImage.ImageToByte(pbImage.Image);

            if (productImage.Insert())
            {
                MessageBox.Show(@"Image Saved");
                cmbProduct.SelectedValue = -1;
                txtTitle.Text            = "";
                pbImage.Image            = null;
                cmbProduct.Focus();
            }

            else
            {
                MessageBox.Show(productImage.Error);
            }
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DAL.clsEmployee em = new DAL.clsEmployee();

            int er = 0;

            er += txtName.txtValidate();
            er += txtPhone.txtValidate();
            er += txtEmail.txtValidate();
            er += txtType.txtValidate();
            er += txtPassword.txtValidate();
            er += pbImage.txtValidate();

            if (er == 0)
            {
                em.Name     = txtName.txtTextValue;
                em.Phone    = txtPhone.txtTextValue;
                em.Email    = txtEmail.txtTextValue;
                em.Type     = txtType.txtTextValue;
                em.Password = txtPassword.txtTextValue;
                em.Image    = FileImage.ImageToByte(pbImage.BGImage);

                if (em.Insert())
                {
                    MessageBox.Show("Employee Information is Saved !!");
                    txtName.txtTextValue     = "";
                    txtPhone.txtTextValue    = "";
                    txtEmail.txtTextValue    = "";
                    txtType.txtTextValue     = "";
                    txtPassword.txtTextValue = "";
                    pbImage.BGImage          = null;
                    txtName.Focus();
                }
                else
                {
                    MessageBox.Show(em.Error);
                }
            }
        }
Ejemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int er = 0;

            ep.Clear();

            if (txtName.Text == "")
            {
                er++;
                ep.SetError(txtName, "Name Required");
            }

            if (txtContact.Text == "")
            {
                er++;
                ep.SetError(txtContact, "Contact Required");
            }

            if (txtEmail.Text == "")
            {
                er++;
                ep.SetError(txtEmail, "Email Required");
            }

            if (txtPassword.Text == "")
            {
                er++;
                ep.SetError(txtPassword, "Password Required");
            }

            if (cmbGender.Text.ToString() == "")
            {
                er++;
                ep.SetError(cmbGender, "Gender Required");
            }

            if (txtAddress.Text == "")
            {
                er++;
                ep.SetError(txtAddress, "Address Required");
            }

            if (cmbCity.SelectedValue == null || cmbCity.SelectedValue.ToString() == "")
            {
                er++;
                ep.SetError(cmbCity, "City Required");
            }

            if (dtpDateOfBirth.Text == "")
            {
                er++;
                ep.SetError(dtpDateOfBirth, "DOB Required");
            }

            if (cmbType.Text.ToString() == "")
            {
                er++;
                ep.SetError(cmbType, "City Required");
            }

            if (pbImage.Image == null)
            {
                er++;
                ep.SetError(pbImage, "Image Required");
            }

            if (er > 0)
            {
                return;
            }

            ledger.Name        = txtName.Text;
            ledger.Contact     = txtContact.Text;
            ledger.Email       = txtEmail.Text;
            ledger.Password    = txtPassword.Text;
            ledger.Gender      = cmbGender.Text;
            ledger.Address     = txtAddress.Text;
            ledger.CityId      = Convert.ToInt32(cmbCity.SelectedValue);
            ledger.DateOfBirth = Convert.ToDateTime(dtpDateOfBirth.Value);
            ledger.Type        = cmbType.Text;
            ledger.Image       = FileImage.ImageToByte(pbImage.Image);


            if (ledger.Update())
            {
                if (cmbType.Text == @"Customer")
                {
                    MessageBox.Show(@"Customer Updated");
                }
                else
                {
                    MessageBox.Show(@"Supplier Updated");
                }
                Close();
            }

            else
            {
                MessageBox.Show(ledger.Error);
            }
        }