protected void btnCheckout_Click(object sender, EventArgs e) { if (ApplicationSession.QRcode == "") { Response.Redirect("Checkout.aspx"); } else { MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName); CSalesMaster sm = ApplicationSession.SalesMaster; if (sm.IsEmpty()) { sm.CreateNewSales(ApplicationSession.StoreID, ApplicationSession.OutletID, ApplicationSession.SalesType.ID, 1, "", 0, (int)CSalesMaster.EFlagStatus.STATUS_ORDER, 0, "", "", 0, ApplicationSession.TableNo, false); if (sm.InsertRecord(conn)) { sm.SetSalesMasterID(sm.ID); } else { //kasih message error } } sm.Recalculate(ApplicationSession.SalesType); sm.UpdateRecord_SalesAmounts(conn); List <CSalesDetail> lst = sm.GetChildrenToBeSent; if (lst.Count > 0) { foreach (CSalesDetail sd in lst) { if (sd.isEmpty) { sd.SalesMasterID = sm.ID; sd.InsertRecord(conn, true); } else { sd.UpdateRecord_Send(conn); } } ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalConfirmed", "$(document).ready(function () {$('#ModalConfirmed').modal();});", true); } else { //kasih message no record } } }
protected void SalesType_Clicked(object sender, EventArgs e) { HtmlAnchor a = (HtmlAnchor)sender; //ListViewItem item0 = (ListViewItem)a.Parent.Parent; HiddenField hf0 = (HiddenField)a.FindControl("hf_STobject"); CSalesType st = JsonConvert.DeserializeObject <CSalesType>(hf0.Value); if (!st.isEmpty) { MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName); st.FetchListOfOrderPromos(conn, ApplicationSession.StoreID, ApplicationSession.OutletID, CSetting.GetFlagOfToday()); ApplicationSession.SalesType = st; if (st.IsCatering()) { Response.Redirect("CategoryPage.aspx"); } else { if (st.IsType(CSalesType.EFlagType.TYPE_DINEIN)) { //CreateOrder: //>>input: CoverAmt & TableNo CSalesMaster sm = new CSalesMaster(); sm.CreateNewSales(ApplicationSession.StoreID, ApplicationSession.OutletID, ApplicationSession.SalesType.ID, 1, "", 0, (int)CSalesMaster.EFlagStatus.STATUS_ORDER, 0, "", "", 0, "", true); if (sm.InsertRecord(conn)) { string str = "MainMenu.aspx?qr=010101&sm=" + sm.ID.ToString(); Response.Redirect(str); //System.Drawing.Bitmap imgQR = CMain.CreateQRCode(str); //Response.ContentType = "Image/jpeg"; //imgQR.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); //imgQR.Save(Server.MapPath("~/images/QRcode.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg); //imgQRcode.ImageUrl = "~/images/QRcode.jpg"; //aOrderNo.InnerText = str; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalConfirmed", "$(document).ready(function () {$('#ModalConfirmed').modal();});", true); //Master.DisplayModalMessageBox("testing..."); } } else { Response.Redirect("ItemGroupPage.aspx"); } } } }
protected void btnCheckout_Click(object sender, EventArgs e) { SalesDetailCollection col = ApplicationSession.SalesMaster.CollectionSalesDetail(); if (col.Count == 0) { Master.DisplayModalMessageBox("Your cart is empty"); } else { string s = btnCheckout.Attributes["PayModeID"]; bool isNumeric = int.TryParse(btnCheckout.Attributes["PayModeID"], out int iPayModeID); if (isNumeric) { CSalesMaster sm = new CSalesMaster(); sm.CreateNewSales(ApplicationSession.StoreID, ApplicationSession.OutletID, ApplicationSession.SalesType.ID, 1, "", ApplicationSession.member.ID, (int)CSalesMaster.EFlagStatus.STATUS_ORDER, iPayModeID, btnCheckout.Attributes["PayModeName"], "", 0, ApplicationSession.SalesMaster.TableNo, false); if (ApplicationSession.SalesType.IsCatering()) { sm.FromDate = ApplicationSession.category.OrderDate; } try { MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName); if (sm.InsertRecord(conn)) { sm.SetSalesMasterID(sm.ID); sm.InsertChildrenRecords(conn, false); aOrderNo.InnerText = sm.Number; aOrderNo.Attributes["smid"] = sm.ID.ToString(); ApplicationSession.SalesMaster.RefreshCollection(); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ModalConfirmed", "$(document).ready(function () {$('#ModalConfirmed').modal();});", true); } else { //lblMessage.Text = "Fail to save order. Please try again"; } } catch { //lblMessage.Text = "Fail to save order. Please try again"; } } } }