예제 #1
0
 public ActionResult AddOrEdit(BKRY_CATEGORY bkt, HttpPostedFileBase file)
 {
     try
     {
         byte[] buf = null;
         if (file != null && file.ContentLength > 0)
         {
             buf = new byte[file.ContentLength];
             file.InputStream.Read(buf, 0, buf.Length);
             bkt.image = buf;
         }
         bkt.insert_by = Session != null && Session["UserName"] != null ? Session["UserName"].ToString() : "";
         bkt.add_date  = DateTime.Now;
         using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
         {
             if (bkt.Id == 0)
             {
                 db.BKRY_CATEGORY.Add(bkt);
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             else
             {
                 db.Entry(bkt).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex) {
         Console.WriteLine(ex.ToString());
     }
     return(null);
 }
예제 #2
0
        public ActionResult Getorder(int id)
        {
            List <GetOrderDetail>  bkryList      = new List <GetOrderDetail>();
            List <BKRY_ITEMS>      lstBKRY_ITEMS = new List <BKRY_ITEMS>();
            List <GetOrderDetail2> bkrList2      = new List <GetOrderDetail2>();

            using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
            {
                bkryList = db.GetOrderDetails.Where(x => x.OrderId == id).ToList <GetOrderDetail>();
                foreach (var item in bkryList)
                {
                    item.OrderDetails = null;
                    item.address      = item.address + " " + item.street + " " + item.postCode;
                    GetOrderDetail2 st = new GetOrderDetail2
                    {
                        add_dtee   = Convert.ToDateTime(item.Orderon).ToLongDateString(),
                        OrderId    = item.OrderId,
                        Orderon    = item.Orderon,
                        personname = item.personname,
                        email      = item.email,
                        address    = item.address,
                        Delivered  = item.Delivered
                    };
                    bkrList2.Add(st);
                }
                return(Json(new { data = bkrList2 }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #3
0
        // GET: Checkout
        public ActionResult Index()
        {
            List <BKRY_ITEMS> bkryList = new List <BKRY_ITEMS>();
            SYS_USR_INFO      bkryuser = new SYS_USR_INFO();

            if (Session != null && Session["Cart"] != null && ((List <int>)Session["Cart"]).Count > 0)
            {
                List <int> itemids = ((List <int>)Session["Cart"]);

                using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
                {
                    bkryList = db.BKRY_ITEMS.Where(x => itemids.Contains(x.Id)).ToList <BKRY_ITEMS>();
                    foreach (BKRY_ITEMS item in bkryList)
                    {
                        item.image    = null;
                        item.quantity = itemids.GroupBy(i => i).Where(x => x.Key == item.Id).FirstOrDefault().Count();
                    }
                }
            }
            if (Session != null && Session["userid"] != null && Session["ltype"] != null && Session["ltype"] != "" && Session["ltype"].ToString() == "2")
            {
                using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
                {
                    bkryuser = db.SYS_USR_INFO.Find(Convert.ToInt32((Session["userid"])));
                }
            }

            return(View(new Tuple <List <BKRY_ITEMS>, SYS_USR_INFO, BKRY_CREDITCARDINFO, BKRY_ORDER>(bkryList, bkryuser, null, null)));
        }
예제 #4
0
 public ActionResult AddOrEdit(BKRY_ITEMS bkt, HttpPostedFileBase file)
 {
     byte[] buf = null;
     if (file != null && file.ContentLength > 0)
     {
         buf = new byte[file.ContentLength];
         file.InputStream.Read(buf, 0, buf.Length);
         bkt.image = buf;
     }
     bkt.insert_by  = Session != null && Session["UserName"] != null ? Session["UserName"].ToString() : "";
     bkt.add_date   = DateTime.Now;
     bkt.categoryId = Convert.ToInt64(Request.Form["categoryname"] != "" ? Request.Form["categoryname"] : "0");
     using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
     {
         if (bkt.Id == 0)
         {
             db.BKRY_ITEMS.Add(bkt);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             db.Entry(bkt).State = EntityState.Modified;
             try
             {
                 db.SaveChanges();
             }
             catch (DbEntityValidationException e)
             {
                 throw e;
             }
             return(RedirectToAction("Index"));
         }
     }
 }
예제 #5
0
        public ActionResult GetData()
        {
            List <SYS_USR_INFO> ListSYS_USR_INFO = new List <SYS_USR_INFO>();

            using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
            {
                ListSYS_USR_INFO = db.SYS_USR_INFO.ToList();
            }
            return(Json(new { data = ListSYS_USR_INFO }, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
 public JsonResult DeleteUser(string id)
 {
     using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
     {
         var search = db.SYS_USR_INFO.ToList().Where(x => x.UserId == Convert.ToInt32(id)).FirstOrDefault();
         db.SYS_USR_INFO.Remove(search);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #7
0
 public ActionResult Delete(int id)
 {
     using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
     {
         BKRY_ITEMS emp = db.BKRY_ITEMS.Where(x => x.Id == id).FirstOrDefault <BKRY_ITEMS>();
         db.BKRY_ITEMS.Remove(emp);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #8
0
        public ActionResult Cfeedback()
        {
            List <CUST_FEED> obj = new List <CUST_FEED>();

            using (db = new BKRY_MNGT_SYSEntities())
            {
                obj = db.CUST_FEED.OrderByDescending(x => x.Feedback_Id).ToList();
            }
            return(View(obj));
        }
예제 #9
0
        public ActionResult GetReport(string nm_rpttype, string nm_dtfrom, string nm_dtTo)
        {
            List <BKRY_ORDER> obh = new List <BKRY_ORDER>();

            using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
            {
                switch (nm_rpttype)
                {
                case "1":
                    List <LoginDetail> LoginDetailList  = db.LoginDetails.ToList <LoginDetail>();
                    List <LoginDetail> LoginDetailList2 = new List <LoginDetail>();
                    LoginDetail        item             = new LoginDetail();
                    LoginDetailList = LoginDetailList.Where(x => x.LoginTime >= (nm_dtfrom != "" ? Convert.ToDateTime(nm_dtfrom) : DateTime.Now) && x.LoginTime <= (nm_dtTo != "" ? Convert.ToDateTime(nm_dtTo).AddDays(1).AddTicks(-1) : DateTime.Now)).ToList();
                    foreach (var item2 in LoginDetailList)
                    {
                        item2.add_dtee = Convert.ToDateTime(item2.LoginTime).ToLongDateString();
                        item           = item2;
                        LoginDetailList2.Add(item);
                    }
                    return(Json(new { data = LoginDetailList2 }, JsonRequestBehavior.AllowGet));

                case "2":
                    var BKRY_ORDERList = db.BKRY_DELIVERY.Join(db.BKRY_ORDER, a => a.OrderId, b => b.Id, (a, b) => new { a, b }).Select(s => new BKRY_ORDER2
                    {
                        OrderId     = ((int)s.a.OrderId).ToString(),
                        personname  = s.b.personname,
                        address     = s.b.address,
                        postCode    = s.b.postCode,
                        Orderon     = (DateTime)s.b.inserted_dt,
                        Delivered   = s.a.DeliveryStatus == 0 ? "No" : s.a.DeliveryStatus == 1 ? "Dispatched" : s.a.DeliveryStatus == 2 ? "Near By" : "Yes",
                        PaymentType = s.a.PaymentType == 0 ? "Cash on Delivery" : "Credit Card Payment"
                    }).ToList().Where(y => y.Orderon >= (nm_dtfrom != "" ? Convert.ToDateTime(nm_dtfrom) : DateTime.Now) && y.Orderon <= (nm_dtTo != "" ? Convert.ToDateTime(nm_dtTo).AddDays(1).AddTicks(-1) : DateTime.Now));
                    foreach (BKRY_ORDER2 item3 in BKRY_ORDERList)
                    {
                        item3.add_dtee = Convert.ToDateTime(item3.Orderon).ToLongDateString();
                    }
                    return(Json(new { data = BKRY_ORDERList.ToList <BKRY_ORDER2>() }, JsonRequestBehavior.AllowGet));

                case "3":
                    List <BKRY_ITEMS> bkryList = db.BKRY_ITEMS.ToList <BKRY_ITEMS>();
                    bkryList = bkryList.Where(x => x.add_date >= (nm_dtfrom != "" ? Convert.ToDateTime(nm_dtfrom) : DateTime.Now) && x.add_date <= (nm_dtTo != "" ? Convert.ToDateTime(nm_dtTo).AddDays(1).AddTicks(-1) : DateTime.Now)).ToList <BKRY_ITEMS>();
                    foreach (BKRY_ITEMS item3 in bkryList)
                    {
                        item3.image    = null;
                        item3.add_dtee = Convert.ToDateTime(item3.expiry_dte).ToLongDateString();
                    }
                    return(Json(new { data = bkryList }, JsonRequestBehavior.AllowGet));

                default:
                    break;
                }
                return(null);
            }
        }
예제 #10
0
 public ActionResult GetShowItemsData(int id)
 {
     using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
     {
         List <BKRY_ITEMS> bkryList = id == 0 ? db.BKRY_ITEMS.ToList <BKRY_ITEMS>()  : db.BKRY_ITEMS.Where(x => x.categoryId == id).ToList <BKRY_ITEMS>();
         foreach (BKRY_ITEMS item in bkryList)
         {
             item.image = null;
         }
         return(Json(new { data = bkryList }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #11
0
 public ActionResult GetData()
 {
     using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
     {
         List <BKRY_CATEGORY> bkryList = db.BKRY_CATEGORY.ToList <BKRY_CATEGORY>();
         foreach (BKRY_CATEGORY item in bkryList)
         {
             item.image    = null;
             item.add_dtee = Convert.ToDateTime(item.add_date).ToLongDateString();
         }
         return(Json(new { data = bkryList }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #12
0
 public ActionResult AddOrEdit(int id = 0)
 {
     if (id == 0)
     {
         return(View(new BKRY_CATEGORY()));
     }
     else
     {
         using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
         {
             return(View(db.BKRY_CATEGORY.Where(x => x.Id == id).FirstOrDefault <BKRY_CATEGORY>()));
         }
     }
 }
예제 #13
0
        // GET: SignUp
        public ActionResult Index(int id = 0)
        {
            SYS_USR_INFO obj = new SYS_USR_INFO();

            if (id != 0)
            {
                using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
                {
                    obj = db.SYS_USR_INFO.Where(x => x.UserId == id).FirstOrDefault();
                }
                return(View(obj));
            }
            return(View());
        }
예제 #14
0
 public JsonResult UserAlreadyExistsAsync(string user)
 {
     using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
     {
         var search = db.SYS_USR_INFO.Where(x => x.UserName == user).SingleOrDefault();
         if (search != null)
         {
             return(Json(search, JsonRequestBehavior.AllowGet));
         }
         else
         {
             return(Json(0));
         }
     }
 }
예제 #15
0
 public ActionResult CreateFeedback()
 {
     using (db = new BKRY_MNGT_SYSEntities())
     {
         CUST_FEED obj = new CUST_FEED();
         obj.Customer_ID = null;
         obj.Order_id    = Session["Order"].ToString();
         obj.feedback    = Request.Form["feedback"].ToString();
         obj.Creation_Id = DateTime.Now.ToShortDateString();
         db.CUST_FEED.Add(obj);
         db.SaveChanges();
     }
     Session["Message"] = null;
     Session["Order"]   = null;
     return(RedirectToAction("Index", "Home"));
 }
예제 #16
0
        public ActionResult GetorderDetails(int id)
        {
            List <GetOrderDetail> bkryList      = new List <GetOrderDetail>();
            List <BKRY_ITEMS>     lstBKRY_ITEMS = new List <BKRY_ITEMS>();

            using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
            {
                bkryList = db.GetOrderDetails.Where(x => x.OrderId == id).ToList <GetOrderDetail>();
                foreach (var item in bkryList)
                {
                    lstBKRY_ITEMS = Newtonsoft.Json.JsonConvert.DeserializeObject <List <BKRY_ITEMS> >(item.OrderDetails);
                    item.address  = item.address + " " + item.street + " " + item.postCode;
                }
                return(PartialView("~/Views/Order/OrderDetails.cshtml", lstBKRY_ITEMS));
            }
        }
        public void UserNameExists(string userName)
        {
            bool userNameInUse = false;

            using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
            {
                var username         = new SqlParameter("@UserName", userName);
                var objuserNameInUse = db.Database.SqlQuery <Registration>("spUserNameExists @UserName", username);
            }

            Registration registration = new Registration();

            registration.Username      = userName;
            registration.Usernameinuse = userNameInUse;
            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Write(js.Serialize(registration));
        }
예제 #18
0
        public ActionResult GetCartData()
        {
            List <BKRY_ITEMS> bkryList = new List <BKRY_ITEMS>();

            if (Session != null && Session["Cart"] != null && ((List <int>)Session["Cart"]).Count > 0)
            {
                List <int> itemids = ((List <int>)Session["Cart"]);

                using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
                {
                    bkryList = db.BKRY_ITEMS.Where(x => itemids.Contains(x.Id)).ToList <BKRY_ITEMS>();
                    foreach (BKRY_ITEMS item in bkryList)
                    {
                        item.image    = null;
                        item.quantity = itemids.GroupBy(i => i).Where(x => x.Key == item.Id).FirstOrDefault().Count();
                    }
                    return(Json(new { data = bkryList }, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(new { data = bkryList }, JsonRequestBehavior.AllowGet));
        }
예제 #19
0
        public ActionResult AddOrEdit(int id = 0)
        {
            List <BKRY_CATEGORY> bkryList = null;

            using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
            {
                bkryList = db.BKRY_CATEGORY.ToList <BKRY_CATEGORY>();
            }
            ViewBag.Category = bkryList;
            if (id == 0)
            {
                return(View(new BKRY_ITEMS()));
            }
            else
            {
                using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
                {
                    return(View(db.BKRY_ITEMS.Where(x => x.Id == id).FirstOrDefault <BKRY_ITEMS>()));
                }
            }
        }
예제 #20
0
        public static void startDeliveryFunction()
        {
            List <BKRY_DELIVERY> bkryList = null;

            using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
            {
                bkryList = db.BKRY_DELIVERY.Where(x => x.DeliveryStatus == null || x.DeliveryStatus == oldstatus).ToList <BKRY_DELIVERY>();
                foreach (var item in bkryList)
                {
                    item.DeliveryStatus = status;
                }
                db.SaveChanges();
            }
            if (Helper.status == 3)
            {
                oldstatus = -1;
                status    = 0;
            }
            else
            {
                oldstatus = status;
                status   += 1;
            }
        }
예제 #21
0
        public ActionResult Autherize(BakerySystem.Models.SYS_USR_INFO userModel)
        {
            string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (string.IsNullOrEmpty(ipAddress))
            {
                ipAddress = Request.ServerVariables["REMOTE_ADDR"];
            }
            Dictionary <string, string> osList = new Dictionary <string, string>
            {
                { "Windows NT 6.3", "Windows 8.1" },
                { "Windows NT 6.2", "Windows 8" },
                { "Windows NT 6.1", "Windows 7" },
                { "Windows NT 6.0", "Windows Vista" },
                { "Windows NT 5.2", "Windows Server 2003" },
                { "Windows NT 5.1", "Windows XP" },
                { "Windows NT 5.0", "Windows 2000" }
            };

            string userAgentText = Request.UserAgent;
            string osVersion     = "";

            if (userAgentText != null)
            {
                int startPoint = userAgentText.IndexOf('(') + 1;
                int endPoint   = userAgentText.IndexOf(';');

                osVersion = userAgentText.Substring(startPoint, (endPoint - startPoint));
                //string friendlyOsName = osList[osVersion];

                SYS_USR_INFO info = new SYS_USR_INFO()
                {
                    MachineIP = ipAddress, OperatingSystem = osVersion
                };
            }
            if ("admin" == userModel.UserName && "admin" == userModel.UserPassowrd)
            {
                Session["userID"]   = "1";
                Session["userName"] = "******";
                Session["ltype"]    = "1";
                return(View("~/Views/adminPanel/Index.cshtml"));
            }
            else
            {
                using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
                {
                    var userDetails = db.SYS_USR_INFO.Where(x => x.UserName == userModel.UserName && x.UserPassowrd == userModel.UserPassowrd).FirstOrDefault();
                    if (userDetails == null)
                    {
                        userModel.LoginErrorMessage = "Wrong username or password.";
                        return(View("Index", userModel));
                    }
                    else
                    {
                        Session["userID"]   = userDetails.UserId;
                        Session["userName"] = userDetails.UserName;
                        Session["ltype"]    = "2";
                        LoginDetail ld = new LoginDetail();
                        ld.UserId          = userDetails.UserId;
                        ld.UserName        = userDetails.UserName;
                        ld.OperatingSystem = osVersion;
                        ld.MachineIP       = ipAddress;
                        ld.UserPassowrd    = userDetails.UserPassowrd;
                        ld.LoginTime       = DateTime.Now;
                        db.LoginDetails.Add(ld);
                        db.SaveChanges();
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }
        }
예제 #22
0
        public ActionResult CreateOrder()
        {
            List <BKRY_ITEMS> bkryList = new List <BKRY_ITEMS>();

            if (Session != null && Session["Cart"] != null && ((List <int>)Session["Cart"]).Count > 0)
            {
                List <int> itemids = ((List <int>)Session["Cart"]);

                using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
                {
                    bkryList = db.BKRY_ITEMS.Where(x => itemids.Contains(x.Id)).ToList <BKRY_ITEMS>();
                    foreach (BKRY_ITEMS item in bkryList)
                    {
                        item.image    = null;
                        item.quantity = itemids.GroupBy(i => i).Where(x => x.Key == item.Id).FirstOrDefault().Count();
                    }
                }
            }
            try
            {
                using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
                {
                    BKRY_ORDER obj = new BKRY_ORDER();
                    obj.OrderDetails = JsonConvert.SerializeObject(bkryList);
                    obj.personname   = Request["name"].ToString();
                    obj.phone        = Request["phone"].ToString();
                    obj.email        = Request["email"].ToString();
                    obj.address      = Request["address"].ToString();
                    obj.street       = Request["street"].ToString();
                    obj.postCode     = Request["postcode"].ToString();
                    obj.inserted_dt  = DateTime.Now;

                    db.BKRY_ORDER.Add(obj);
                    db.SaveChanges();
                    Session["Cart"] = null;
                    BKRY_DELIVERY dobj = new BKRY_DELIVERY();
                    dobj.OrderDetails   = JsonConvert.SerializeObject(bkryList);
                    dobj.OrderId        = obj.Id;
                    dobj.inserted_dt    = DateTime.Now;
                    dobj.DeliveryStatus = 0;
                    dobj.PaymentType    = Convert.ToInt16(Request.Form["nm_rad_pay"]);
                    if (dobj.PaymentType == 1)
                    {
                        BKRY_CREDITCARDINFO objC = new BKRY_CREDITCARDINFO();
                        objC.OrderID    = obj.Id;
                        objC.cardname   = Request["cardname"].ToString();
                        objC.cardnumber = Request["cardnumber"].ToString();
                        objC.expyear    = Request["expyear"].ToString();
                        objC.cvv        = Request["cvv"].ToString();
                        objC.expmonth   = " ";
                        db.BKRY_CREDITCARDINFO.Add(objC);
                    }
                    db.BKRY_DELIVERY.Add(dobj);
                    db.SaveChanges();
                    Session["Message"] = "Saved Successfully your Order# is " + obj.Id.ToString();
                    Session["Order"]   = obj.Id;
                    return(RedirectToAction("Index", "home"));
                }
            }
            catch (Exception ex) {
                return(Json(new { success = true, message = "UnSuccessfully" }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #23
0
        public FileResult PrintDetails(int id)
        {
            string pdfFilename = "";
            string line        = "";

            try
            {
                List <GetOrderDetail>  bkryList      = new List <GetOrderDetail>();
                List <BKRY_ITEMS>      lstBKRY_ITEMS = new List <BKRY_ITEMS>();
                List <GetOrderDetail2> bkrList2      = new List <GetOrderDetail2>();
                using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
                {
                    bkryList = db.GetOrderDetails.Where(x => x.OrderId == id).ToList <GetOrderDetail>();
                    foreach (var item in bkryList)
                    {
                        line += "Bakery System " + " \n";
                        line += "*****************************************************" + " \n";
                        line += "Order # : " + item.OrderId + " \n";
                        line += "Person Name : " + item.personname + " \n";
                        line += "Address : " + item.address + " \n";
                        line += "Street : " + item.street + " \n";
                        line += "PostCode : " + item.postCode + " \n";
                        line += "Email  : " + item.email + " \n";
                        line += "Order On  : " + Convert.ToDateTime(item.Orderon).ToLongDateString() + " \n";
                        line += "*****************************************************" + " \n";
                        line += "Item Details" + "\n";
                        decimal pp = 0;
                        foreach (var Oitem in JsonConvert.DeserializeObject <List <BKRY_ITEMS> >(item.OrderDetails))
                        {
                            line += "Product : " + Oitem.name + " Quantity : " + Oitem.quantity + " Price : " + Oitem.price + " \n";
                            pp   += (Convert.ToDecimal(Oitem.price) * Convert.ToDecimal(Oitem.quantity));
                        }
                        line += "*****************************************************" + " \n";
                        line += "Total : " + pp + " \n ";
                    }
                }
                int         yPoint = 0;
                PdfDocument pdf    = new PdfDocument();
                pdf.Info.Title = "Bakery System Order No #" + id;
                PdfPage   pdfPage = pdf.AddPage();
                XGraphics graph   = XGraphics.FromPdfPage(pdfPage);
                XFont     font    = new XFont("Verdana", 8, XFontStyle.Regular);
                //graph.DrawString(line, font, XBrushes.Black, pdfPage.Width.Point, pdfPage.Height.Point);
                foreach (var item in line.Split('\n'))
                {
                    graph.DrawString(item, font, XBrushes.Black, new XRect(40, yPoint, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft);
                    yPoint = yPoint + 10;
                }


                pdfFilename = Server.MapPath("~/Temp/txttopdf" + DateTime.Now.ToString("mmddyyyyhhMMss") + ".pdf");
                pdf.Save(pdfFilename);
            }
            catch (Exception ex)
            {
            }
            byte[] fileBytes = System.IO.File.ReadAllBytes(pdfFilename);
            string fileName  = "txttopdf" + DateTime.Now.ToString("mmddyyyyhhMMss") + ".pdf";

            return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName));
        }
예제 #24
0
 public HomeController()
 {
     db = new BKRY_MNGT_SYSEntities();
 }
예제 #25
0
        public ActionResult CreateUser(SYS_USR_INFO objOn)
        {
            string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

            if (string.IsNullOrEmpty(ipAddress))
            {
                ipAddress = Request.ServerVariables["REMOTE_ADDR"];
            }
            Dictionary <string, string> osList = new Dictionary <string, string>
            {
                { "Windows NT 6.3", "Windows 8.1" },
                { "Windows NT 6.2", "Windows 8" },
                { "Windows NT 6.1", "Windows 7" },
                { "Windows NT 6.0", "Windows Vista" },
                { "Windows NT 5.2", "Windows Server 2003" },
                { "Windows NT 5.1", "Windows XP" },
                { "Windows NT 5.0", "Windows 2000" }
            };

            string userAgentText = Request.UserAgent;
            string osVersion     = "";

            if (userAgentText != null)
            {
                int startPoint = userAgentText.IndexOf('(') + 1;
                int endPoint   = userAgentText.IndexOf(';');

                osVersion = userAgentText.Substring(startPoint, (endPoint - startPoint));
                //string friendlyOsName = osList[osVersion];
            }
            SYS_USR_INFO userinfo = new SYS_USR_INFO();

            try
            {
                using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
                {
                    SYS_USR_INFO obj = new SYS_USR_INFO
                    {
                        UserId            = (objOn.UserId > 0) ? objOn.UserId : 0,
                        UserName          = objOn.UserName,
                        UserPassowrd      = objOn.UserPassowrd,
                        MachineIP         = ipAddress,
                        OperatingSystem   = osVersion,
                        LoginTime         = DateTime.Now,
                        LoginErrorMessage = JsonConvert.SerializeObject(userinfo),
                        address           = objOn.address,
                        email             = objOn.email,
                        street            = objOn.street,
                        phone             = objOn.phone,
                        postCode          = objOn.postCode
                    };

                    if (db.SYS_USR_INFO.Where(x => x.UserName == obj.UserName).ToList().Count == 0)
                    {
                        db.SYS_USR_INFO.Add(obj);
                        db.Entry(obj).State = EntityState.Added;

                        db.SaveChanges();
                        Session["Message"] = "Saved Successfully your UserName# is " + obj.UserName.ToString();
                    }
                    else
                    {
                        db.SYS_USR_INFO.Remove(db.SYS_USR_INFO.Where(x => x.UserName == obj.UserName).ToList().FirstOrDefault());
                        db.SYS_USR_INFO.Add(obj);
                        db.SaveChanges();
                        Session["Message"] = "Updated Successfully your UserName# is " + obj.UserName.ToString();
                    }
                    return(RedirectToAction("LogOut", "Login"));
                }
            }
            catch (Exception ex) { return(Json(new { success = true, message = "UnSuccessfully" + ex.ToString() }, JsonRequestBehavior.AllowGet)); }
        }