コード例 #1
0
        public Ent_GuestAddress SelectGuestAddress(int ID)
        {
            Ent_GuestAddress ent = new Ent_GuestAddress();

            try
            {
                Dal_Guest dal = new Dal_Guest();
                ent = dal.SelectGuestAddress(ID);
                return(ent);
            }
            catch
            {
                return(ent);
            }
        }
コード例 #2
0
        public int UpdateAddress(Ent_GuestAddress entGuest, SafeTransaction trans)
        {
            int dataResult = 0;

            try
            {
                Dal_Guest dal = new Dal_Guest();
                dataResult = dal.UpdateAddress(entGuest, trans);
                return(dataResult);
            }
            catch
            {
                return(0);
            }
        }
コード例 #3
0
        public int UpdateAddress(Ent_GuestAddress ent, SafeTransaction trans)
        {
            int dataresult = 0;

            try
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                using (SqlCommand cmd = new SqlCommand("EC_UpdateAddress", trans.DatabaseConnection, trans.Transaction))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Address_ID", ent.Address_ID));
                    cmd.Parameters.Add(new SqlParameter("@Guest_ID", ent.Guest_ID));
                    cmd.Parameters.Add(new SqlParameter("@First_Name", ent.First_Name));
                    cmd.Parameters.Add(new SqlParameter("@Last_Name", ent.Last_Name));
                    cmd.Parameters.Add(new SqlParameter("@Guest_Address1", ent.Guest_Address1));
                    cmd.Parameters.Add(new SqlParameter("@Guest_Address2", ent.Guest_Address2));
                    cmd.Parameters.Add(new SqlParameter("@Guest_Town", ent.Guest_Town));
                    cmd.Parameters.Add(new SqlParameter("@Guest_State", ent.Guest_State));
                    cmd.Parameters.Add(new SqlParameter("@Guest_Country", ent.Guest_Country));
                    cmd.Parameters.Add(new SqlParameter("@Address_Type", ent.Address_Type));
                    cmd.Parameters.Add(new SqlParameter("@Address_Default", ent.Address_Default));
                    try
                    {
                        dataresult = Convert.ToInt32(cmd.ExecuteScalar());
                        if (dataresult > 0)
                        {
                            cmd.Dispose();
                        }
                    }
                    catch (Exception ex)
                    {
                        dataresult = -2;
                        InsertException(ex.Message, "UpdateAddress", ent.Guest_ID);
                    }
                }
            }
            catch (Exception e)
            {
                dataresult = -2;
            }
            finally { con.Close(); }
            return(dataresult);
        }
コード例 #4
0
        public List <Ent_GuestAddress> SelectGuestAddressList(int ID)
        {
            List <Ent_GuestAddress> list = new List <Ent_GuestAddress>();

            Ent_GuestAddress ent = new Ent_GuestAddress();

            try
            {
                string query = "select * from EC_GuestAddress where Guest_ID=" + ID;
                using (SqlCommand cmd = new SqlCommand(query, con))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    IDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        ent                 = new Ent_GuestAddress();
                        ent.Address_ID      = Convert.ToInt32(dr["Address_ID"]);
                        ent.Guest_ID        = Convert.ToInt32(dr["Guest_ID"]);
                        ent.First_Name      = Convert.ToString(dr["First_Name"]);
                        ent.Last_Name       = Convert.ToString(dr["Last_Name"]);
                        ent.Guest_Address1  = Convert.ToString(dr["Guest_Address1"]);
                        ent.Guest_Address2  = Convert.ToString(dr["Guest_Address2"]);
                        ent.Guest_Town      = Convert.ToString(dr["Guest_Town"]);
                        ent.Guest_State     = Convert.ToString(dr["Guest_State"]);
                        ent.Guest_Country   = Convert.ToString(dr["Guest_Country"]);
                        ent.Address_Type    = Convert.ToString(dr["Address_Type"]);
                        ent.Address_Default = Convert.ToInt32(dr["Address_Default"]);
                        list.Add(ent);
                    }
                }
            }
            catch (Exception ex)
            {
                InsertException(ex.Message, "SelectGuestAddressList", ID);
            }
            finally
            {
                con.Close();
            }
            return(list);
        }
コード例 #5
0
        public ActionResult MyAccount()
        {
            HttpCookie Guest_ID = Request.Cookies["Guest_ID"];
            int        GuestID  = Guest_ID != null?Convert.ToInt32(Guest_ID.Value.Split('=')[1]) : 0;

            List <Ent_Order>        list        = new List <Ent_Order>();
            List <Ent_GuestAddress> AddressList = new List <Ent_GuestAddress>();
            Ent_Guest entGuest = new Ent_Guest();

            if (GuestID != 0)
            {
                list        = balOrder.SelectGuestOrder(GuestID);
                entGuest    = balGuest.SelectGuestDetails(GuestID);
                AddressList = balGuest.SelectGuestAddressList(GuestID);
            }

            ViewBag.OrderList = list;
            Ent_GuestAddress entHome  = new Ent_GuestAddress();
            Ent_GuestAddress entWork  = new Ent_GuestAddress();
            Ent_GuestAddress entOther = new Ent_GuestAddress();
            var home  = AddressList.Where(x => x.Address_Type == "Home").FirstOrDefault();
            var work  = AddressList.Where(x => x.Address_Type == "Work").FirstOrDefault();
            var other = AddressList.Where(x => x.Address_Type == "Other").FirstOrDefault();

            if (home != null)
            {
                entHome = home;
            }
            if (work != null)
            {
                entWork = work;
            }
            if (other != null)
            {
                entOther = other;
            }


            ViewBag.HomeAddress  = entHome;
            ViewBag.WorkAddress  = entWork;
            ViewBag.OtherAddress = entOther;
            return(View(entGuest));
        }
