Esempio n. 1
0
        //btn add factor section new factor
        private async void btnAddOrderAndOrderDetail_Click(object sender, EventArgs e)
        {
            btnAddOrderAndOrderDetail.Enabled = false;
            Orders    order    = new Orders();
            Customers customer = await CustCheck();

            List <OrderDetail> details = ProductToOrderDetails(_SoldProduct);

            order.CustId     = customer.CustId;
            order.EmpId      = _emp.EmpId;
            order.OrderDate  = DateTime.Now;
            order.AmountBuy  = ControlerMethods.AmountOfBuy(details);
            order.AmountSell = ControlerMethods.AmountOfSale(details);
            order.Profit     = ControlerMethods.porfit(details);
            try
            {
                order = await ControlerMethods.SetOrderAsync(order, details);

                DialogResult result = MessageBox.Show(String.Format("فاکتور به شماره {0} ثبت گردید", order.OrderId),
                                                      "موفق",
                                                      MessageBoxButtons.OK,
                                                      MessageBoxIcon.Information);

                btnAddOrderAndOrderDetail.Enabled = result == DialogResult.OK ? true : false;

                _SoldProduct = new List <Product>();
                LoadSoldProductTodata();
                lblTotal1.Text     = String.Format("{0:#,#}", ControlerMethods.AmountOfSale(ProductToOrderDetails(_SoldProduct)));
                lblTotalCount.Text = ControlerMethods.TotalOfQty(ProductToOrderDetails(_SoldProduct)).ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("خطا در هنگام انجام عملایات  " + "\n" + ex.Message,
                                "خطا",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }