public int SubmitShippingBilling(ShippingBilling shippingBilling) { int savetype = 0; savetype = DataAccess.DBAccess.SaveShippingBilling(shippingBilling); return(savetype); }
public void ChangeShippingBillingInformation(ShippingBilling input, string id) { if (ContainsShippingBilling(id)) { input.Id = ContainingId(id); _db.Update(input); } else { _db.Add(input); } _db.SaveChanges(); }
public static int SaveShippingBilling(ShippingBilling shippingBilling) { int savetype = 0; string content = string.Empty; using (DBKOMPDataContext db = new DBKOMPDataContext()) { var countUser = (from w in db.ShippingBillings where w.RequestId == shippingBilling.RequestId select w).Count(); if (countUser == 0) { db.ShippingBillings.InsertOnSubmit(shippingBilling); db.SubmitChanges(); savetype = shippingBilling.Id; } else { savetype = (from w in db.ShippingBillings where w.RequestId == shippingBilling.RequestId select w).First().Id; } return(savetype); } }
public void ChangeShippingBillingInfo(ShippingBillingInputModel input, string id) { ShippingBilling write = new ShippingBilling() { UserId = id, ShippingFirstName = input.ShippingFirstName, ShippingLastName = input.ShippingLastName, ShippingStreetName = input.ShippingStreetName, ShippingHouseNumber = input.ShippingHouseNumber, ShippingCity = input.ShippingCity, ShippingZipCode = input.ShippingCity, ShippingCountry = input.ShippingCountry, BillingFirstName = input.BillingFirstName, BillingLastName = input.BillingLastName, BillingStreetName = input.BillingStreetName, BillingHouseNumber = input.BillingHouseNumber, BillingCity = input.BillingCity, BillingZipCode = input.BillingCity, BillingCounry = input.BillingCountry }; _userRepo.ChangeShippingBillingInformation(write, id); }
//public static int SaveOrder(OrderList orders) //{ // //Now taking it from session. instead of perameter. // if (HttpContext.Current.Session["OrderList"] != null) // { // orders = (OrderList)HttpContext.Current.Session["OrderList"]; // } // using (DBKOMPDataContext db = new DBKOMPDataContext()) // { // int customerId = 0; // if (HttpContext.Current.Session["USER"] != null) // { // customerId = ((User)HttpContext.Current.Session["USER"]).UserId; // } // Request objRequest = new Request(); // objRequest.CreatedDate = DateTime.Now; // objRequest.UserId = customerId; // objRequest.CreatedBy = customerId; // //create a request id // db.Requests.InsertOnSubmit(objRequest); // db.SubmitChanges(); // foreach(var order in orders.orders) // { // order.Order.RequestId = objRequest.Id; // order.Order.CustomerId = customerId; // order.Order.OrderDate = DateTime.Now; // db.Orders.InsertOnSubmit(order.Order); // db.SubmitChanges(); // order.payment.OrderId = order.Order.Id; // db.Payments.InsertOnSubmit(order.payment); // foreach (var apt in order.OrderDetailList) // { // apt.OrderId = order.Order.Id; // } // db.OrderDetails.InsertAllOnSubmit(order.OrderDetailList); // } // db.SubmitChanges(); // //#region Send Mail // //if (HttpContext.Current.Session["USER"] != null) // //{ // // var objtblUser = (User)HttpContext.Current.Session["USER"]; // // string content = string.Empty; // // string filepath = "~/Email/Post.htm"; // // //New user // // StringBuilder sbContent = new StringBuilder(); // // StreamReader rdr = new StreamReader(HttpContext.Current.Server.MapPath(filepath)); // // string strLine = ""; // // while (strLine != null) // // { // // strLine = rdr.ReadLine(); // // if ((strLine != null) && (strLine != "")) // // { // // sbContent.Append("\n" + strLine); // // } // // } // // rdr.Close(); // // string site = ConfigurationManager.AppSettings["SiteName"].ToString(); // // content = sbContent.ToString(); // // //content = content.Replace("$REQ$", PostType); // // //content = content.Replace("$ID$", ID); // // content = content.Replace("$NAME$", objtblUser.FirstName + " " + objtblUser.LastName); // // content = content.Replace("$SITE$", site); // // if (!string.IsNullOrEmpty(objtblUser.email)) // // { // // MailHelper.SendMailMessage("", objtblUser.email, string.Empty, string.Empty, "Thanks for Posting", content); // // // AutoServices.SendeMailToUs("Copy:Thanks for Posting", content); // // } // //} // //#endregion // // HttpContext.Current.Session["OrderList"] = orders; // return objRequest.Id;// orderDTO.Order.Id; // } //} public static int SavePayemt(int requestId, int paymentStatus, int paymentMode, string cardNum, string trnNo, string NameOnCard) { using (DBKOMPDataContext db = new DBKOMPDataContext()) { var objtblUser = CommanAction.GetSession();//for yourguyonly var orders = (from w in db.Orders where w.RequestId == requestId select w).ToList(); var SipBilObj = new ShippingBilling(); string locationOfPinCode = string.Empty; if (orders.Count > 0) { locationOfPinCode = (from w in db.tblLocations where w.pincode.Value == orders[0].pincode select w).First().Location; } //Variable is using to add 25 rs only one time bool IsCashPickup25Added = false; foreach (var ord in orders) { if (string.IsNullOrEmpty(SipBilObj.Pincode)) { SipBilObj = DBAccess.GetShippingBillingByUserId(objtblUser.UserId, ord.pincode ?? 0);//for yourguyonly } if (requestId > 0) { var payment = (from w in db.Payments where w.OrderId == ord.Id select w).First(); //paymentObj.Amount = 200; payment.CardNumber = cardNum; payment.Mode = paymentMode; //NET BANKING-1, credit card-2, debit card - 3, cash card - 4, mobile payment-5 payment.NameOnCard = NameOnCard; payment.TransactionNo = trnNo; payment.IsActive = (paymentStatus == 1) ? 1 : 0; payment.PaymentDate = DateTime.Now; //Settign for offline casehpickup if (paymentMode == 14 && !IsCashPickup25Added) { var config = DBAccess.GetConfig(); //order.payment.TrnChrg = Convert.ToDecimal(Caspikup + CaspikupPer * (order.payment.Amount + order.payment.DeliveryChrg) / 100); payment.TrnChrg = Convert.ToDecimal(config.CashPickUpPercent * (payment.Amount + payment.DeliveryChrg) / 100) + config.CashPickUp ?? 0; payment.TrnChrg = Convert.ToDecimal(String.Format("{0:.00}", payment.TrnChrg)); //payment.TrnChrg = Convert.ToInt32(payment.TrnChrg + config.CashPickUp ?? 0); IsCashPickup25Added = true; } ord.PaymentDone = paymentStatus; //SUCCESS -1 , failure - 0 , invalid =3, abort = 4 --- paymentMode != 5 ? 1 : 0; //5 means offline ord.IsActive = (paymentStatus == 1)?1:0; if (paymentStatus == 1 && (paymentMode != 11 && paymentMode != 12 && paymentMode != 13 && paymentMode != 14)) //Not offline and not cash pickup { var orderDetails = (from w in db.OrderDetails where w.OrderId == ord.Id select w); //Yourguy productid var prodcId = "0"; //Your guy DateColletion List <string> lstDeliveryDate = new List <string>(); //Your guy time string Deliverytime = ord.IsLunch == 1 ? "2015-01-01T12:15:02Z" : "2015-01-01T20:15:02Z"; string time = ord.IsLunch == 1 ? "12:16:06Z" : "20:16:06Z"; string PickUptime = ord.IsLunch == 1 ? "2015-01-01T10:16:06Z" : "2015-01-01T18:16:06Z"; foreach (var od in orderDetails) { prodcId = "0"; // od.SubProductId.ToString(); lstDeliveryDate.Add(od.DeliverDate.Value.ToString("yyyy-MM-ddT") + time); od.IsActive = 1; //od.YourguyOrderId = YourGuy(od.Id.ToString(), ord.Id.ToString(), SipBilObj, od.DeliverDate.Value.ToString("yyyy-MM-ddT") + time); //"2015-07-22T12:16:06Z" } //Yourguy service TODO: UNDO ONCE READY BY YOUR GUY //ord.YourguyOrderId = CallYourGuy(prodcId, ord.Id.ToString(), SipBilObj, Deliverytime, PickUptime, lstDeliveryDate, locationOfPinCode); } db.SubmitChanges(); } //else //{ // //ord.PaymentDone = 3; //Payment Failed // //ord.IsActive = 1; // //db.SubmitChanges(); //} } return(1); } }
private int InsertAddress() { //Start Insert Address //Note use last name as emaiid var shippingBilling = new ShippingBilling(); shippingBilling.Id = 0; shippingBilling.UserId = loggiedIn; shippingBilling.RequestId = requestId; shippingBilling.FirstName = delivery_name.Value.Trim(); //Trim(document.getElementById("delivery_name").value); shippingBilling.LastName = txtLastName.Value; // Trim(document.getElementById("txtLastName").value); shippingBilling.mobile = delivery_tel.Value; // Trim(document.getElementById("delivery_tel").value); shippingBilling.CompanyName = txtCompanyName.Value; //Trim(document.getElementById("txtCompanyName").value); //Create address // delivery_address.Value = txtFlat.Value + ", " + txtBuilding.Value + ", " + txtStreet.Value + ", ";// +txtLocation.Items[txtLocation.SelectedIndex].Text; shippingBilling.Address = txtFlat.Value + "$" + txtBuilding.Value + ", " + txtStreet.Value + "$";// +txtLocation.Items[txtLocation.SelectedIndex].Text; //shippingBilling.Address = Trim($("#txtFlat").val()) + "$" + Trim($("#txtBuilding").val()) + "$" + Trim($("#txtStreet").val() + "$" + $("#txtLocation option:selected").html()); // Trim(document.getElementById("delivery_address").value); shippingBilling.City = delivery_city.Value.Trim(); shippingBilling.State = delivery_state.Value.Trim(); shippingBilling.LandMark = txtLandMark.Value.Trim(); shippingBilling.Pincode = delivery_zip.Value; if (chkSamAsShipping.Checked)// $("#chkSamAsShipping").is(':checked')) { //Need to set control value too for ccavenu posting -start //billing_name.Value = delivery_name.Value; //txtLastNameB.Value = txtLastName.Value; //billing_tel.Value = delivery_tel.Value; //txtCompanyNameB.Value = txtCompanyName.Value; //billing_address.Value = delivery_address.Value; //txtFlat.Value = txtFlatB.Value; //txtBuilding.Value = txtBuildingB.Value; //txtStreet.Value = txtStreetB.Value; //billing_city.Value = delivery_city.Value; //billing_state.Value = delivery_state.Value; //txtLandMarkB.Value = txtLandMark.Value; //billing_zip.Value = delivery_zip.Value; //Need to set control value too for ccavenu posting -end shippingBilling.FirstNameB = delivery_name.Value; shippingBilling.LastNameB = txtLastName.Value; shippingBilling.mobileB = delivery_tel.Value; shippingBilling.CompanyNameB = txtCompanyName.Value; //shippingBilling.AddressB = Trim($("#txtFlat").val()) + "$" + Trim($("#txtBuilding").val()) + "$" + $("#txtLocation option:selected").html(); // Trim(document.getElementById("delivery_address").value); shippingBilling.AddressB = txtFlat.Value + "$" + txtBuilding.Value + "$";// +txtLocation.Items[txtLocation.SelectedIndex].Text; // Trim(document.getElementById("delivery_address").value); shippingBilling.CityB = delivery_city.Value; shippingBilling.StateB = delivery_state.Value; shippingBilling.LandMarkB = txtLandMark.Value; shippingBilling.PincodeB = delivery_zip.Value; shippingBilling.CreatedDate = DateTime.Now; } else { shippingBilling.FirstNameB = billing_name.Value; shippingBilling.LastNameB = txtLastNameB.Value; shippingBilling.mobileB = billing_tel.Value; shippingBilling.CompanyNameB = txtCompanyNameB.Value; //document.getElementById("billing_address").value = Trim($("#txtFlatB").val()) + ", " + Trim($("#txtBuildingB").val()) + ", " + Trim($("#txtStreetB").val()); // billing_address.Value = txtFlatB.Value.Trim() + ", " + txtBuildingB.Value.Trim() + ", " + txtStreetB.Value.Trim(); shippingBilling.AddressB = txtFlatB.Value.Trim() + "$" + txtBuildingB.Value.Trim() + "$" + txtStreetB.Value.Trim(); //shippingBilling.AddressB = Trim($("#txtFlatB").val()) + "$" + Trim($("#txtBuildingB").val()) + "$" + Trim($("#txtStreetB").val()+"$"+$("#txtLocationB").val()); // Trim(document.getElementById("billing_address").value); shippingBilling.CityB = billing_city.Value; shippingBilling.StateB = billing_state.Value; shippingBilling.LandMarkB = txtLandMarkB.Value.Trim(); shippingBilling.PincodeB = billing_zip.Value.Trim(); shippingBilling.CreatedDate = DateTime.Now; } int shipinid = DataAccess.DBAccess.SaveShippingBilling(shippingBilling); return(shipinid); //end Insert Address }
public int SavePayementDetails(Payment objPaymentHistory) { SqlTransaction transaction = null; try { if (objPaymentHistory.OrderId == 0) { //throw (new Exception("Please retrieve Customer ID")); return(0); } if (objPaymentHistory.Amount == 0) { //throw (new Exception("Please retrieve Customer ID")); return(0); } con = new SqlConnection(cs); con.Open(); transaction = con.BeginTransaction(IsolationLevel.ReadCommitted); String cbt = "select TotalPayment from [Order] where Id= '" + objPaymentHistory.OrderId + "'"; cmd = new SqlCommand(cbt); cmd.Connection = con; cmd.Transaction = transaction; decimal amt = Convert.ToDecimal(cmd.ExecuteScalar()); int paymenStatus = 2; if (objPaymentHistory.Amount >= amt) { paymenStatus = 1; //Paid } //string invoiceno = "INV-" + GetUniqueKey(8); //String cb = "update [Order] set IsActive='1', PaymentDone='" + paymenStatus + "',TotalPayment = TotalPayment + " + objPaymentHistory.Amount + " where Id= '" + objPaymentHistory.OrderId + "'"; String cb = "update [Order] set IsActive='1', PaymentDone='" + paymenStatus + "',TotalPayment = " + objPaymentHistory.Amount + " where Id= '" + objPaymentHistory.OrderId + "'"; //string cb = "insert Into Sales(InvoiceNo,InvoiceDate,CustomerID,SubTotal,VATPercentage,VATAmount,GrandTotal,TotalPayment,PaymentDue,Remarks) VALUES ('" + invoiceno + "','" + objInvoiceData.InvoiceItems[0].InvoiceDate + "','" + objInvoiceData.InvoiceItems[0].CustomerID + "'," + objInvoiceData.InvoiceItems[0].SubTotal + "," + objInvoiceData.InvoiceItems[0].VATPercentage + "," + objInvoiceData.InvoiceItems[0].VATAmount + "," + objInvoiceData.InvoiceItems[0].GrandTotal + "," + objInvoiceData.InvoiceItems[0].TotalPayment + "," + objInvoiceData.InvoiceItems[0].PaymentDue + ",'" + objInvoiceData.InvoiceItems[0].Remarks + "')"; cmd = new SqlCommand(cb); cmd.Connection = con; cmd.Transaction = transaction; cmd.ExecuteNonQuery(); //cb = "update [OrderDetails] set IsActive='1' where OrderId= '" + objPaymentHistory.OrderId + "'"; //cmd = new SqlCommand(cb); //cmd.Connection = con; //cmd.Transaction = transaction; //cmd.ExecuteNonQuery(); //if (con.State == ConnectionState.Open) //{ // con.Close(); //} //con.Close(); //Delete product //con = new SqlConnection(cs); //con.Open(); //string invoiceno = "INV-" + GetUniqueKey(8); //String cb1 = "insert from ProductSold where Invoiceno= '" + objInvoiceData.InvoiceItems[0].InvoiceNo + "'"; string cb1 = "update Payment set PaymentDate='" + objPaymentHistory.PaymentDate.Value.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToLocalTime().TimeOfDay.ToString().Substring(0, 12) + "', Mode='" + objPaymentHistory.Mode + "',TransactionNo='" + objPaymentHistory.TransactionNo + "',Bank='" + objPaymentHistory.Bank + "',Branch='" + objPaymentHistory.Branch + "',Comments='" + objPaymentHistory.Comments + "', IsActive=1 where Orderid='" + objPaymentHistory.OrderId + "'"; //string cb1 = "update Payment set Amount =Amount + " + objPaymentHistory.Amount + ",PaymentDate='" + objPaymentHistory.PaymentDate + "', Mode='" + objPaymentHistory.Mode + "',TransactionNo='" + objPaymentHistory.TransactionNo + "',IsActive=1 where Orderid='" + objPaymentHistory.OrderId + "'"; cmd = new SqlCommand(cb1); cmd.Connection = con; cmd.Transaction = transaction; cmd.ExecuteNonQuery(); transaction.Commit(); if (con.State == ConnectionState.Open) { con.Close(); } con.Close(); //TODO:LATER //for (int i = 0; i <= objInvoiceData.CartItems.Count - 1; i++) //{ // con = new SqlConnection(cs); // con.Open(); // string cb1 = "update stock set Quantity = Quantity - " + objInvoiceData.CartItems[i].Qty + " where ConfigID= " + objInvoiceData.CartItems[i].ConfigID + ""; // cmd = new SqlCommand(cb1); // cmd.Connection = con; // cmd.ExecuteNonQuery(); // con.Close(); //} //for (int i = 0; i <= objInvoiceData.CartItems.Count - 1; i++) //{ // con = new SqlConnection(cs); // con.Open(); // string cb2 = "update stock set TotalPrice = Totalprice - '" + objInvoiceData.CartItems[i].TotalAmount + "' where ConfigID= " + objInvoiceData.CartItems[i].ConfigID + ""; // cmd = new SqlCommand(cb2); // cmd.Connection = con; // cmd.ExecuteReader(); // con.Close(); //} String cbt1 = "select RequestId from [Order] where Id= '" + objPaymentHistory.OrderId + "'"; cmd = new SqlCommand(cbt1); con.Open(); cmd.Connection = con; //cmd.Transaction = transaction; int rqst = Convert.ToInt32(cmd.ExecuteScalar()); if (con.State == ConnectionState.Open) { con.Close(); } con.Close(); #region Calling yourguy api // var objtblUser = CommanAction.GetSession();//for yourguyonly using (DBKOMPDataContext db = new DBKOMPDataContext()) { var orders = (from w in db.Orders where w.Id == objPaymentHistory.OrderId select w).First(); var SipBilObj = DBAccess.GetShippingBillingByUserId(orders.CustomerId ?? 0, orders.pincode ?? 0);//for yourguyonly var orderDetails = (from w in db.OrderDetails where w.OrderId == objPaymentHistory.OrderId select w); //string time = orders.IsLunch == 1 ? "12:16:06Z" : "20:16:06Z"; string locationOfPinCode = string.Empty; locationOfPinCode = (from w in db.tblLocations where w.pincode.Value == orders.pincode select w).First().Location; //Yourguy productid var prodcId = "0"; //Your guy DateColletion List <string> lstDeliveryDate = new List <string>(); //Your guy time //string time = orders.IsLunch == 1 ? "12:16:06Z" : "20:16:06Z"; //Your guy time string Deliverytime = orders.IsLunch == 1 ? "2015-01-01T12:16:06Z" : "2015-01-01T20:16:06Z"; string time = orders.IsLunch == 1 ? "12:16:06Z" : "20:16:06Z"; string PickUptime = orders.IsLunch == 1 ? "2015-01-01T10:16:06Z" : "2015-01-01T18:16:06Z"; foreach (var od in orderDetails) { prodcId = "0"; //prodcId = od.SubProductId.ToString(); lstDeliveryDate.Add(od.DeliverDate.Value.ToString("yyyy-MM-ddT") + time); od.IsActive = 1; //od.YourguyOrderId = OrderManagement.CallYourGuy(od.Id.ToString(), objPaymentHistory.OrderId.ToString(), SipBilObj, od.DeliverDate.Value.ToString("yyyy-MM-ddT") + time); //"2015-07-22T12:16:06Z" } //Yourguy service //Yourguy service TODO: UNDO ONCE READY BY YOUR GUY //orders.YourguyOrderId = OrderManagement.CallYourGuy(prodcId, orders.Id.ToString(), SipBilObj, Deliverytime, PickUptime, lstDeliveryDate, locationOfPinCode); db.SubmitChanges(); } #endregion ShippingBilling objSB = DBAccess.GetShippingBilling(rqst); #region Send Mail string content = string.Empty; string filepath = "~/Email/Post.htm"; //New user StringBuilder sbContent = new StringBuilder(); StreamReader rdr = new StreamReader(HttpContext.Current.Server.MapPath(filepath)); string strLine = ""; while (strLine != null) { strLine = rdr.ReadLine(); if ((strLine != null) && (strLine != "")) { sbContent.Append("\n" + strLine); } } rdr.Close(); string site = ConfigurationManager.AppSettings["SiteName"].ToString(); content = sbContent.ToString(); //content = content.Replace("$REQ$", PostType); //content = content.Replace("$ID$", ID); var sbOff = new StringBuilder(); //divOff.RenderControl(new HtmlTextWriter(new StringWriter(sbOff))); content = content.Replace("$ORDERSUMMARY$", "Congratulation!! Your Order #" + objPaymentHistory.OrderId + " is confirmed!<br/>KOMP has received payment of Rs. " + objPaymentHistory.Amount + " /-"); var sb = new StringBuilder(); //divFinal.RenderControl(new HtmlTextWriter(new StringWriter(sb))); content = content.Replace("$REQ$", ""); content = content.Replace("$NAME$", objSB.FirstName); content = content.Replace("$SITE$", site); content = content.Replace("RobotoBlack", "Arial"); content = content.Replace("Roboto", "Arial"); content = content.Replace("RobotoBold", "Arial"); content = content.Replace("images/rs3.png", "http://www.kitchenonmyplate.com/images/rs3.png"); content = content.Replace("class", "style"); content = content.Replace("page-titleSmallCust", "color:#4b220c; text-transform:uppercase; font-family:'Arial'; font-weight:bold;border-bottom:1px solid #c8c6c6; padding:10px 0 10px 25px ; font-size:25px; margin-top:0px;background:#EEEEEE !important;"); content = content.Replace("OrderBox", "display:none"); content = content.Replace("ProcessBox", "width:100%;height:auto;border:1px solid #c8c6c6;padding-bottom:10px;"); content = content.Replace("ProcesBoxInner", "height:auto; padding:0px 25px 10px 10px;text-align: justify; text-justify: inter-word;"); content = content.Replace("tbl", "width:100%;height:auto;border:1px solid #c8c6c6;"); content = content.Replace("divRowHeader", "font-weight:bold; color:Black; font-size:0.85em;"); content = content.Replace("<table", "<table style='border-collapse:collapse; border-spacing:0;' "); content = content.Replace("price", "font-weight:700; font-size:1.2em; color: #006400;"); content = content.Replace("priceTotaltxt", "font-weight:700; font-size:24px; color: #006400;"); content = content.Replace("priceTotal", "font-size:30px; color: #006400; padding-right:25px;"); content = content.Replace("CUSTBOX", ""); content = content.Replace("emailH5", "font-size:14px;"); content = content.Replace(">01<", ""); content = content.Replace(">03<", ""); if (!string.IsNullOrEmpty(objSB.LastName)) //Note : last name is as emailid { MailHelper.SendMailMessage("", objSB.LastName, string.Empty, string.Empty, "KOMP : Your order #" + objPaymentHistory.OrderId + " is confirmed", content); AutoServices.SendeMailToUs("Copy:KOMP : Your order #" + objPaymentHistory.OrderId + " is confirmed", content); } #endregion return(1); } catch (Exception exc) { transaction.Rollback(); return(0); //throw exc; } }