private void btnaction_Click(object sender, EventArgs e) { if (combotypes.SelectedIndex == -1 || combocompany.SelectedIndex == -1) { MessageBox.Show("الرجاء تحديد التاجر و الصنف", "خطأ ادخال بيانات", MessageBoxButtons.OK); return; } if (txtamount.Text == "0" || (string.IsNullOrEmpty(txtamount.Text))) { MessageBox.Show("الرجاء تحديد الكمية ", "خطأ ادخال بيانات", MessageBoxButtons.OK); return; } BLL.Types tp = BLL.Types.GetTypeByID((int)combotypes.SelectedValue); BLL.BusinesDeal cl = new WeightsOrganizer.BLL.BusinesDeal(0, (int)combotypes.SelectedValue, (int)combocompany.SelectedValue, double.Parse(txtamount.Text), tp.BusinessPrice, tp.ClientPrice, 0, "مجموعة", MyDateTime.Now, combocompany.Text, combotypes.Text); List <BLL.BusinesDeal> allz = new List <WeightsOrganizer.BLL.BusinesDeal>(); allz = alloo; bool s = false; if (allz.Count > 0) { foreach (BLL.BusinesDeal bd in allz) { if (bd.TypeId == cl.TypeId) { bd.Amount += cl.Amount; s = false; break; } else { s = true; } } if (s) { alloo.Add(cl); } } else { alloo.Add(cl); } MessageBox.Show(cl.AddedDate.ToString()); ALlPrice += cl.ToTalPrice; numbertextbox1.Text = ALlPrice.ToString(); numbertextbox2.Text = ALlPrice.ToString(); txtamount.Text = "20"; combotypes.SelectedIndex = -1; combotypes.Text = "اختر صنف.. "; dataGridView1.DataSource = new object(); dataGridView1.DataSource = alloo; combocompany.Enabled = false; }
void goo() { if (combotypes.SelectedIndex == -1 || combocompany.SelectedIndex == -1) { MessageBox.Show("الرجاء تحديد التاجر و الصنف", "خطأ ادخال بيانات", MessageBoxButtons.OK); return; } if (txtamount.Text == "0" || (string.IsNullOrEmpty(txtamount.Text))) { MessageBox.Show("الرجاء تحديد الكمية ", "خطأ ادخال بيانات", MessageBoxButtons.OK); return; } BLL.Types tp = BLL.Types.GetTypeByID((int)combotypes.SelectedValue); BLL.BusinesDeal cl = new WeightsOrganizer.BLL.BusinesDeal(0, (int)combotypes.SelectedValue, (int)combocompany.SelectedValue, double.Parse(txtamount.Text), tp.BusinessPrice, tp.ClientPrice, 0, "", MyDateTime.Now, combocompany.Text, combotypes.Text); alloo.Add(cl); ALlPrice += cl.ToTalPrice; numbertextbox1.Text = ALlPrice.ToString(); numbertextbox2.Text = ALlPrice.ToString(); txtamount.Text = ""; combotypes.SelectedIndex = -1; combotypes.Text = "اختر صنف.. "; dataGridView1.DataSource = new object(); dataGridView1.DataSource = alloo; combocompany.Enabled = false; }