Exemplo n.º 1
0
        public int UpdateOrderStatus(Ent_Order ent)
        {
            int             result     = 0;
            SafeTransaction trans      = new SafeTransaction();
            DateTime        indianTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
            DateTime        indiTime   = Convert.ToDateTime(indianTime.ToString("yyyy-MM-dd h:m:s"));

            ent.Created_Date = indiTime;
            result           = balOrder.UpdateOrderStatus(ent, trans);
            if (result > 0)
            {
                trans.Commit();
                string body = string.Empty; var lnkHref = "";
                if (ent.Is_Active == 2)
                {
                    if (ent.Guest_ID == 0)
                    {
                        lnkHref = "<a href='https://acsadmin.atintellilabs.live/" + @Url.Action("TrackOrder", "Order", new { Order_ID = ent.Order_ID }) + "' 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("~/Shipping.html")))
                    {
                        body = reader.ReadToEnd();
                    }
                    body = body.Replace("{Url}", lnkHref);

                    Email em = new Email();
                    em.SendConfirmationMail(ent.Order_ID, body, "Order Shipped");
                }
                else if (ent.Is_Active == 3)
                {
                    if (ent.Guest_ID == 0)
                    {
                        lnkHref = "<a href='https://acsadmin.atintellilabs.live/" + @Url.Action("TrackOrder", "Order", new { Order_ID = ent.Order_ID }) + "' 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("~/Delivered.html")))
                    {
                        body = reader.ReadToEnd();
                    }
                    body = body.Replace("{Url}", lnkHref);

                    Email eml = new Email();
                    eml.SendConfirmationMail(ent.Order_ID, body, "Order Delivered");
                }
            }
            else
            {
                trans.Rollback();
            }
            return(result);
        }
Exemplo n.º 2
0
        public int SendConfirmationMail(int Order_ID, string body, string subject)
        {
            Ent_Order ent = new Ent_Order();

            ent = balOrder.SelectOrder(Order_ID);

            body = body.Replace("{{ReceivedDate}}", ent.Received_Date);
            body = body.Replace("{{ShippedDate}}", ent.Shipped_Date);
            body = body.Replace("{{DeliveredDate}}", ent.Delivered_Date);
            body = body.Replace("{OrderID}", Order_ID.ToString());
            body = body.Replace("{Total}", ent.Order_Total.ToString());
            body = body.Replace("{Billing_FirstName}", ent.Billing_FirstName);
            body = body.Replace("{Billing_LastName}", ent.Billing_LastName);
            body = body.Replace("{Billing_Address1}", ent.Billing_Address1);
            body = body.Replace("{Billing_Address2}", ent.Billing_Address2);
            body = body.Replace("{Billing_Country}", ent.Billing_Country);
            body = body.Replace("{Billing_Phone}", ent.Billing_Phone);
            body = body.Replace("{Shipping_FirstName}", ent.Shipping_FirstName);
            body = body.Replace("{Shipping_LastName}", ent.Shipping_LastName);
            body = body.Replace("{Shipping_Address1}", ent.Shipping_Address1);
            body = body.Replace("{Shipping_Address2}", ent.Shipping_Address2);
            body = body.Replace("{Shipping_Country}", ent.Shipping_Country);
            body = body.Replace("{Shipping_Phone}", ent.Shipping_Phone);

            int i = SendMail(body, ent.Billing_Email, subject);

            return(i);
        }
Exemplo n.º 3
0
        public int UpdatePayment(Ent_Order entOrder)
        {
            SafeTransaction trans    = new SafeTransaction();
            HttpCookie      Guest_ID = Request.Cookies["Guest_ID"];
            int             ID       = Guest_ID != null?Convert.ToInt32(Guest_ID.Value.Split('=')[1]) : 0;

            entOrder.Guest_ID = ID;
            int i = balOrder.UpdatePayment(entOrder, trans);

            if (i > 0)
            {
                trans.Commit();
                if (entOrder.Payment_Status == "CAPTURED")
                {
                    string body = string.Empty; var lnkHref = "";
                    if (ID == 0)
                    {
                        lnkHref = "<a href='https://acsadmin.atintellilabs.live/" + @Url.Action("TrackOrder", "Order", new { Order_ID = entOrder.Order_ID }) + "' 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(entOrder.Order_ID, body, "Order Confirmation");
                    if (ID != 0)
                    {
                        SafeTransaction transac = new SafeTransaction();
                        int             result  = balOrder.DeleteCart(0, ID, 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);
        }
Exemplo n.º 4
0
        public ActionResult Orders()
        {
            int OrderID = Request.QueryString["OrderID"] != null?Convert.ToInt32(Request.QueryString["OrderID"]) : 0;

            Ent_Order entOrder = new Ent_Order();

            entOrder = balOrder.SelectOrder(OrderID);
            List <Ent_OrderDetail> OrderList = new List <Ent_OrderDetail>();

            OrderList         = balOrder.SelectOrderDetails(OrderID);
            ViewBag.OrderList = OrderList;
            return(View(entOrder));
        }
Exemplo n.º 5
0
        public int UpdatePayment(Ent_Order entOrder, SafeTransaction trans)
        {
            int dataResult = 0;

            try
            {
                Dal_Order dal = new Dal_Order();
                dataResult = dal.UpdatePayment(entOrder, trans);
                return(dataResult);
            }
            catch
            {
                return(0);
            }
        }
Exemplo n.º 6
0
        public int SaveOrder(Ent_Order ent, SafeTransaction trans)
        {
            int dataResult = 0;

            try
            {
                Dal_Order dal = new Dal_Order();
                dataResult = dal.SaveOrder(ent, trans);
                return(dataResult);
            }
            catch
            {
                return(0);
            }
        }
Exemplo n.º 7
0
        public Ent_Order SelectOrder(int OrderID)
        {
            Ent_Order ent = new Ent_Order();

            try
            {
                Dal_Order dal = new Dal_Order();
                ent = dal.SelectOrder(OrderID);
                return(ent);
            }
            catch
            {
                return(ent);
            }
        }
Exemplo n.º 8
0
        public ActionResult TrackOrder(int Order_ID)
        {
            List <Ent_OrderDetail> list = new List <Ent_OrderDetail>();
            Ent_Order ent = new Ent_Order();

            if (Order_ID != 0)
            {
                list = balOrder.SelectOrderDetails(Order_ID);
                ViewBag.OrderDetails = list;
                if (list.Count > 0)
                {
                    ent = list[0].entOrder;
                }
            }
            return(View(ent));
        }
Exemplo n.º 9
0
        public ActionResult ViewOrder()
        {
            int Order_ID = Request.QueryString["Id"] != null?Convert.ToInt32(Request.QueryString["Id"]) : 0;

            List <Ent_OrderDetail> list = new List <Ent_OrderDetail>();
            Ent_Order ent = new Ent_Order();

            if (Order_ID != 0)
            {
                list = balOrder.SelectOrderDetails(Order_ID);
                ViewBag.OrderDetails = list;
                if (list.Count > 0)
                {
                    ent = list[0].entOrder;
                }
            }
            return(View(ent));
        }
Exemplo n.º 10
0
        public int UpdateOrderStatus(Ent_Order ent, SafeTransaction trans)
        {
            int dataresult = 0;

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

                using (SqlCommand cmd = new SqlCommand("EC_UpdateOrderStatus", trans.DatabaseConnection, trans.Transaction))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Created_Date", ent.Created_Date));
                    cmd.Parameters.Add(new SqlParameter("@status", ent.Is_Active));
                    cmd.Parameters.Add(new SqlParameter("@Order_ID", ent.Order_ID));
                    try
                    {
                        dataresult = Convert.ToInt32(cmd.ExecuteScalar());
                        if (dataresult > 0)
                        {
                            cmd.Dispose();
                        }
                    }
                    catch (Exception ex)
                    {
                        dataresult = -2;
                    }
                }
            }
            catch (Exception e)
            {
                dataresult = -2;
            }
            finally { con.Close(); }
            return(dataresult);
        }
Exemplo n.º 11
0
        public Ent_Order SelectOrder(int OrderID)
        {
            Ent_Order ent     = new Ent_Order();
            int       guestid = 0;

            try
            {
                using (SqlCommand cmd = new SqlCommand("EC_SelectGuestOrder", con))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Guest_ID", guestid));
                    cmd.Parameters.Add(new SqlParameter("@Order_ID", OrderID));
                    IDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        ent                = new Ent_Order();
                        ent.Order_ID       = Convert.ToInt32(dr["Order_ID"]);
                        ent.Guest_ID       = Convert.ToInt32(dr["Guest_ID"]);
                        ent.Created_Date   = Convert.ToDateTime(dr["Created_Date"]);
                        ent.Is_Active      = Convert.ToInt32(dr["Is_Active"]);
                        ent.Order_Total    = Convert.ToDouble(dr["Order_Total"]);
                        ent.Order_SubTotal = Convert.ToDouble(dr["Order_SubTotal"]);
                        ent.Order_Shipping = Convert.ToDouble(dr["Order_Shipping"]);
                        ent.Total_Qty      = Convert.ToInt32(dr["Total_Qty"]);
                        ent.Is_Active      = Convert.ToInt32(dr["Is_Active"]);
                        if (dr["Received_Date"].ToString() == "")
                        {
                            ent.Received_Date = null;
                        }
                        else
                        {
                            ent.Received_Date = dr["Received_Date"].ToString();
                        }

                        if (dr["Shipped_Date"].ToString() == "")
                        {
                            ent.Shipped_Date = null;
                        }
                        else
                        {
                            ent.Shipped_Date = dr["Shipped_Date"].ToString();
                        }

                        if (dr["Delivered_Date"].ToString() == "")
                        {
                            ent.Delivered_Date = null;
                        }
                        else
                        {
                            ent.Delivered_Date = dr["Delivered_Date"].ToString();
                        }

                        if (dr["Cancel_Date"].ToString() == "")
                        {
                            ent.Cancel_Date = null;
                        }
                        else
                        {
                            ent.Cancel_Date = dr["Cancel_Date"].ToString();
                        }

                        if (dr["Return_Date"].ToString() == "")
                        {
                            ent.Return_Date = null;
                        }
                        else
                        {
                            ent.Return_Date = dr["Return_Date"].ToString();
                        }

                        ent.Billing_FirstName = Convert.ToString(dr["Billing_FirstName"]);
                        ent.Billing_LastName  = Convert.ToString(dr["Billing_LastName"]);
                        ent.Billing_Address1  = Convert.ToString(dr["Billing_Address1"]);
                        ent.Billing_Address2  = Convert.ToString(dr["Billing_Address2"]);
                        ent.Billing_Town      = Convert.ToString(dr["Billing_Town"]);
                        ent.Billing_State     = Convert.ToString(dr["Billing_State"]);
                        ent.Billing_Country   = Convert.ToString(dr["Billing_Country"]);
                        ent.Billing_Email     = Convert.ToString(dr["Billing_Email"]);
                        ent.Billing_Phone     = Convert.ToString(dr["Billing_Phone"]);

                        ent.Shipping_FirstName = Convert.ToString(dr["Shipping_FirstName"]);
                        ent.Shipping_LastName  = Convert.ToString(dr["Shipping_LastName"]);
                        ent.Shipping_Address1  = Convert.ToString(dr["Shipping_Address1"]);
                        ent.Shipping_Address2  = Convert.ToString(dr["Shipping_Address2"]);
                        ent.Shipping_Town      = Convert.ToString(dr["Shipping_Town"]);
                        ent.Shipping_State     = Convert.ToString(dr["Shipping_State"]);
                        ent.Shipping_Country   = Convert.ToString(dr["Shipping_Country"]);
                        ent.Shipping_Email     = Convert.ToString(dr["Shipping_Email"]);
                        ent.Shipping_Phone     = Convert.ToString(dr["Shipping_Phone"]);
                        ent.Payment_COD        = Convert.ToInt32(dr["Payment_COD"]);

                        ent.Created_Date = Convert.ToDateTime(dr["Created_Date"]);
                    }
                }
            }
            catch (Exception ex)
            {
                InsertException(ex.Message, "SelectOrder", OrderID);
            }
            finally
            {
                con.Close();
            }
            return(ent);
        }
Exemplo n.º 12
0
        public List <Ent_Order> SelectGuestOrder(int guestID)
        {
            List <Ent_Order> result = new List <Ent_Order>();
            Ent_Order        ent    = new Ent_Order();
            int orderid             = 0;

            try
            {
                using (SqlCommand cmd = new SqlCommand("EC_SelectGuestOrder", con))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Guest_ID", guestID));
                    cmd.Parameters.Add(new SqlParameter("@Order_ID", orderid));
                    IDataReader dr = cmd.ExecuteReader();
                    while (dr.Read())
                    {
                        ent                = new Ent_Order();
                        ent.Order_ID       = Convert.ToInt32(dr["Order_ID"]);
                        ent.Created_Date   = Convert.ToDateTime(dr["Created_Date"]);
                        ent.Is_Active      = Convert.ToInt32(dr["Is_Active"]);
                        ent.Order_Total    = Convert.ToDouble(dr["Order_Total"]);
                        ent.Order_SubTotal = Convert.ToDouble(dr["Order_SubTotal"]);
                        ent.Order_Shipping = Convert.ToDouble(dr["Order_Shipping"]);
                        ent.Total_Qty      = Convert.ToInt32(dr["Total_Qty"]);

                        ent.Billing_FirstName = Convert.ToString(dr["Billing_FirstName"]);
                        ent.Billing_LastName  = Convert.ToString(dr["Billing_LastName"]);
                        ent.Billing_Address1  = Convert.ToString(dr["Billing_Address1"]);
                        ent.Billing_Address2  = Convert.ToString(dr["Billing_Address2"]);
                        ent.Billing_Town      = Convert.ToString(dr["Billing_Town"]);
                        ent.Billing_State     = Convert.ToString(dr["Billing_State"]);
                        ent.Billing_Country   = Convert.ToString(dr["Billing_Country"]);
                        ent.Billing_Email     = Convert.ToString(dr["Billing_Email"]);
                        ent.Billing_Phone     = Convert.ToString(dr["Billing_Phone"]);

                        ent.Shipping_FirstName = Convert.ToString(dr["Shipping_FirstName"]);
                        ent.Shipping_LastName  = Convert.ToString(dr["Shipping_LastName"]);
                        ent.Shipping_Address1  = Convert.ToString(dr["Shipping_Address1"]);
                        ent.Shipping_Address2  = Convert.ToString(dr["Shipping_Address2"]);
                        ent.Shipping_Town      = Convert.ToString(dr["Shipping_Town"]);
                        ent.Shipping_State     = Convert.ToString(dr["Shipping_State"]);
                        ent.Shipping_Country   = Convert.ToString(dr["Shipping_Country"]);
                        ent.Shipping_Email     = Convert.ToString(dr["Shipping_Email"]);
                        ent.Shipping_Phone     = Convert.ToString(dr["Shipping_Phone"]);

                        ent.Created_Date = Convert.ToDateTime(dr["Created_Date"]);
                        result.Add(ent);
                    }
                }
            }
            catch (Exception ex)
            {
                InsertException(ex.Message, "SelectGuestOrder", guestID);
            }
            finally
            {
                con.Close();
            }
            return(result);
        }
Exemplo n.º 13
0
        public int UpdatePayment(Ent_Order entOrder, SafeTransaction trans)
        {
            int dataresult  = 0;
            int dataresult1 = 0;

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

                using (SqlCommand cmd = new SqlCommand("EC_UpdateOrder", trans.DatabaseConnection, trans.Transaction))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Order_ID", entOrder.Order_ID));
                    cmd.Parameters.Add(new SqlParameter("@Payment_Status", entOrder.Payment_Status));
                    cmd.Parameters.Add(new SqlParameter("@Transaction_Id", entOrder.Transaction_Id));
                    cmd.Parameters.Add(new SqlParameter("@Payment_Method", entOrder.Payment_Method));
                    try
                    {
                        dataresult = Convert.ToInt32(cmd.ExecuteScalar());
                        if (dataresult > 0)
                        {
                            cmd.Dispose();
                            dataresult1 = 1;

                            if (dataresult1 > 0)
                            {
                                if (entOrder.Guest_ID != 0 && entOrder.Payment_Status == "CAPTURED")
                                {
                                    var query = "delete from EC_Cart where Guest_ID=" + entOrder.Guest_ID;
                                    int k     = 0;
                                    using (SqlCommand cmd2 = new SqlCommand(query, trans.DatabaseConnection, trans.Transaction))
                                    {
                                        try
                                        {
                                            k = cmd2.ExecuteNonQuery();
                                            cmd2.Dispose();
                                        }
                                        catch (Exception ex)
                                        {
                                            dataresult = 0;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        dataresult = -2;
                    }
                }
            }
            catch (Exception e)
            {
                dataresult = -2;
            }
            finally { con.Close(); }
            return(dataresult);
        }
Exemplo n.º 14
0
        public int SaveOrder(Ent_Order ent, SafeTransaction trans)
        {
            int dataresult  = 0;
            int dataresult1 = 0;

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

                using (SqlCommand cmd = new SqlCommand("EC_InsertOrder", trans.DatabaseConnection, trans.Transaction))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@Order_ID", ent.Order_ID));
                    cmd.Parameters.Add(new SqlParameter("@Guest_ID", ent.Guest_ID));

                    cmd.Parameters.Add(new SqlParameter("@Shipping_FirstName", ent.Shipping_FirstName));
                    cmd.Parameters.Add(new SqlParameter("@Shipping_LastName", ent.Shipping_LastName));
                    cmd.Parameters.Add(new SqlParameter("@Shipping_Address1", ent.Shipping_Address1));
                    cmd.Parameters.Add(new SqlParameter("@Shipping_Address2", ent.Shipping_Address2));
                    cmd.Parameters.Add(new SqlParameter("@Shipping_Town", ent.Shipping_Town));
                    cmd.Parameters.Add(new SqlParameter("@Shipping_State", ent.Shipping_State));
                    cmd.Parameters.Add(new SqlParameter("@Shipping_Country", ent.Shipping_Country));
                    cmd.Parameters.Add(new SqlParameter("@Shipping_Email", ent.Shipping_Email));
                    cmd.Parameters.Add(new SqlParameter("@Shipping_Phone", ent.Shipping_Phone));

                    cmd.Parameters.Add(new SqlParameter("@Billing_FirstName", ent.Billing_FirstName));
                    cmd.Parameters.Add(new SqlParameter("@Billing_LastName", ent.Billing_LastName));
                    cmd.Parameters.Add(new SqlParameter("@Billing_Address1", ent.Billing_Address1));
                    cmd.Parameters.Add(new SqlParameter("@Billing_Address2", ent.Billing_Address2));
                    cmd.Parameters.Add(new SqlParameter("@Billing_Town", ent.Billing_Town));
                    cmd.Parameters.Add(new SqlParameter("@Billing_State", ent.Billing_State));
                    cmd.Parameters.Add(new SqlParameter("@Billing_Country", ent.Billing_Country));
                    cmd.Parameters.Add(new SqlParameter("@Billing_Email", ent.Billing_Email));
                    cmd.Parameters.Add(new SqlParameter("@Billing_Phone", ent.Billing_Phone));

                    cmd.Parameters.Add(new SqlParameter("@Order_SubTotal", ent.Order_SubTotal));
                    cmd.Parameters.Add(new SqlParameter("@Order_Shipping", ent.Order_Shipping));
                    cmd.Parameters.Add(new SqlParameter("@Order_Total", ent.Order_Total));
                    cmd.Parameters.Add(new SqlParameter("@Created_Date", ent.Created_Date));
                    cmd.Parameters.Add(new SqlParameter("@Payment_COD", ent.Payment_COD));
                    try
                    {
                        dataresult = Convert.ToInt32(cmd.ExecuteScalar());
                        if (dataresult > 0)
                        {
                            cmd.Dispose();
                            if (ent.OrderDetailsList != null)
                            {
                                for (int i = 0; i < ent.OrderDetailsList.Count; i++)
                                {
                                    using (SqlCommand cmd1 = new SqlCommand("EC_InsertOrderDetails", trans.DatabaseConnection, trans.Transaction))
                                    {
                                        cmd1.CommandType = CommandType.StoredProcedure;
                                        cmd1.Parameters.Add(new SqlParameter("@OrderDetail_ID", ent.OrderDetailsList[i].OrderDetail_ID));
                                        cmd1.Parameters.Add(new SqlParameter("@Order_ID", dataresult));
                                        cmd1.Parameters.Add(new SqlParameter("@Product_ID", ent.OrderDetailsList[i].Product_ID));
                                        cmd1.Parameters.Add(new SqlParameter("@Quantity", ent.OrderDetailsList[i].Quantity));
                                        cmd1.Parameters.Add(new SqlParameter("@Product_Price", ent.OrderDetailsList[i].Product_Price));
                                        cmd1.Parameters.Add(new SqlParameter("@Product_Total", ent.OrderDetailsList[i].Product_Total));
                                        try
                                        {
                                            dataresult1 = Convert.ToInt32(cmd1.ExecuteScalar());
                                            cmd1.Dispose();
                                        }
                                        catch (Exception ex)
                                        {
                                            dataresult = 0;
                                            InsertException(ex.Message, "SaveOrderDetail", ent.OrderDetailsList[i].OrderDetail_ID);
                                        }
                                    }
                                }

                                //if (dataresult1 > 0)
                                //{
                                //    if (ent.Guest_ID != 0)
                                //    {
                                //        var query = "delete from EC_Cart where Guest_ID=" + ent.Guest_ID;
                                //        int k = 0;
                                //        using (SqlCommand cmd2 = new SqlCommand(query, trans.DatabaseConnection, trans.Transaction))
                                //        {
                                //            try
                                //            {
                                //                k = cmd2.ExecuteNonQuery();
                                //                cmd2.Dispose();

                                //            }
                                //            catch (Exception ex)
                                //            {
                                //                dataresult = 0;
                                //            }
                                //        }
                                //    }
                                //}
                            }
                            else
                            {
                                dataresult = 0;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        dataresult = -2;
                    }
                }
            }
            catch (Exception e)
            {
                dataresult = -2;
            }
            finally { con.Close(); }
            return(dataresult);
        }
Exemplo n.º 15
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);
        }