protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string strID = Request.QueryString["id"];
         if (strID == null)
         {
             if (!ApplicationSession.SalesMaster.IsEmpty())
             {
                 MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName);
                 CSalesMaster    sm   = new CSalesMaster(ApplicationSession.SalesMaster.ID, conn);
                 if (!sm.IsEmpty())
                 {
                     DisplayInfo(sm, conn);
                 }
             }
         }
         else
         {
             bool isNumeric = int.TryParse(strID, out int iID);
             if (isNumeric)
             {
                 MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName);
                 CSalesMaster    sm   = new CSalesMaster(iID, conn);
                 if (!sm.IsEmpty())
                 {
                     DisplayInfo(sm, conn);
                 }
             }
         }
     }
 }
Beispiel #2
0
        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
                }
            }
        }
        private void InitFromTableNo(string sTableNo)
        {
            MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName);

            CSalesMaster sm = new CSalesMaster(ApplicationSession.StoreID, ApplicationSession.OutletID, sTableNo, conn);

            if (!sm.IsEmpty())
            {
                sm.RetrieveCollection(conn);
            }
            ApplicationSession.SalesMaster = sm;
            ApplicationSession.TableNo     = sTableNo;
        }
Beispiel #4
0
        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");
                    }
                }
            }
        }
Beispiel #5
0
        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";
                    }
                }
            }
        }
        private void DisplayInfo(CSalesMaster sm, MySqlConnection conn)
        {
            lblOrderNo.InnerText = sm.Number;
            lblTransDate.Text    = sm.TransDate_ToString;
            //lblDelMode.Text = sm.DelModeName;

            lblPmtMode.Text = sm.PmtModeName;
            //lblPmtNo.Text = "";
            //lblPmtDate.Text = "";

            string sBillAddr = "";

            if (sm.LinkID > 0)
            {
                CPayment pmt = CSalesMaster.FetchPaymentRecord(conn, sm.LinkID);
                if (!pmt.isEmpty)
                {
                    lblPmtMode.Text = pmt.PaymentName;
                    //lblPmtNo.Text = pmt.Number;
                    //lblPmtDate.Text = pmt.TransDate_ToString;
                }
            }
            lblBillAddr.Text = sBillAddr;
            //lblDelAddr.Text = sm.Address;

            SalesDetailCollection col = sm.CollectionSalesDetail(true, conn);

            lvwOrder.DataSource = col;
            lvwOrder.DataBind();

            //lblDelFee.Text = sm.Charge_ToString;
            lblSubtotal.Text  = sm.Subtotal_ToString;
            lblCharge.Text    = "Charge";
            lblChargeAmt.Text = sm.Charge_ToString;
            lblTax.Text       = "Tax";
            lblTaxAmt.Text    = sm.Tax_ToString;
            lblTotal.Text     = sm.SalesTotal_ToString;
            //lblNotes.Text = sm.Notes;

            // List<CDeliveryLog> lst = CSalesMaster.ListOfDeliveryLogs(conn, sm.ID);
            //lvwDelLog.DataSource = lst;
            //lvwDelLog.DataBind();
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnCheckout.Attributes["PayModeID"]   = "";
                btnCheckout.Attributes["PayModeName"] = "";

                CSalesMaster    sm   = ApplicationSession.SalesMaster;
                MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName);
                lvwOrder.DataSource = sm.CollectionSalesDetail(true, conn);
                lvwOrder.DataBind();

                lblSubtotal.Text      = sm.Subtotal_ToString;
                lblTaxName.Text       = (ApplicationSession.SalesType.TaxName == "") ? "Tax" : ApplicationSession.SalesType.TaxName;
                lblTaxAmt.Text        = sm.Tax_ToString;
                lblTotal.Text         = sm.SalesTotal_ToString;
                btnCheckout.InnerText = "PAY ";
                checkoutAmt.InnerText = sm.SalesTotal_ToString;
            }
        }
        private bool InitFromSMID(string sSMID)
        {
            bool bln       = false;
            bool isNumeric = int.TryParse(sSMID, out int iSMID);

            if (isNumeric)
            {
                MySqlConnection conn = CMain.GetConnection(ApplicationSession.DBName);

                CSalesMaster sm = new CSalesMaster(iSMID, conn);
                if (!sm.IsEmpty())
                {
                    sm.RetrieveCollection(conn);
                    ApplicationSession.SalesMaster = sm;
                    bln = true;
                }
            }
            else
            {
                MessageBox.Show("Sales Record is not found");
            }

            return(bln);
        }