コード例 #1
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
                }
            }
        }
コード例 #2
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";
                    }
                }
            }
        }