private void addCompanyBtn_Click(object sender, EventArgs e)
        {
            try
            {
                item offer = new item();
                if (String.IsNullOrEmpty(companyNametxt.Text) || String.IsNullOrEmpty(itemNameCbox.Text) || String.IsNullOrEmpty(Qtytxt.Text) || String.IsNullOrEmpty(costTxt.Text) || String.IsNullOrEmpty(totalCostTxt.Text))
                {
                    MessageBox.Show("برجاء ادخال البيانات المطلوبة ");
                }
                else
                {
                    offer.Company_Name = companyNametxt.Text;
                    offer.item_Name    = itemNameCbox.Text;

                    int Qty;
                    IsNumber = int.TryParse(Qtytxt.Text, out Qty);
                    if (!IsNumber)
                    {
                        throw new Exception("برجاء إدخال رقم صحيح في الكمية المطلوبة");
                    }
                    offer.REQ_Quantity = Qty;
                    //offer.REQ_Quantity = Convert.ToInt32(Qtytxt.Text);

                    double cost;
                    IsNumber = Double.TryParse(costTxt.Text, out cost);
                    if (!IsNumber)
                    {
                        throw new Exception("برجاء إدخال رقم في السعر الإفرادي");
                    }
                    offer.Cost = cost;
                    //offer.Cost = Convert.ToInt32(costTxt.Text);

                    offer.totalCost    = Convert.ToDouble(totalCostTxt.Text);
                    offer.Model        = modelTxt.Text;
                    offer.Manufacturer = ManufTxt.Text;
                    offer.madein       = madeinTxt.Text;
                    offer.item_Id      = add.item_Id;
                    offer.Comp_Num     = add.Comp_Num;
                    offer.Condition    = conditionCbox.Text;
                    offer.OfferNote    = NoteOfferTxt.Text;
                    offer.ADD_Offer();
                    MessageBox.Show("تم الحفظ بنجاح");
                    companyNametxt.Clear();
                    Qtytxt.Clear();
                    costTxt.Clear();
                    totalCostTxt.Clear();
                    modelTxt.Clear();
                    ManufTxt.Clear();
                    madeinTxt.Clear();
                    NoteOfferTxt.Clear();
                    conditionCbox.SelectedItem = null;
                    itemNameCbox.SelectedItem  = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        private void addCompanyBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(companyNametxt.Text) || String.IsNullOrEmpty(itemNameCbox.Text) || String.IsNullOrEmpty(totalCostTxt.Text))
                {
                    throw new Exception("برجاء ادخال البيانات المطلوبة");
                }
                double cost;
                IsNumber = Double.TryParse(costTxt.Text, out cost);
                if (!IsNumber)
                {
                    throw new Exception("برجاء إدخال رقم في السعر الإفرادي");
                }

                #region controls
                companyCount++;
                Label  newlable = new Label();
                Button newBtn   = new Button();

                newlable.Name     = "Company" + itemsCount;
                newlable.Text     = companyNametxt.Text;
                newlable.AutoSize = true;
                newlable.Visible  = true;
                newlable.Enabled  = true;
                newlable.Tag      = newBtn;

                newBtn.Name      = "deleteCompany" + itemsCount;
                newBtn.Text      = "-";
                newBtn.Size      = new Size(26, 23);
                newBtn.BackColor = Color.SeaGreen;
                newBtn.ForeColor = Color.White;
                newBtn.FlatStyle = FlatStyle.Flat;
                newBtn.Click    += new EventHandler(deleteCompany_Click);



                companiesPanel.Controls.Add(newlable);
                companiesPanel.Controls.Add(newBtn);


                #endregion

                item offer = new item();
                offer.Company_Name = newlable.Text;
                offer.item_Name    = itemNameCbox.Text;

                int Qty;
                IsNumber       = int.TryParse(Qtytxt.Text, out Qty);
                offer.Quantity = Qty;

                offer.Cost = cost;

                double totalCost;
                IsNumber        = Double.TryParse(totalCostTxt.Text, out totalCost);
                offer.totalCost = totalCost;

                offer.Comp_Num      = compNumTxt.Text;
                offer.Model         = modelTxt.Text;
                offer.Manufacturer  = ManufTxt.Text;
                offer.madein        = madeinTxt.Text;
                offer.Condition     = conditionCbox.Text;
                offer.codeIdentifer = newlable.Name;
                offerslist.Add(offer);
                companyNametxt.Clear();
                Qtytxt.Clear();
                costTxt.Clear();
                totalCostTxt.Clear();
                modelTxt.Clear();
                ManufTxt.Clear();
                madeinTxt.Clear();
                itemNameCbox.SelectedItem = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }