예제 #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            int          numberOfSupplyerBill;
            SupplyerBill SupplyerB = context.SupplyerBills.OrderByDescending(c => c.ID).FirstOrDefault();

            if (SupplyerB == null)
            {
                numberOfSupplyerBill    = 1;
                BillNumberSypplyer.Text = numberOfSupplyerBill.ToString();
            }
            else
            {
                numberOfSupplyerBill = int.Parse(SupplyerB.ID.ToString());
                numberOfSupplyerBill++;
                BillNumberSypplyer.Text = numberOfSupplyerBill.ToString();
            }
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Supplyer     sup         = context.Supplyers.FirstOrDefault(s => s.Name == SupplyerCombo.Text);
            SupplyerBill suppleyBill = new SupplyerBill()
            {
                supplyer_ID = sup.ID,
                PaidPrice   = 0,
                DeptPrice   = 0
            };

            context.SupplyerBills.Add(suppleyBill);
            context.SaveChanges();
            SupplyerBill       supBill = context.SupplyerBills.OrderByDescending(s => s.ID).FirstOrDefault();
            SupplyerBillDetail supplyerBDetails;

            foreach (var item in supperList)
            {
                supplyerBDetails                    = new SupplyerBillDetail();
                supplyerBDetails.Amount             = item.Amount;
                supplyerBDetails.Date               = item.Date;
                supplyerBDetails.Paid               = 0;
                supplyerBDetails.Debt               = 0;
                supplyerBDetails.AmountPrice        = item.AmountPrice;
                supplyerBDetails.productOpj_ID      = item.productOpj_ID;
                supplyerBDetails.AdeyMortagaType    = item.AdeyMortagaType;
                supplyerBDetails.SupplyerBillobj_ID = supBill.supplyer_ID;
                context.SupplyerBillDetails.Add(supplyerBDetails);

                Product UpdateProduct = context.Products.FirstOrDefault(p => p.ID == supplyerBDetails.productOpj_ID);
                if (supplyerBDetails.AdeyMortagaType == "عادى")
                {
                    UpdateProduct.AmountInStock = UpdateProduct.AmountInStock + supplyerBDetails.Amount;
                }
                if (supplyerBDetails.AdeyMortagaType == "مرتجع")
                {
                    UpdateProduct.AmountInStock = UpdateProduct.AmountInStock - supplyerBDetails.Amount;
                }
                context.SaveChanges();
            }
        }
예제 #3
0
        private void supplierbill_Load(object sender, EventArgs e)
        {
            //--------------------fill Supplyer Name----------------------------
            List <Supplyer> supplyerList = context.Supplyers.ToList();

            SupplyerCombo.DataSource    = supplyerList;
            SupplyerCombo.DisplayMember = "Name";

            //------------------------fill name of product------------
            List <Product> ProductList = context.Products.ToList();

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

            int          numberOfBill3;
            SupplyerBill supplyerB = context.SupplyerBills.OrderByDescending(s => s.ID).FirstOrDefault();

            if (supplyerB == 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 ('supplyerBills',RESEED,0)";
                command.ExecuteNonQuery();
                connection.Close();

                numberOfBill3           = 1;
                BillNumberSypplyer.Text = numberOfBill3.ToString();
            }
            else
            {
                numberOfBill3 = int.Parse(supplyerB.ID.ToString());
                numberOfBill3++;
                BillNumberSypplyer.Text = numberOfBill3.ToString();
            }
        }