private void vatComplementoryButton_Click(object sender, EventArgs e) { CResult aCResult = new CResult(); CUserInfoDAO aUserInfoDao = new CUserInfoDAO(); CUserInfo aUserInfo = new CUserInfo(); aUserInfo.UserID = RMSGlobal.m_iLoginUserID; aCResult = aUserInfoDao.GetUser(aUserInfo); aUserInfo = (CUserInfo)aCResult.Data; if (aUserInfo.Type != 0) { MessageBox.Show("You are not correct person to give Order Vat Complementory Opportunity"); return; } COrderInfoDAO aOrderInfoDao = new COrderInfoDAO(); string result = aOrderInfoDao.UpdateOrderVatComplementory(orderID, true); LoadOrderDetails(); MessageBox.Show(result); }
// Change by Mithu public void LoadWaiter() { CUserInfoDAO orderwaiterDao = new CUserInfoDAO(); // COrderwaiter orderwaiter = new COrderwaiter(); List<CUserInfo> auserInfo = new List<CUserInfo>(); auserInfo = orderwaiterDao.GetAllUser(); auserInfo = (from userInfo in auserInfo where userInfo.Type == 7 select userInfo).ToList(); waitercomboBox.DataSource = auserInfo; waitercomboBox.ValueMember = "UserID"; waitercomboBox.DisplayMember = "UserName"; }
private void itemComplementoryButton_Click(object sender, EventArgs e) { CResult aCResult = new CResult(); CUserInfoDAO aUserInfoDao = new CUserInfoDAO(); CUserInfo aUserInfo = new CUserInfo(); aUserInfo.UserID = RMSGlobal.m_iLoginUserID; aCResult = aUserInfoDao.GetUser(aUserInfo); aUserInfo = (CUserInfo)aCResult.Data; if (aUserInfo.Type != 0) { MessageBox.Show("You are not correct person to give Item Complementory Opportunity"); return; } COrderInfoDAO aOrderInfoDao=new COrderInfoDAO(); foreach (DataGridViewRow row in g_FoodDataGridView.Rows) { if (Convert.ToBoolean(row.Cells["complementoryfood"].Value) == true) { COrderDetails aCOrderDetails = new COrderDetails(); aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["Order_details_id"].Value); string result = aOrderInfoDao.UpdateItemComplementory(aCOrderDetails.OrderDetailsID); } } foreach (DataGridViewRow row in g_BeverageDataGridView.Rows) { if (Convert.ToBoolean(row.Cells["complementorynonfood"].Value) == true) { COrderDetails aCOrderDetails = new COrderDetails(); aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["dataGridViewTextBoxColumn5"].Value); string result = aOrderInfoDao.UpdateItemComplementory(aCOrderDetails.OrderDetailsID); } } LoadOrderDetails(); }
private void g_PromotionsButton_Click(object sender, EventArgs e) { CResult aCResult=new CResult(); CUserInfoDAO aUserInfoDao=new CUserInfoDAO(); CUserInfo aUserInfo = new CUserInfo(); aUserInfo.UserID = RMSGlobal.m_iLoginUserID; aCResult = aUserInfoDao.GetUser(aUserInfo); aUserInfo = (CUserInfo)aCResult.Data; if (aUserInfo.Type != 0) { MessageBox.Show("You are not correct person to give discount"); return; } //CDiscountForm tempDiscountForm = new CDiscountForm(); //tempDiscountForm.ShowDialog(); //if (CDiscountForm.discountType.Equals("Cancel")) // return; //m_dDiscountAmount = Convert.ToDecimal(CDiscountForm.discountAmount); //m_sDiscountType = CDiscountForm.discountType; //double discountAmount = 0; //List<COrderDetails> aCOrderDetailses=new List<COrderDetails>(); //foreach (DataGridViewRow row in g_FoodDataGridView.Rows) //{ // if(Convert.ToBoolean(row.Cells["foodselect"].Value)==true) // { // COrderDetails aCOrderDetails=new COrderDetails(); // aCOrderDetails.ProductID = Convert.ToInt32(row.Cells["Cat_id"].Value); // aCOrderDetails.OrderQuantity = Convert.ToInt32(row.Cells["Qty"].Value); // aCOrderDetails.UnitPrice = Convert.ToDouble(row.Cells["unitPrice"].Value); // aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["Order_details_id"].Value); // aCOrderDetails.OrderAmount = Convert.ToDouble(row.Cells["Price"].Value); // aCOrderDetails.DiscountAmount = (((double)m_dDiscountAmount)*aCOrderDetails.OrderAmount)/100; // discountAmount += aCOrderDetails.DiscountAmount; // aCOrderDetailses.Add(aCOrderDetails); // } //} //foreach (DataGridViewRow row in g_BeverageDataGridView.Rows) //{ // if (Convert.ToBoolean(row.Cells["nonfoodselect"].Value) == true) // { // COrderDetails aCOrderDetails = new COrderDetails(); // aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["dataGridViewTextBoxColumn5"].Value); // aCOrderDetails.OrderAmount = Convert.ToDouble(row.Cells["dataGridViewTextBoxColumn7"].Value); // aCOrderDetails.DiscountAmount = (((double)m_dDiscountAmount) * aCOrderDetails.OrderAmount) / 100; // discountAmount += aCOrderDetails.DiscountAmount; // aCOrderDetailses.Add(aCOrderDetails); // } //} //COrderDetailsDAO aOrderDetailsDao=new COrderDetailsDAO(); //string result = aOrderDetailsDao.UpdateItemWiseDiscount(aCOrderDetailses); //MessageBox.Show(result); //COrderManager tempOrderManager = new COrderManager(); // COrderDiscount tempOrderDiscount = new COrderDiscount(); // CResult oResult = tempOrderManager.OrderDiscountGetByOrderID(orderID); // if (oResult.IsSuccess && oResult.Data != null) // { // tempOrderDiscount = (COrderDiscount)oResult.Data; // if (membership != null && membership.id > 0) // { // tempOrderDiscount.clientID = membership.customerID; // tempOrderDiscount.membershipCardID = membership.mebershipCardID; // tempOrderDiscount.membershipID = membership.id; // tempOrderDiscount.membershipPoint = membership.point; // tempOrderDiscount.membershipDiscountRate = membership.discountPercentRate; // } // //update // tempOrderDiscount.Discount = Convert.ToDouble(discountAmount); // tempOrderManager.UpdateOrderDiscount(tempOrderDiscount); // } // else // { // //insert // tempOrderDiscount.OrderID = orderID; // tempOrderDiscount.Discount = Convert.ToDouble(discountAmount); // if (membership != null && membership.id > 0) // { // tempOrderDiscount.clientID = membership.customerID; // tempOrderDiscount.membershipCardID = membership.mebershipCardID; // tempOrderDiscount.membershipID = membership.id; // tempOrderDiscount.membershipPoint = membership.point; // tempOrderDiscount.membershipDiscountRate = membership.discountPercentRate; // } // tempOrderManager.InsertOrderDiscount(tempOrderDiscount); // } CDiscountForm tempDiscountForm = new CDiscountForm(); tempDiscountForm.ShowDialog(); if (CDiscountForm.discountType.Equals("Cancel")) return; m_dDiscountAmount = Convert.ToDecimal(CDiscountForm.discountAmount); m_sDiscountType = CDiscountForm.discountType; TotalAmountCalculation(); }
private void functionalButton1_Click_2(object sender, EventArgs e) { CResult aCResult = new CResult(); CUserInfoDAO aUserInfoDao = new CUserInfoDAO(); CUserInfo aUserInfo = new CUserInfo(); aUserInfo.UserID = RMSGlobal.m_iLoginUserID; aCResult = aUserInfoDao.GetUser(aUserInfo); aUserInfo = (CUserInfo)aCResult.Data; if (aUserInfo.Type != 0) { MessageBox.Show("You are not correct person to give Item Complementory Opportunity"); return; } CDiscountForm tempDiscountForm = new CDiscountForm(); tempDiscountForm.ShowDialog(); if (CDiscountForm.discountType.Equals("Cancel")) return; double discountAmount = Convert.ToDouble(CDiscountForm.discountAmount); string discountType = CDiscountForm.discountType; COrderDetailsDAO aOrderInfoDao = new COrderDetailsDAO(); foreach (DataGridViewRow row in g_FoodDataGridView.Rows) { if (Convert.ToBoolean(row.Cells["complementoryfood"].Value) == true) { COrderDetails aCOrderDetails = new COrderDetails(); aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["Order_details_id"].Value); aCOrderDetails = aOrderInfoDao.OrderDetailsGetByOrderDetailID(aCOrderDetails.OrderDetailsID); double totalAmount = aCOrderDetails.UnitPrice*aCOrderDetails.OrderQuantity; double discount=0; if (discountType == "Fixed") { discount = discountAmount; } else { discount = (totalAmount*discountAmount)/100.0; } aCOrderDetails.DiscountAmount = discount; string result = aOrderInfoDao.UpdateItemWiseDiscountForItem(aCOrderDetails); } } foreach (DataGridViewRow row in g_BeverageDataGridView.Rows) { if (Convert.ToBoolean(row.Cells["complementorynonfood"].Value) == true) { COrderDetails aCOrderDetails = new COrderDetails(); aCOrderDetails.OrderDetailsID = Convert.ToInt64(row.Cells["dataGridViewTextBoxColumn5"].Value); aCOrderDetails = aOrderInfoDao.OrderDetailsGetByOrderDetailID(aCOrderDetails.OrderDetailsID); double totalAmount = aCOrderDetails.UnitPrice * aCOrderDetails.OrderQuantity; double discount = 0; if (discountType == "Fixed") { discount = discountAmount; } else { discount = (totalAmount * discountAmount) / 100.0; } aCOrderDetails.DiscountAmount = discount; string result = aOrderInfoDao.UpdateItemWiseDiscountForItem(aCOrderDetails); } } CResult oResult1 = aOrderInfoDao.OrderDetailsGetByOrderID(orderID); List<COrderDetails> aOrderDetailses = oResult1.Data as List<COrderDetails>; double totalItemDiscount = 0; if (aOrderDetailses != null) { totalItemDiscount = aOrderDetailses.Sum(a => a.DiscountAmount); } COrderManager tempOrderManager = new COrderManager(); COrderDiscount tempOrderDiscount = new COrderDiscount(); CResult oResult = tempOrderManager.OrderDiscountGetByOrderID(orderID); if (oResult.IsSuccess && oResult.Data != null) { tempOrderDiscount = (COrderDiscount)oResult.Data; tempOrderDiscount.TotalItemDiscount = totalItemDiscount; tempOrderManager.UpdateOrderDiscount(tempOrderDiscount); } else { //insert tempOrderDiscount.OrderID = orderID; tempOrderDiscount.TotalItemDiscount = totalItemDiscount; tempOrderManager.InsertOrderDiscount(tempOrderDiscount); } LoadOrderDetails(); }
private bool CheckStockControl() { CCategory3DAO cCategory3Dao = new CCategory3DAO(); COrderManager tempOrderManager = new COrderManager(); List<COrderDetails> tempOrderDetailsList = new List<COrderDetails>(); CResult oResult = tempOrderManager.OrderDetailsByOrderID(orderID); if (oResult.IsSuccess && oResult.Data != null) tempOrderDetailsList = (List<COrderDetails>)oResult.Data; string stockMessage = "Stock is unavailable "; bool isStockAvailable = true; foreach (COrderDetails orderDetail in tempOrderDetailsList) { CCategory3 cCategory3 = cCategory3Dao.GetAllCategory3ByCategory3ID(Convert.ToInt32(orderDetail.ProductID)); if ((orderDetail.OrderQuantity - orderDetail.KitchenQuantity) > cCategory3.MUnitsInStock && cCategory3.MNonStockable) { //stockMessage += "\n " + orderDetail.Product_Name + " " + (orderDetail.OrderQuantity - cCategory3.MUnitsInStock); stockMessage += "\n " + cCategory3.Category3Name + ": Needed: " + (orderDetail.OrderQuantity - orderDetail.KitchenQuantity) + " But Have " + (cCategory3.MUnitsInStock); isStockAvailable = false; } } if (!isStockAvailable) { CUserInfoDAO aUserInfoDao = new CUserInfoDAO(); CUserInfo aUserInfo = new CUserInfo(); aUserInfo = aUserInfoDao.GetUserInfoByUsername(RMSGlobal.LoginUserName); if (aUserInfo.Type == 0) { DialogResult dialogResult = MessageBox.Show("Do You Proceed", "Stock Alert", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { isStockAvailable = true; } else if (dialogResult == DialogResult.No) { } } } if (!isStockAvailable || !CheckRawProduct(tempOrderDetailsList)) { CMessageBox cMessageBox = new CMessageBox("Finished Product", stockMessage); cMessageBox.ShowDialog(); //MessageBox.Show(stockMessage); return false; } else { foreach (COrderDetails orderDetails in tempOrderDetailsList) { CCategory3 cCategory3 = cCategory3Dao.GetAllCategory3ByCategory3ID(Convert.ToInt32(orderDetails.ProductID)); if (!cCategory3.MNonStockable) { cCategory3Dao.UpdateStock(Convert.ToInt32(orderDetails.ProductID), orderDetails.OrderQuantity - orderDetails.KitchenQuantity); COrderDetailsDAO cOrderDetailsDao = new COrderDetailsDAO(); cOrderDetailsDao.UpdateKitchenQuantity(orderDetails); } } } // parrentForm.scre return true; }
private bool CheckRawProduct(List<COrderDetails> tempOrderDetailsList) { CCategory3DAO cCategory3Dao = new CCategory3DAO(); FinishedRawProductListDAO finishedRawProductListDao = new FinishedRawProductListDAO(); string stockMessage = "Stock is unavailable "; bool isStockAvailable = true; KitchenStockDAO aKitchenStockDao = new KitchenStockDAO(); foreach (COrderDetails orderDetail in tempOrderDetailsList) { List<CFinishedRawProductList> finishedRawProductList = finishedRawProductListDao.GetFinishedRawProductListByProductID(Convert.ToInt32(orderDetail.ProductID)); foreach (CFinishedRawProductList finishedRawProduct in finishedRawProductList) { // CCategory3 cCategory3 = cCategory3Dao.GetAllCategory3ByCategory3ID(Convert.ToInt32(finishedRawProduct.RawProductID)); KitchenStock aKitchenStock = new KitchenStock(); // KitchenStockDAO aKitchenStockDao=new KitchenStockDAO(); aKitchenStock = aKitchenStockDao.GetStockByItemidFrominventory_kitchen_stock((int)finishedRawProduct.RawProductID); //List<CCategory3> aList = cCategory3Dao.GetAllCategory3(); //var temp = from acategory in aList where acategory.Category2ID == cCategory3.Category2ID select acategory; if (finishedRawProduct.Qnty * (orderDetail.OrderQuantity - orderDetail.KitchenQuantity) > aKitchenStock.Stocks) { stockMessage += "\n " + finishedRawProduct.RawProductName + ": Needed: " + finishedRawProduct.Qnty * (orderDetail.OrderQuantity - orderDetail.KitchenQuantity) + "\n " + " But Have: " + (aKitchenStock.Stocks); isStockAvailable = false; } } } if(!isStockAvailable) { CUserInfoDAO aUserInfoDao=new CUserInfoDAO(); CUserInfo aUserInfo=new CUserInfo(); aUserInfo = aUserInfoDao.GetUserInfoByUsername(RMSGlobal.LoginUserName); if (aUserInfo.Type == 0) { DialogResult dialogResult = MessageBox.Show("Do You Proceed", "Stock Alert", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { isStockAvailable = true; } else if (dialogResult == DialogResult.No) { } } } if (!isStockAvailable) { CMessageBox cMessageBox = new CMessageBox("Raw Product", stockMessage); cMessageBox.ShowDialog(); return false; } else { foreach (COrderDetails orderDetails in tempOrderDetailsList) { List<CFinishedRawProductList> finishedRawProductList = finishedRawProductListDao.GetFinishedRawProductListByProductID( Convert.ToInt32(orderDetails.ProductID)); foreach (CFinishedRawProductList finishedRawProduct in finishedRawProductList) { aKitchenStockDao.UpdateStock(Convert.ToInt32(finishedRawProduct.RawProductID), finishedRawProduct.Qnty * (orderDetails.OrderQuantity - orderDetails.KitchenQuantity)); } COrderDetailsDAO cOrderDetailsDao = new COrderDetailsDAO(); cOrderDetailsDao.UpdateKitchenQuantity(orderDetails); } } return true; }