コード例 #6
0
        public int UpdateAddress(Ent_GuestAddress model)
        {
            int        result   = 0;
            HttpCookie Guest_ID = Request.Cookies["Guest_ID"];
            int        GuestID  = Guest_ID != null?Convert.ToInt32(Guest_ID.Value.Split('=')[1]) : 0;

            model.Guest_ID = GuestID;
            SafeTransaction trans = new SafeTransaction();

            result = balGuest.UpdateAddress(model, trans);
            if (result > 0)
            {
                trans.Commit();
            }
            else
            {
                trans.Rollback();
            }
            return(result);
        }
コード例 #7
0
        public int SaveOrder(Ent_Order model)
        {
            SafeTransaction trans      = new SafeTransaction();
            DateTime        indianTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
            DateTime        indiTime   = Convert.ToDateTime(indianTime.ToString("yyyy-MM-dd h:m:s"));

            model.Created_Date = indiTime;

            HttpCookie Guest_ID = Request.Cookies["Guest_ID"];
            string     GuestID  = Guest_ID != null?Guest_ID.Value.Split('=')[1] : "";

            if (!string.IsNullOrEmpty(GuestID))
            {
                model.Guest_ID = Convert.ToInt32(GuestID);
                Ent_GuestAddress entAddress = new Ent_GuestAddress();
                entAddress = balguest.SelectGuestAddress(Convert.ToInt32(GuestID));
                if (entAddress.Guest_Address1 != "")
                {
                    model.Billing_FirstName = entAddress.First_Name;
                    model.Billing_LastName  = entAddress.Last_Name;
                    model.Billing_Address1  = entAddress.Guest_Address1;
                    model.Billing_Address2  = entAddress.Guest_Address2;
                    model.Billing_State     = entAddress.Guest_State;
                    model.Billing_Town      = entAddress.Guest_Town;
                    model.Billing_Country   = entAddress.Guest_Country;
                }
                else
                {
                    model.Billing_FirstName = model.Shipping_FirstName;
                    model.Billing_LastName  = model.Shipping_LastName;
                    model.Billing_Address1  = model.Shipping_Address1;
                    model.Billing_Address2  = model.Shipping_Address2;
                    model.Billing_State     = model.Shipping_State;
                    model.Billing_Town      = model.Shipping_Town;
                    model.Billing_Country   = model.Shipping_Country;
                }
            }
            else
            {
                model.Guest_ID          = 0;
                model.Billing_FirstName = model.Shipping_FirstName;
                model.Billing_LastName  = model.Shipping_LastName;
                model.Billing_Address1  = model.Shipping_Address1;
                model.Billing_Address2  = model.Shipping_Address2;
                model.Billing_State     = model.Shipping_State;
                model.Billing_Town      = model.Shipping_Town;
                model.Billing_Country   = model.Shipping_Country;
            }

            model.Billing_Email = model.Shipping_Email;
            model.Billing_Phone = model.Shipping_Phone;

            model.Order_SubTotal   = Convert.ToDouble(Session["SubTotal"]);
            model.Order_Shipping   = 0;
            model.Order_Total      = Convert.ToDouble(Session["Total"]);
            model.OrderDetailsList = (List <Ent_OrderDetail>)Session["Cart"];
            int i = balOrder.SaveOrder(model, trans);

            if (i > 0)
            {
                trans.Commit();
                if (model.Payment_COD == 1)
                {
                    string body = string.Empty; var lnkHref = "";
                    if (string.IsNullOrEmpty(GuestID))
                    {
                        lnkHref = "<a href='https://acsadmin.atintellilabs.live/" + @Url.Action("TrackOrder", "Order", new { Order_ID = i }) + "' target = '_blank' style = 'color: #fc7ca0;' > here </ a >";
                    }
                    else
                    {
                        lnkHref = "<a href='https://acsadmin.atintellilabs.live/" + @Url.Action("Register", "Login") + "' target = '_blank' style = 'color: #fc7ca0;' > here </ a >";
                    }

                    using (StreamReader reader = new StreamReader(Server.MapPath("~/OrderConfirmation.html")))
                    {
                        body = reader.ReadToEnd();
                    }
                    body = body.Replace("{Url}", lnkHref);

                    Email em = new Email();
                    em.SendConfirmationMail(i, body, "Order Confirmation");

                    if (!string.IsNullOrEmpty(GuestID))
                    {
                        SafeTransaction transac = new SafeTransaction();
                        int             result  = balOrder.DeleteCart(0, Convert.ToInt32(GuestID), transac);
                        if (result > 0)
                        {
                            transac.Commit();
                        }
                        else
                        {
                            transac.Rollback();
                        }
                    }
                    Session["Cart"]     = null;
                    Session["Total"]    = null;
                    Session["SubTotal"] = null;
                    Session["Shipping"] = null;
                }
            }
            else
            {
                trans.Rollback();
            }

            return(i);
        }