public static void DeleteNews(int id) { DBKOMPDataContext db = new DBKOMPDataContext(); var objDelete = News().Where(p => (p.Id == id)).First(); db.MenuItems.Attach(objDelete); db.MenuItems.DeleteOnSubmit(objDelete); db.SubmitChanges(); }
public static void DeleteProduct(int id) { DBKOMPDataContext db = new DBKOMPDataContext(); var objDelete = (from w in db.Menus where w.Id == id select w).First(); // db.Menus.Attach(objDelete); db.Menus.DeleteOnSubmit(objDelete); db.SubmitChanges(); CacheHelper.Clear("Menu"); }
public static int SubmitHoliday(List <HoliDay> list) { string content = string.Empty; using (DBKOMPDataContext db = new DBKOMPDataContext()) { db.HoliDays.DeleteAllOnSubmit(from w in db.HoliDays select w); db.HoliDays.InsertAllOnSubmit(list); db.SubmitChanges(); CacheHelper.Clear("Holiday"); return(1); } }
public bool UpdateFolderOrder(string folders) { DBKOMPDataContext db = new DBKOMPDataContext(); string[] folderArr = folders.Split('^'); for (int k = 0; k < folderArr.Length; k++) { PhotoDirectory tbl = db.PhotoDirectories.Single(p => p.Id == Convert.ToInt32(folderArr[k])); tbl.Sequence = k + 1; db.SubmitChanges(); } return(true); }
public static int SendMsgToAgent(Message msg) { using (DBKOMPDataContext db = new DBKOMPDataContext()) { db.Messages.InsertOnSubmit(msg); db.SubmitChanges(); #region Send Mail string content = string.Empty; string filepath = "Email/UserMessage.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("$USER$", msg.name); content = content.Replace("$MESSAGE$", msg.message1); content = content.Replace("$EMAIL$", msg.email); content = content.Replace("$MOBILE$", msg.mobile); content = content.Replace("$SITE$", site); content.Replace("RobotoBlack", "Arial").Replace("RobotoBold", "Arial").Replace("Roboto", "Arial"); //MailHelper.SendMailMessage("", objtblUser.email, string.Empty, string.Empty, "Thanks for Posting", content); //MailHelper.SendMailMessage("", "*****@*****.**", string.Empty, string.Empty, "User message", content); string ownerEmailId1 = ConfigurationManager.AppSettings["OwnerEmailID1"].ToString(); MailHelper.SendMailMessage("", ownerEmailId1, string.Empty, string.Empty, "Visitor's message", content); string ownerEmailId2 = ConfigurationManager.AppSettings["OwnerEmailID2"].ToString(); MailHelper.SendMailMessage("", ownerEmailId2, string.Empty, string.Empty, "Visitor's message", content); #endregion return(1); } }
public static int DeltedWeeklyMenuItem(int id) { using (DBKOMPDataContext db = new DBKOMPDataContext()) { if (id != 0) { db.WeeklyMenus.DeleteOnSubmit(db.WeeklyMenus.Where(w => w.Id == id).First()); } db.SubmitChanges(); CacheHelper.Clear("WEEKLYMENU"); CacheHelper.Clear("WEEKLYMENUA"); } return(id); }
public static int DeleteOrder(int orderId) { string content = string.Empty; using (DBKOMPDataContext db = new DBKOMPDataContext()) { int requesid = (from o in db.Orders where o.Id == orderId select o).First().RequestId ?? 0; var orders1 = (from w in db.Orders where w.RequestId == requesid select w); //it shipping billing should be deleted in case order is one becaseu there might me more orders on same request id if (orders1.Count() == 1) { db.ShippingBillings.DeleteAllOnSubmit(from w in db.ShippingBillings where w.RequestId == requesid select w); } //Here updating next paying in case cash pickup bool IsPriceSeted = false; Payment pmt; foreach (var ord in orders1) { if (ord.Id != orderId) { if ((from w in db.Payments where w.OrderId == ord.Id select w).Count() > 0) { pmt = (from w in db.Payments where w.OrderId == ord.Id select w).First(); if (pmt.Mode.ToString() == "14" && !IsPriceSeted) { pmt.TrnChrg = (from w in db.Payments where w.OrderId == orderId select w).First().TrnChrg; IsPriceSeted = true; } } } } // var ordersBig = (from w in db.Payments where w.RequestId == requesid select w); db.Payments.DeleteAllOnSubmit(from w in db.Payments where w.OrderId == orderId select w); db.OrderDetails.DeleteAllOnSubmit(from w in db.OrderDetails where w.OrderId == orderId select w); db.Orders.DeleteAllOnSubmit(from w in db.Orders where w.Id == orderId select w); db.SubmitChanges(); CacheHelper.Clear("Holiday"); return(1); } }
public static int SaveTitle(string imageFile, string title, string folderName) { DBKOMPDataContext db = new DBKOMPDataContext(); lock (db) { System.Diagnostics.Process.GetCurrentProcess(); PeraImage obj = new PeraImage(); PeraImage objUpdated = db.PeraImages.Where(p => (p.Directory == folderName && p.FileName == imageFile)).First(); objUpdated.Detail = title; db.SubmitChanges(); db.Dispose(); } return(1); }
public static int SetUserByAdminOnBehalf(int requestId, string name, string emailid) { int savetype = 0; string content = string.Empty; using (DBKOMPDataContext db = new DBKOMPDataContext()) { int uid = 0; var countUser = (from w in db.Users where w.email.ToUpper() == emailid.ToUpper() select w).Count(); if (countUser == 0) { uid = InsertUpdateUserDetails(new User { UserId = 0, FirstName = name, email = emailid, UserLoginID = emailid, password = "******" + name.Substring(0, 2) }); } else { uid = (from w in db.Users where w.email.ToUpper() == emailid.ToUpper() select w).First().UserId; } var rqst = (from w in db.Requests where w.Id == requestId select w).First(); rqst.UserId = uid; System.Threading.Thread.Sleep(5000); var shipp = (from w in db.ShippingBillings where w.RequestId == requestId select w).First(); shipp.UserId = uid; var orders = (from w in db.Orders where w.RequestId == requestId select w); foreach (var ord in orders) { ord.CustomerId = uid; ord.PaymentDone = 0;//pending } db.SubmitChanges(); return(savetype); } }
public static int SaveEventNPics(PeraImage peraImage) { try { DBKOMPDataContext db = new DBKOMPDataContext(); db.PeraImages.InsertOnSubmit(peraImage); db.SubmitChanges(); return(1); // Page.ClientScript.RegisterStartupScript(typeof(Page), "sub", "GetFiles();", true); // SetFolders(); } catch (Exception ex) { return(0); } }
public static void SaveProduct(Menu obj) { using (DBKOMPDataContext db = new DBKOMPDataContext()) { if (obj.Id == 0) { db.Menus.InsertOnSubmit(obj); } else { KitchenOnMyPlate.Menu objUpdated = db.Menus.Where(p => (p.Id == obj.Id)).First(); objUpdated.Header = obj.Header; objUpdated.Detail = obj.Detail; objUpdated.IsActive = obj.IsActive; } db.SubmitChanges(); db.Dispose(); CacheHelper.Clear("Menu"); } }
public static string DeleteFiles(string files, string folderName) { DBKOMPDataContext db = new DBKOMPDataContext(); string[] fileArray = files.Split(','); foreach (string fileName in fileArray) { //delete from direcotry System.IO.FileInfo fileEntries = new FileInfo(HttpContext.Current.Server.MapPath("images/" + folderName + "/" + fileName)); fileEntries.Delete(); //delete from database var objDelete = db.PeraImages.Where(p => (p.FileName == fileName)).First(); db.PeraImages.DeleteOnSubmit(objDelete); db.SubmitChanges(); } return(GetFilesWithCheckBox("images/" + folderName, folderName, "group1")); }
public static bool DeleteEvent(int eventId) { DBKOMPDataContext db = new DBKOMPDataContext(); bool Deleted = false; if (eventId == 0) { Deleted = false; } else { var objDelete = db.PhotoDirectories.Where(p => (p.Id == eventId)).First(); //db.PhotoDirectories.Attach(objDelete); db.PhotoDirectories.DeleteOnSubmit(objDelete); Deleted = true; Directory.Delete(HttpContext.Current.Server.MapPath("images/" + objDelete.FolderName), true); db.SubmitChanges(); } return(Deleted); }
public static int setPaymentAsFailed(int requestId) { int savetype = 0; string content = string.Empty; using (DBKOMPDataContext db = new DBKOMPDataContext()) { int uid = 0; var rqst = (from w in db.Requests where w.Id == requestId select w).First(); rqst.UserId = uid; var orders = (from w in db.Orders where w.RequestId == requestId select w); foreach (var ord in orders) { ord.PaymentDone = 2; //Failed } db.SubmitChanges(); return(savetype); } }
public static int ChangePassword(string UID, string ChngPass, string OldPassword) { using (DBKOMPDataContext db = new DBKOMPDataContext()) { int action = 0; User tblus = db.Users.Single(p => p.UserLoginID == UID || p.mobile == UID); if (tblus.password == OldPassword) { tblus.password = ChngPass; db.SubmitChanges(); action = 1; ChangedPasswordMail(tblus); } else { action = 2; } return(action); } }
//protected void Images() //{ // System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(HttpContext.Current.Server.MapPath("images/"+Folders.SelectedItem)); // //to retrieve aspx files alone // System.IO.FileInfo[] fileEntries = di.GetFiles("*.jpg"); // //string[] fileEntries = Directory.GetFiles(Server.MapPath("images/PhotaGallery")); // foreach (FileInfo fileName in fileEntries) // { // ltrlImage.Text = ltrlImage.Text + "<div id='" + fileName.Name + "' ><a rel='group' class='aaa' title='" + fileName.Name + "' href='../Samples/" + fileName.Name + "'>" + // "<img src='images/" + Folders.Text + "/" + fileName.Name + "' width='40' height='30' /></a><input id='chk" + fileName.Name + "' type='checkbox' /></div>"; // } //} //protected void Folders_SelectedIndexChanged(object sender, EventArgs e) //{ // Images(); //} protected void btnUpload_Click(object sender, EventArgs e) { try { DBKOMPDataContext db = new DBKOMPDataContext(); // Get the HttpFileCollection HttpFileCollection hfc = Request.Files; for (int i = 0; i < hfc.Count; i++) { PeraImage obj = new PeraImage(); obj.Directory = Folders.SelectedItem.ToString(); HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { hpf.SaveAs(Server.MapPath("images/" + Folders.SelectedItem) + "\\" + System.IO.Path.GetFileName(hpf.FileName)); Response.Write("<b>File: </b>" + hpf.FileName + " <b>Size:</b> " + hpf.ContentLength + " <b>Type:</b> " + hpf.ContentType + " Uploaded Successfully <br/>"); } obj.FileName = hpf.FileName; obj.Detail = hpf.FileName.Replace(".jpg", "").Replace(".JPG", ""); db.PeraImages.InsertOnSubmit(obj); db.SubmitChanges(); } Page.ClientScript.RegisterStartupScript(typeof(Page), "sub", "GetFiles();", true); // SetFolders(); } catch (Exception ex) { } }
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 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); } }
public static int SaveOrder(string method) { OrderList orders = new OrderList(); //Now taking it from session. instead of perameter. if (HttpContext.Current.Session["OrderList"] != null) { orders = (OrderList)HttpContext.Current.Session["OrderList"]; } else { //It create the orders from the cookies if (OrderManagement.GetOrderListSession().orders.Count == 0) { return(-1); } } //Below condition : already ordered using (DBKOMPDataContext db = new DBKOMPDataContext()) { int customerId = 0; //if (CommanAction.GetSession() != null) //{ customerId = CommanAction.GetSession().UserId; //} //Delete if already in cart if (orders.orders.Count > 0 && orders.orders[0].Order.RequestId > 0) { foreach (var order in orders.orders) { if (orders.orders.Count > 0 && orders.orders[0].Order.RequestId > 0) { db.OrderDetails.DeleteAllOnSubmit((from w in db.OrderDetails where w.OrderId == order.Order.Id select w)); db.Payments.DeleteAllOnSubmit((from w in db.Payments where w.OrderId == order.Order.Id select w)); } } db.Requests.DeleteAllOnSubmit((from w in db.Requests where w.Id == orders.orders[0].Order.RequestId select w)); db.Orders.DeleteAllOnSubmit((from w in db.Orders where w.RequestId == orders.orders[0].Order.RequestId select w)); db.SubmitChanges(); } decimal tranCharge = 0; decimal tranChargeConfig = (from w in db.Configs select w).First().TrnChrg ?? 0; var config = (from w in db.Configs select w).First(); decimal Caspikup = config.CashPickUp ?? 0; decimal CaspikupPer = config.CashPickUpPercent ?? 0; //////////////////REQUEST START Request objRequest = new Request(); objRequest.CreatedDate = DateTime.Now; objRequest.UserId = customerId; objRequest.CreatedBy = customerId; if (method == "14") //Cash pikup delivery charges by yourguy { objRequest.YourGuyChkPickUP = Convert.ToInt32(Caspikup); } //create a request id db.Requests.InsertOnSubmit(objRequest); db.SubmitChanges(); //////////////////REQUEST END TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"); DateTime indianTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE); foreach (var order in orders.orders) { Caspikup = 0;// resetting 0 becuasue unable to divide charges in n order so making o, actial charges are in Request table order.Order.RequestId = objRequest.Id; order.Order.CustomerId = customerId; order.Order.OrderDate = indianTime;// DateTime.Now; order.Order.OrderStartDate = order.OrderDetailList[0].DeliverDate; tranCharge = ((order.payment.Amount + order.payment.DeliveryChrg) * tranChargeConfig / 100) ?? 0; order.Order.TotalPayment = (method == "11" || method == "12" || method == "13")?0:(order.payment.Amount + tranCharge + order.payment.DeliveryChrg); if (method == "14")//Cas pikup { order.Order.TotalPayment = (method == "11" || method == "12" || method == "13") ? 0 : (order.payment.Amount + Caspikup + order.payment.DeliveryChrg); } db.Orders.InsertOnSubmit(order.Order); db.SubmitChanges(); if (method == "14") //Cash pikup delivery { order.payment.TrnChrg = Convert.ToDecimal(Caspikup + CaspikupPer * (order.payment.Amount + order.payment.DeliveryChrg) / 100); //Round off for cash pickup } else if (method == "11" || method == "12" || method == "13") { order.payment.TrnChrg = 0; //Add 0 if offline else calculate trans charge } else { order.payment.TrnChrg = tranCharge; //for online calculate trans charge } 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; HttpContext.Current.Session["OrderList"] = orders; CreateCookieOrderList(); return(objRequest.Id);// orderDTO.Order.Id; } }
public static int SendMsgToAgent(Message msg) { using (DBKOMPDataContext db = new DBKOMPDataContext()) { db.Messages.InsertOnSubmit(msg); db.SubmitChanges(); #region Send Mail string content = string.Empty; string filepath = "~/Email/UserMessage.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("$USER$", msg.name); content = content.Replace("$MESSAGE$", msg.message1); content = content.Replace("$EMAIL$", msg.email); content = content.Replace("$MOBILE$", msg.mobile); 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<", ""); //MailHelper.SendMailMessage("", objtblUser.email, string.Empty, string.Empty, "Thanks for Posting", content); //MailHelper.SendMailMessage("", "*****@*****.**", string.Empty, string.Empty, "User message", content); string ownerEmailId1 = ConfigurationManager.AppSettings["OwnerEmailID1"].ToString(); MailHelper.SendMailMessage("", ownerEmailId1, string.Empty, string.Empty, "Visitor's message", content); string ownerEmailId2 = ConfigurationManager.AppSettings["OwnerEmailID2"].ToString(); MailHelper.SendMailMessage("", ownerEmailId2, string.Empty, string.Empty, "Visitor's message", content); #endregion return(1); } }
public static int InsertUpdateUserDetails(User objtblUser) { int savetype = 0; string content = string.Empty; using (DBKOMPDataContext db = new DBKOMPDataContext()) { var countUser = (from w in db.Users where (objtblUser.UserLoginID != string.Empty && w.email == objtblUser.UserLoginID) select w).Count(); if (countUser == 0) { objtblUser.password = objtblUser.FirstName.Substring(0, 2) + "9876"; db.Users.InsertOnSubmit(objtblUser); string filepath = "~/Email/NewRegistration.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(); string uid = string.IsNullOrEmpty(objtblUser.email) ? objtblUser.UserLoginID : objtblUser.email; content = content.Replace("$UID$", uid); content = content.Replace("$PWD$", objtblUser.password); content = content.Replace("$NAME$", objtblUser.FirstName); content = content.Replace("$SITE$", site); string encryptemailid = EncryptDecrypt.EncryptString(objtblUser.email, "kota@1234"); encryptemailid = encryptemailid.Replace("+", "_"); string hreflnk = "http://www." + site + "/Register.aspx?rid=" + encryptemailid; content = content.Replace("$PROFILE$", hreflnk); 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(objtblUser.email)) { MailHelper.SendMailMessage("", objtblUser.email, string.Empty, string.Empty, "Welcome to " + site, content); // AutoServices.SendeMailToUs("Copy:Welcome to " + site, content); } MailHelper.SendMailMessage("", ConfigurationManager.AppSettings["OwnerEmailID1"].ToString(), string.Empty, string.Empty, "Copy : Welcome to " + site, "Below Mail Details for new user<br/><br/>" + content); //MailHelper.SendMailMessage("", ConfigurationManager.AppSettings["OwnerEmailID2"].ToString(), string.Empty, string.Empty, "Copy : Welcome to " + site, "Below Mail Details for new user<br/><br/>" + content); //string ownerEmailId = ConfigurationManager.AppSettings["OwnerEmailID"].ToString(); //MailHelper.SendMailMessage("", ownerEmailId, string.Empty, string.Empty, "New User is Created", "Below Mail Details for new user<br/><br/>" + content); } else { User tblus = db.Users.Single(p => (objtblUser.UserLoginID != string.Empty && p.UserLoginID == objtblUser.UserLoginID) || p.mobile == objtblUser.mobile); if (objtblUser.email == objtblUser.mobile && objtblUser.mobile != tblus.mobile) { tblus.email = objtblUser.mobile; tblus.UserLoginID = objtblUser.mobile; } tblus.email = objtblUser.email; tblus.UserType = objtblUser.UserType; tblus.FirstName = objtblUser.FirstName; tblus.LastName = objtblUser.LastName; tblus.mobile = objtblUser.mobile; tblus.picture = objtblUser.picture; tblus.LocationId = objtblUser.LocationId; tblus.WorkingSince = objtblUser.WorkingSince; tblus.STDCode = objtblUser.STDCode; tblus.LandLine = objtblUser.LandLine; tblus.LandLine1 = objtblUser.LandLine1; tblus.LandLine2 = objtblUser.LandLine2; tblus.WebsiteLink = objtblUser.WebsiteLink; tblus.SocialLink = objtblUser.SocialLink; tblus.Address = objtblUser.Address; tblus.AboutUs = objtblUser.AboutUs; tblus.CompanyName = objtblUser.CompanyName; tblus.CompanyLogo = objtblUser.CompanyLogo; } db.SubmitChanges(); savetype = objtblUser.UserId; return(savetype); } }
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; } }