private void Category3Button_Click(object sender, EventArgs e) { //get item qty CCategoryButton tempCategory3Button = (CCategoryButton)sender; RMSGlobal.m_sellinginvalue = tempCategory3Button.SellingQuantityorWeight; //Used to identify the product whether sold in quantity or weight int tempCategory3ID = tempCategory3Button.CategoryID; if (m_bItemDescriptionClicked) { string tempItemDescription = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3ID)[0]["description"].ToString(); if (!tempItemDescription.Equals("")) { CMessageBox tempMessageBox = new CMessageBox("Item Description", tempItemDescription); tempMessageBox.ShowDialog(); } else { CMessageBox tempMessageBox = new CMessageBox("Item Description", "No information available."); tempMessageBox.ShowDialog(); } m_bItemDescriptionClicked = false; return; } int tempFoodType = int.Parse(Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3ID)[0].GetParentRow(Program.initDataSet.Relations["category2_to_category3"])["cat2_type"].ToString()); DataGridView tempDataGridView = new DataGridView(); if (tempFoodType == 0) { tempDataGridView = g_BeverageDataGridView; } else { tempDataGridView = g_FoodDataGridView; } DataRow[] tempDataRowArray = Program.initDataSet.Tables["Category4"].Select("cat3_id = " + tempCategory3ID.ToString()); category4ButtonList.Clear(); COrderInfoDAO aOrderInfoDao = new COrderInfoDAO(); COrderInfo aCOrderInfo = aOrderInfoDao.GetOrderInfoByOrderID(orderID); if (tempDataRowArray.Length != 0) { foreach (DataRow tempDataRow in tempDataRowArray) { if (Int32.Parse(tempDataRow["status"].ToString()) == 0) { continue; } CCategoryButton tempCategoryButton = new CCategoryButton(); tempCategoryButton.CategoryID = int.Parse(tempDataRow["cat4_id"].ToString()); tempCategoryButton.CategoryOrder = int.Parse(tempDataRow["cat4_order"].ToString()); tempCategoryButton.CategoryLevel = 4; tempCategoryButton.Text = tempDataRow["cat4_name"].ToString(); tempCategoryButton.BackColor = tempCategory3Button.BackColor; category4ButtonList.Add(tempCategoryButton); } keyboardForm.Hide(); CCategory4Form tempCategory4Form = new CCategory4Form(tempCategory3ID, category4ButtonList, tempCategory3Button.Text); tempCategory4Form.ShowDialog(); CCategoryButton tempCategory4Button = CCategory4Form.m_cbResult; m_iSavedOrderedQty = CCategory4Form.ItemQTY; if (tempCategory4Button == null) { return; } else //insert into table and datagridview { DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category4"].Select("cat4_id = " + tempCategory4Button.CategoryID.ToString()); if (temp2DataRowArray.Length != 0) { //category4 + categpry3 string ItemName = temp2DataRowArray[0]["cat4_name"].ToString() + " " + tempCategory3Button.Text; string tableTypePrice = string.Empty; if (m_iType == m_cCommonConstants.TableType) { tableTypePrice = temp2DataRowArray[0]["table_price"].ToString(); } else if (m_iType == m_cCommonConstants.TakeAwayType) { tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString(); } int tempSearchResult = FindExistingItem(tempDataGridView, ItemName); // vat_included double vatRate = 0; bool vat_included = false; double vatAmountRate = 0; try { vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString()); vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString()); if (vat_included) { vatAmountRate = (Double.Parse(tableTypePrice) * vatRate) / 100; // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); } else { vatAmountRate = 0.00; } } catch (Exception ex) { } COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); if (tempSearchResult != -1) { int tempRowIndex = tempSearchResult; int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty; tempDataGridView.Rows[tempRowIndex].Cells[3].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02"); //update Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString()); tempOrderDetails.ProductID = tempCategory4Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory4Button.CategoryLevel; tempOrderDetails.OrderQuantity = qty; tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice); tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderDetails.OnlineItemSequenceNumber = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString()); tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[8].Value.ToString()); if (aCOrderInfo.VatComplementory) vatRate =vatAmountRate= 0; if (vat_included) { // tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * vatAmountRate; tempOrderDetails.VatTotal = qty * vatAmountRate; tempDataGridView.Rows[tempRowIndex].Cells[2].Value = qty * vatAmountRate; } else { tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100); } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { tempOrderManager.UpdateOrderDetails(tempOrderDetails); } else { tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails);//for online orders } } else { //Insert into Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = tempCategory4Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory4Button.CategoryLevel; tempOrderDetails.OrderQuantity = m_iSavedOrderedQty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks; tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice); // tempOrderDetails.Product_Name = temp2DataRowArray[0]["cat3_name"].ToString(); if (aCOrderInfo.VatComplementory) vatRate = 0; if (vat_included) { tempOrderDetails.VatTotal = 0; tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100); // tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * vatAmountRate; } else { tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100); } tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal; string category1ID = this.GetCategory1ID(tempOrderDetails.ProductID, tempOrderDetails.CategoryLevel); //Int32 cat1Order = this.GetCategory1OrderNumber(Convert.ToInt32(category1ID)); // Change by Mithu if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { tempOrderDetails = (COrderDetails)tempOrderManager.InsertOrderDetails(tempOrderDetails).Data; string[] tempDataGridViewRow = new string[] { ItemName, m_iSavedOrderedQty.ToString(), ((double)tempOrderDetails.VatTotal).ToString("F02"), ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"), tempCategory4Button.CategoryID.ToString(), "4", temp2DataRowArray[0]["cat4_rank"].ToString(), tempOrderDetails.OrderDetailsID.ToString(), "0", tempOrderDetails.UnitPrice.ToString("F2") }; tempDataGridView.Rows.Add(tempDataGridViewRow); } else //For online orders { tempOrderDetails.ItemName = ItemName; tempOrderDetails = (COrderDetails)tempOrderManager.InsertOnlineOrderDetails(tempOrderDetails).Data; string[] tempDataGridViewRow = new string[] { ItemName, m_iSavedOrderedQty.ToString(), ((double)tempOrderDetails.VatTotal).ToString("F02"), ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"), tempCategory4Button.CategoryID.ToString(), "4", tempOrderDetails.OnlineItemSequenceNumber.ToString(), tempOrderDetails.OrderDetailsID.ToString(),"0", tempOrderDetails.UnitPrice.ToString("F2") }; tempDataGridView.Rows.Add(tempDataGridViewRow); } } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) //If local orders are considered { this.ConvertRank(); } tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending); tempDataGridView.Update(); TotalAmountCalculation(); } } } else //There is no category4 { keyboardForm.Hide(); try { CCalculatorForm tempCalculatorForm = new CCalculatorForm("Order Quantity", "Item Quantity"); tempCalculatorForm.ShowDialog(); if (CCalculatorForm.inputResult.Equals("Cancel")) return; string str = CCalculatorForm.inputResult; str = (str == "") ? "1" : str; if (Int32.Parse(str) == 0) { CMessageBox tempMessageBox = new CMessageBox("Error", "Input invalid!"); tempMessageBox.ShowDialog(); return; } int tempOrderedQty = Int32.Parse(str); m_iSavedOrderedQty = tempOrderedQty; } catch (Exception exp) { MessageBox.Show(exp.Message, RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } DataGridViewRow tempDataGridViewRow = new DataGridViewRow(); tempDataGridViewRow.CreateCells(tempDataGridView); DataRow[] temp2DataRowArray = Program.initDataSet.Tables["Category3"].Select("cat3_id = " + tempCategory3Button.CategoryID.ToString()); if (temp2DataRowArray.Length != 0) { string tableTypePrice = string.Empty; if (m_iType == m_cCommonConstants.TableType) { tableTypePrice = temp2DataRowArray[0]["table_price"].ToString(); } else if (m_iType == m_cCommonConstants.TakeAwayType) { tableTypePrice = temp2DataRowArray[0]["tw_price"].ToString(); } // vat_included double vatRate = 0; bool vat_included = false; double vatAmountRate = 0; try { vatRate = Convert.ToDouble(temp2DataRowArray[0]["vat_Rate"].ToString()); vat_included = Convert.ToBoolean(temp2DataRowArray[0]["vat_included"].ToString()); if (vat_included) { vatAmountRate = (Double.Parse(tableTypePrice) * vatRate) / 100; // tableTypePrice = (Double.Parse(tableTypePrice) - vatAmountRate).ToString(); tableTypePrice = Convert.ToDouble(tableTypePrice).ToString(); } else { vatAmountRate = 0.00; } } catch (Exception ex) { } COrderManager tempOrderManager = new COrderManager(); COrderDetails tempOrderDetails = new COrderDetails(); int tempResult = FindExistingItem(tempDataGridView, temp2DataRowArray[0]["cat3_name"].ToString()); if (tempResult != -1) { //update Order_details table int tempRowIndex = tempResult; int qty = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[1].Value.ToString()) + m_iSavedOrderedQty; tempDataGridView.Rows[tempRowIndex].Cells[1].Value = qty; tempDataGridView.Rows[tempRowIndex].Cells[3].Value = ((double)(Double.Parse(tableTypePrice) * qty)).ToString("F02"); tempOrderDetails.OrderDetailsID = Int64.Parse(tempDataGridView.Rows[tempRowIndex].Cells[7].Value.ToString()); tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = tempCategory3Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory3Button.CategoryLevel; tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice); tempOrderDetails.OrderQuantity = qty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderDetails.OnlineItemSequenceNumber = Convert.ToInt64("0" + tempDataGridView.Rows[tempRowIndex].Cells[6].Value.ToString()); tempOrderDetails.PrintedQuantity = int.Parse(tempDataGridView.Rows[tempRowIndex].Cells[8].Value.ToString()); if (aCOrderInfo.VatComplementory) vatAmountRate = 0; if (vat_included) { tempOrderDetails.VatTotal = qty * vatAmountRate; tempDataGridView.Rows[tempRowIndex].Cells[2].Value = tempOrderDetails.VatTotal; } else { tempOrderDetails.VatTotal = 0.00; } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { tempOrderManager.UpdateOrderDetails(tempOrderDetails); } else { tempOrderManager.UpdateOnlineOrderDetails(tempOrderDetails); } } else { //Insert into Order_details table tempOrderDetails.OrderID = orderID; tempOrderDetails.ProductID = tempCategory3Button.CategoryID; tempOrderDetails.CategoryLevel = tempCategory3Button.CategoryLevel; tempOrderDetails.UnitPrice = Convert.ToDouble(tableTypePrice); tempOrderDetails.OrderQuantity = m_iSavedOrderedQty; tempOrderDetails.OrderAmount = tempOrderDetails.OrderQuantity * Double.Parse(tableTypePrice); tempOrderDetails.OrderFoodType = tempFoodType == 1 ? ("Food") : ("Nonfood"); tempOrderDetails.ItemOrderTime = DateTime.Now.Ticks; tempOrderDetails.Product_Name = temp2DataRowArray[0]["cat3_name"].ToString(); tempOrderDetails.UOM = temp2DataRowArray[0]["uom"].ToString(); tempOrderDetails.Product_Type = temp2DataRowArray[0]["productType"].ToString(); if (aCOrderInfo.VatComplementory) vatRate = vatAmountRate = 0; try { if (vat_included) { tempOrderDetails.VatTotal = 0; tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100); // tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * vatAmountRate; } else { tempOrderDetails.VatTotal = tempOrderDetails.OrderAmount * (vatRate / 100); } } catch { } try { tempOrderDetails.Amount_with_vat = tempOrderDetails.OrderAmount + tempOrderDetails.VatTotal; } catch { } string category1ID = this.GetCategory1ID(tempOrderDetails.ProductID, tempOrderDetails.CategoryLevel); Int32 cat1Order = this.GetCategory1OrderNumber(Convert.ToInt32(category1ID)); if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { tempOrderDetails = (COrderDetails)tempOrderManager.InsertOrderDetails(tempOrderDetails).Data; string[] temp2DataGridViewRow = new string[] { temp2DataRowArray[0]["cat3_name"].ToString(), m_iSavedOrderedQty.ToString(), tempOrderDetails.VatTotal.ToString("F2"), ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"), tempCategory3Button.CategoryID.ToString(), "3", temp2DataRowArray[0]["cat3_rank"].ToString(), tempOrderDetails.OrderDetailsID.ToString(),"0", tempOrderDetails.UnitPrice.ToString("F2") }; tempDataGridView.Rows.Add(temp2DataGridViewRow); } else { tempOrderDetails.ItemName = temp2DataRowArray[0]["cat3_name"].ToString(); tempOrderDetails = (COrderDetails)tempOrderManager.InsertOnlineOrderDetails(tempOrderDetails).Data; string[] temp2DataGridViewRow = new string[] {temp2DataRowArray[0]["cat3_name"].ToString(), m_iSavedOrderedQty.ToString(), tempOrderDetails.VatTotal.ToString(), ((double)(Double.Parse(tableTypePrice)*m_iSavedOrderedQty)).ToString("F02"), tempCategory3Button.CategoryID.ToString(), "3", tempOrderDetails.OnlineItemSequenceNumber.ToString(),//For online order sequence number is category rank. tempOrderDetails.OrderDetailsID.ToString(),"0", //0 For first time. tempOrderDetails.UnitPrice.ToString("F2") }; tempDataGridView.Rows.Add(temp2DataGridViewRow); } } if (m_orderUserName.Replace(" ", "").ToUpper() != "Web User".Replace(" ", "").ToUpper()) { this.ConvertRank(); } tempDataGridView.Sort(tempDataGridView.Columns[5], ListSortDirection.Ascending); try { tempDataGridView.Update(); } catch { } TotalAmountCalculation(); } } g_FoodDataGridView.ClearSelection(); g_BeverageDataGridView.ClearSelection(); m_iSavedOrderedQty = 1; keyboardForm.Hide(); this.SetPrintedItemBackColor(); }
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); }
private void delivaryfromkitchneButton_Click(object sender, EventArgs e) { string sr = "DelivaryFromKitchen"; COrderInfoDAO aCOrderInfoDao=new COrderInfoDAO(); string ss= aCOrderInfoDao.UpdateOrderInfoDAOForDelivary(sr,(Int32)orderID); MessageBox.Show(ss); }
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(); }
public void VoidTableDataGridView_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (VoidTableDataGridView.Columns[e.ColumnIndex].Name == "ActionButtonColumn" && e.RowIndex >= 0 && VoidTableDataGridView.Rows[e.RowIndex].Cells["OrderIDColumn"].Value != null) { DialogResult tempDialogResult = MessageBox.Show("Are you sure you want to void this order?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (tempDialogResult.Equals(DialogResult.No)) return; //ItemInfo c = new ItemInfo(); //c.ShowDialog(); //c.Close(); //DialogResult tempDialogResult1 = MessageBox.Show("Ok Done", "Confirm", MessageBoxButtons.OK, MessageBoxIcon.Question); //if (tempDialogResult1.Equals(DialogResult.No)) return; else { String tempOldOrderID = VoidTableDataGridView.Rows[e.RowIndex].Cells["OrderIDColumn"].Value.ToString(); int tempOldTableNumber = int.Parse(VoidTableDataGridView.Rows[e.RowIndex].Cells["TableNumberColumn"].Value.ToString()); String tempOldTableType = VoidTableDataGridView.Rows[e.RowIndex].Cells["TableTypeColumn"].Value.ToString(); // add by mithu OrderVoid aOrderVoid=new OrderVoid(); aOrderVoid.OrderId = Convert.ToInt32(VoidTableDataGridView.Rows[e.RowIndex].Cells["OrderIDColumn"].Value); COrderDetailsDAO aDao = new COrderDetailsDAO(); List<COrderDetails> aList = new List<COrderDetails>(); CResult aResult = new CResult(); aResult = aDao.OrderDetailsGetByOrderID(aOrderVoid.OrderId); aList = (List<COrderDetails>)aResult.Data; aOrderVoid.TableNumber = tempOldTableNumber; aOrderVoid.RemoverId = RMS.RMSGlobal.m_iLoginUserID; aOrderVoid.VoidDate = DateTime.Now; COrderDetailsDAO aCOrderDetailsDAO=new COrderDetailsDAO(); aOrderVoid.OrderAmount = aCOrderDetailsDAO.GetOrderAmount(aOrderVoid.OrderId); COrderInfo aInfo=new COrderInfo(); COrderInfoDAO aCOrderInfoDao=new COrderInfoDAO(); aInfo = aCOrderInfoDao.GetOrderInfoByOrderID(aOrderVoid.OrderId); aOrderVoid.OrderDate = aInfo.OrderTime; aOrderVoid.Creator_Id = aInfo.UserID; ReasonForm aReasonForm=new ReasonForm(); aReasonForm.ShowDialog(); aOrderVoid.Reason = aReasonForm.reason; OrderVoidDAO aOrderVoidDao=new OrderVoidDAO(); aOrderVoidDao.InsertOrderForVoid(aOrderVoid); DataSet tempStockDataSet = new DataSet(); tempStockDataSet.ReadXml("Config/StockSetting.xml"); bool isAllowedToOrder = Convert.ToBoolean(tempStockDataSet.Tables[0].Rows[0]["AllowedtoOrder"].ToString()); if (!isAllowedToOrder) { UpdateRawMaterial(aList); } COrderManager tempVoidTableManager = new COrderManager(); CResult tempResult = tempVoidTableManager.UpdateForVoidTable(tempOldOrderID, tempOldTableNumber, tempOldTableType, false); if (tempResult.IsSuccess) { this.PopulateVoidTableDataGridView(); } } } } catch (Exception ex) { } }