public void InsertOrderForVoid(OrderVoid aOrderVoid) { try { this.OpenConnection(); string sqlCommand = string.Format(SqlQueries.GetQuery(Query.InsertOrderForVoid),aOrderVoid.OrderId,aOrderVoid.Creator_Id,aOrderVoid.RemoverId, aOrderVoid.OrderAmount,aOrderVoid.OrderDate,aOrderVoid.VoidDate,aOrderVoid.TableNumber,aOrderVoid.Reason); this.ExecuteNonQuery(sqlCommand); } catch (Exception ex) { Logger.Write("Exception : " + ex + " in AddNewOnlineProducts()", LogLevel.Error, "Database"); throw new Exception("Exception occure at AddNewOnlineProducts()", ex); } finally { this.CloseConnection(); } }
private OrderVoid ordervoidReader(IDataReader oReader) { OrderVoid oItem =new OrderVoid(); try { oItem.OrderId = Convert.ToInt32(oReader["order_id"]); } catch (Exception) { } try { oItem.CreatorName = (oReader["creatorname"]).ToString(); } catch (Exception) { } try { oItem.RemoverName = (oReader["removername"]).ToString(); } catch (Exception) { } try { oItem.OrderAmount = Convert.ToDouble(oReader["order_amount"]); } catch (Exception) { } try { oItem.TableNumber = Convert.ToInt32(oReader["table_number"]); } catch (Exception) { } try { oItem.OrderDate = Convert.ToDateTime(oReader["order_date"]); } catch (Exception) { } try { oItem.VoidDate = Convert.ToDateTime(oReader["void_date"]); } catch (Exception) { } try { oItem.Reason = (oReader["reason"]).ToString(); } catch (Exception) { } return oItem; }
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) { } }