Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            comboBox1.Enabled = false;

            RepresentitiveBillDetail newRepresentiveBd = new RepresentitiveBillDetail();
            Representitive           NameRep           = (Representitive)comboBox1.SelectedItem;
            Representitive           rep = context.Representitives.FirstOrDefault(r => r.Name == NameRep.Name);
            RepresentitiveBill       newRepresentitveBill = new RepresentitiveBill()
            {
                Representitive_NationalID = rep.NationalID
            };

            context.RepresentitiveBills.Add(newRepresentitveBill);
            context.SaveChanges();
            RepresentitiveBill RepresentitveBillJustAdded = context.RepresentitiveBills.OrderByDescending(r => r.ID).FirstOrDefault();

            foreach (var item in supproductlocalList)
            {
                newRepresentiveBd.GivenAmount              = item.GivenAmount;
                newRepresentiveBd.Date                     = item.Date;
                newRepresentiveBd.ProductObj_ID            = item.ProductObj_ID;
                newRepresentiveBd.GivenAmountPrice         = item.GivenAmountPrice;
                newRepresentiveBd.RepresentitiveBillObj_ID = RepresentitveBillJustAdded.ID;
                context.RepresentitiveBillDetails.Add(newRepresentiveBd);
                context.SaveChanges();
                Product pro = context.Products.FirstOrDefault(p => p.ID == item.ProductObj_ID);
                pro.AmountInStock = pro.AmountInStock - item.GivenAmount;
                context.SaveChanges();
            }
        }
Example #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            int numberOfBillRepresentive;
            RepresentitiveBill RpresentiveB = context.RepresentitiveBills.OrderByDescending(R => R.ID).FirstOrDefault();

            if (RpresentiveB == null)
            {
                numberOfBillRepresentive = 1;
                labelNumberBill.Text     = numberOfBillRepresentive.ToString();
            }
            else
            {
                numberOfBillRepresentive = int.Parse(RpresentiveB.ID.ToString());
                numberOfBillRepresentive++;
                labelNumberBill.Text = numberOfBillRepresentive.ToString();
            }
            listView1.Clear();
            comboBox1.Enabled = true;

            numericUQouantity.Value = 0;
        }
Example #3
0
        private void sader_Load(object sender, EventArgs e)
        {
            List <Representitive> rep = context.Representitives.ToList();

            comboBox1.DataSource    = rep;
            comboBox1.DisplayMember = "Name";
            //-----------------displayNumber Of bill--------------
            //--------number of bill representiv----------
            int numberOfBill2;
            RepresentitiveBill representivrB = context.RepresentitiveBills.OrderByDescending(r => r.ID).FirstOrDefault();

            if (representivrB == null)
            {
                SqlConnection connection = new SqlConnection(@"Data Source=DESKTOP-9HH57Q0\MSSQLSEVEREX;Initial Catalog=project;Integrated Security=True");

                SqlCommand command = new SqlCommand();
                connection.Open();
                command.Connection  = connection;
                command.CommandText = "DBCC CHECKIDENT ('RepresentitiveBills',RESEED,0)";
                command.ExecuteNonQuery();
                connection.Close();

                numberOfBill2        = 1;
                labelNumberBill.Text = numberOfBill2.ToString();
            }
            else
            {
                numberOfBill2 = int.Parse(representivrB.ID.ToString());
                numberOfBill2++;
                labelNumberBill.Text = numberOfBill2.ToString();
            }
            List <Product> ProductList = context.Products.ToList();

            productComboSypplyer.DataSource    = ProductList;
            productComboSypplyer.DisplayMember = "Name";
        }