Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int found = 0;

            btnSave.Enabled = false;
            if (txtname.Text.Equals(""))
            {
                MessageBox.Show("Insert Product Name Please.");
            }
            else
            {
                DataTable dt = ClassSetting.searchProductsByName(txtname.Text);
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    if (txtname.Text.Equals(dt.Rows[j][0].ToString()))
                    {
                        found = 1;
                    }
                }
                if (found == 1)
                {
                    MessageBox.Show("This name already exists . .");
                }
                else
                {
                    int       AddPro  = ClassSetting.sp_addProduct(txtname.Text, txtBarcode.Text, (int)cmbCategory.SelectedValue, (int)cmbColor.SelectedValue, (int)cmbType.SelectedValue);
                    DataTable lastPro = ClassSetting.sp_lastProID();
                    for (int i = 0; i < images.Count; i++)
                    {
                        int ProImage = ClassSetting.sp_imgageProduct(images[i], int.Parse(lastPro.Rows[0][0].ToString()));
                    }
                    txtname.Text    = txtBarcode.Text = "";
                    LbNumOfImg.Text = "0";
                    images.Clear();
                    NumOfImage = 0;
                    MessageBox.Show("Done");
                }
            }
            btnSave.Enabled = true;
        }