// case delete || update in provider order state = Order private void Operations_dgv_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (comboBox1.SelectedItem.ToString() == "Order") { // case of dalete if (e.ColumnIndex == 0) { // user confirm about the delete operation string messag = "Do You really sure about the delete operation ?"; if (MessageBox.Show(messag, "Confirmation Messag", MessageBoxButtons.YesNo) == DialogResult.Yes) { new ProviderOrderLineBLO(db).Delete(Convert.ToInt32(Operations_dgv.CurrentRow.Cells[2].Value.ToString())); MessageBox.Show("Deleted !!"); // referesh the datagridview after delliting the item selected Operations_dgv.DataSource = null; Operations_dgv.DataSource = new ProviderOrderLineBLO(db).GetPOlByOpType(comboBox1.SelectedItem.ToString()); //Operations_dgv.Columns[2].Visible = false; //Operations_dgv.Columns[3].Visible = false; } } // Update s case if (e.ColumnIndex == 1) { // user s confirm about the operation string messsage = "This Order is already here ?"; if (MessageBox.Show(messsage, "Confirmation Messag", MessageBoxButtons.YesNo) == DialogResult.Yes) { ProviderOrderLine pol = new ProviderOrderLine(); pol = new ProviderOrderLineBLO(db).GetByID(Convert.ToInt32(Operations_dgv.CurrentRow.Cells[2].Value.ToString())); //MessageBox.Show(pol.Id.ToString()); ProviderOrder po = new ProviderOrder(); // change the order state selected form order to buy po = new ProviderOrderBLO(db).GetByID(Convert.ToInt32(Operations_dgv.CurrentRow.Cells[3].Value.ToString())); po.OrderState = "Buy"; po.orderDate = DateTime.Now; new ProviderOrderBLO(db).Save(po); Article article = new Article(); article = new ArticlesBLO(db).SearchByReference(Operations_dgv.CurrentRow.Cells[4].Value.ToString())[0]; MessageBox.Show("Count Article Before " + article.Quantity); // add the quantity selected to the article in stock article.Quantity = article.Quantity + pol.Quantity; MessageBox.Show("Count Article After : " + article.Quantity); // refresh the articles datagridview after this operation Operations_dgv.DataSource = null; Operations_dgv.DataSource = new ProviderOrderLineBLO(db).GetPOlByOpType(comboBox1.SelectedItem.ToString()); } } } }
private void endadte_dtp_ValueChanged(object sender, EventArgs e) { // start date && end date confirming // Get the Articles list in buy order state + the count + total price // Get the Articles list in sell order state + the count + total price // Get the expenses list + the count + total price // EndDate = endadte_dtp.Value; string Message = "vous etes d'accord ? \n\t Date Debut est : " + StartDate.Day + "-" + StartDate.Month + "-" + StartDate.Year + "\n\t Date Fin est : " + EndDate.Day + "-" + EndDate.Month + "-" + EndDate.Year; if (MessageBox.Show(Message, "Confirmation Messag", MessageBoxButtons.YesNo) == DialogResult.Yes) { // enable the other parts result buy_grpbx.Enabled = true; buy_dgv.DataSource = null; buy_dgv.DataSource = new ProviderOrderLineBLO(db).GetPOLBySD_ED_OS(StartDate, EndDate); if (new ProviderOrderLineBLO(db).GetPOLBySD_ED_OS(StartDate, EndDate).Count > 0) { buy_dgv.Columns[0].Visible = false; buy_dgv.Columns[1].Visible = false; } // sell_grpx.Enabled = true; sell_dgv.DataSource = null; sell_dgv.DataSource = new CustomerOrderLineBLO(db).GetCOLBySD_ED(StartDate, EndDate); if (new CustomerOrderLineBLO(db).GetCOLBySD_ED(StartDate, EndDate).Count() > 0) { sell_dgv.Columns[0].Visible = false; sell_dgv.Columns[1].Visible = false; } // exp_grpx.Enabled = true; exp_dgv.DataSource = null; exp_dgv.DataSource = new ExpensesBLO(db).GetExpByStartDate_Ed(StartDate, EndDate); //Informations count SAC_tb.Text = (new CustomerOrderLineBLO(db).GetCOLBySD_ED(StartDate, EndDate).Count()).ToString(); BAC_tb.Text = (new ProviderOrderLineBLO(db).GetPOLBySD_ED_OS(StartDate, EndDate).Count).ToString(); E_tb.Text = (new ExpensesBLO(db).GetExpByStartDate_Ed(StartDate, EndDate).Count).ToString(); /// Information Prices // 1- Sell List <Article> ArticlesList = new List <Article>(); ArticlesList = new CustomerOrderLineBLO(db).GetArticles_SD_ED(StartDate, EndDate); float PriceTotal = 0; foreach (var item in ArticlesList) { PriceTotal = PriceTotal + item.SellingPrice; } SP_tb.Text = PriceTotal.ToString(); // 2- Buy List <Article> BuyArticlesList = new List <Article>(); BuyArticlesList = new ProviderOrderLineBLO(db).GetArticlesList_SD_Ed(StartDate, EndDate); float BPriceTotal = 0; foreach (var item in BuyArticlesList) { BPriceTotal = BPriceTotal + item.BuyingPrice; } BP_tb.Text = BPriceTotal.ToString(); //3-Expenses List <Expense> ExpensesList = new List <Expense>(); ExpensesList = new ExpensesBLO(db).GetExpBySD_ES(StartDate, EndDate); float EPriceTotal = 0; foreach (var item in ExpensesList) { EPriceTotal = EPriceTotal + item.price; } EP_tb.Text = EPriceTotal.ToString(); } }