예제 #1
0
 public void Allotment(FormCollection collection)
 {
     db.Database.ExecuteSqlCommand("UPDATE Allotments SET active = '" + collection.Get("status") + "' WHERE ID = '" + collection.Get("allotment") + "'");
     // db.Database.ExecuteSqlCommand("UPDATE ORSMasters SET active = '" + collection.Get("status") + "' WHERE allotments ='" + collection.Get("allotment") + "'");
     db.Database.ExecuteSqlCommand("UPDATE FundSourceHdrs SET active = '" + collection.Get("status") + "' WHERE allotment ='" + collection.Get("allotment") + "'");
     db.SaveChanges();
 }
예제 #2
0
        public JsonResult SaveORPS(String data)
        {
            List <Object> list          = JsonConvert.DeserializeObject <List <Object> >(data);
            Int32         id            = 0;
            Int32         ors_allotment = Convert.ToInt32(GlobalData.ors_allotment);
            String        DateFormat    = "yyyy-MM-dd HH:mm:ss";

            foreach (Object s in list)
            {
                try
                {
                    dynamic sb               = JsonConvert.DeserializeObject <dynamic>(s.ToString());
                    String  fundsource       = (String)sb.FundSource;
                    var     fundsource_exist = db.fsh.Where(p => p.allotment.ToString() == GlobalData.ors_allotment && p.Code == fundsource).ToList();

                    if (fundsource_exist.Count > 0)
                    {
                        id = Convert.ToInt32(sb.ID);
                        var    ors  = db.ors.Where(p => p.ID == id).Where(p => p.allotment == ors_allotment).FirstOrDefault();
                        Object date = sb.Date;
                        ors.Date1 = date.ToString();
                        DateTime datetime = Convert.ToDateTime(date.ToString());
                        ors.Date         = datetime;
                        ors.DB           = sb.DB;
                        ors.PO           = sb.PO;
                        ors.PR           = sb.PR;
                        ors.PAYEE        = sb.PAYEE;
                        ors.Adress       = sb.Adress;
                        ors.Particulars  = sb.Particulars;
                        ors.FundSource   = sb.FundSource;
                        ors.DateReceived = sb.DateReceived;
                        ors.TimeReceived = sb.TimeReceived;
                        ors.DateReleased = sb.DateReleased;
                        ors.TimeReleased = sb.TimeReleased;

                        try { db.SaveChanges(); } catch { }
                    }
                }
                catch (Exception ex)
                {
                    dynamic sb = JsonConvert.DeserializeObject <dynamic>(s.ToString());
                    try
                    {
                        String fundsource       = (String)sb.FundSource;
                        var    fundsource_exist = db.fsh.Where(p => p.allotment.ToString() == GlobalData.ors_allotment && p.Code == fundsource).ToList();

                        if (fundsource_exist.Count > 0)
                        {
                            if (sb.Date != null && sb.Particulars != null && sb.PAYEE != null)
                            {
                                ORS ors = new ORS();
                                ors.allotment = Convert.ToInt32(GlobalData.ors_allotment);
                                Object date = sb.Date;
                                ors.Date1 = date.ToString();
                                DateTime datetime = Convert.ToDateTime(date.ToString());
                                ors.Date         = datetime;
                                ors.DB           = sb.DB;
                                ors.PO           = sb.PO;
                                ors.PR           = sb.PR;
                                ors.PAYEE        = sb.PAYEE;
                                ors.Adress       = sb.Adress;
                                ors.Particulars  = sb.Particulars;
                                ors.FundSource   = sb.FundSource;
                                ors.Created_By   = User.Identity.GetUserName();
                                ors.DateReceived = sb.DateReceived;
                                ors.TimeReceived = sb.TimeReceived;
                                ors.DateReleased = sb.DateReleased;
                                ors.TimeReleased = sb.TimeReleased;
                                ors.Date_Added   = DateTime.Now;
                                ors.dateadded    = DateTime.Now.ToString(DateFormat);
                                db.ors.Add(ors);
                                try { db.SaveChanges(); } catch { }

                                try
                                {
                                    var           ors_master    = db.allotments.Where(p => p.ID.ToString() == GlobalData.ors_allotment).FirstOrDefault();
                                    Notifications notifications = new Notifications();
                                    notifications.Module    = "ORS, " + ors_master.Title;
                                    notifications.User      = User.Identity.GetUserName();
                                    notifications.Action    = " added a new ors obligation to";
                                    notifications.status    = "add";
                                    notifications.DateAdded = DateTime.Now;
                                    notifications.Year      = GlobalData.Year;
                                    db.notifications.Add(notifications);
                                    db.SaveChanges();
                                }
                                catch { }
                            }
                        }
                    }
                    catch { }
                }
            }
            return(GetOrsPS());
        }
예제 #3
0
        public ActionResult Create(FormCollection collection)
        {
            Allotments allotments = new Allotments();

            allotments.Title  = collection.Get("Title");
            allotments.Code   = collection.Get("code");
            allotments.active = 1;
            allotments.year   = GlobalData.Year;
            db.allotments.Add(allotments);

            Notifications n = new Notifications();

            n.Action    = "added " + allotments.Code + " budget allotment to";
            n.Module    = "Budget Allocations";
            n.User      = User.Identity.GetUserName();
            n.Year      = GlobalData.Year;
            n.DateAdded = DateTime.Now;
            n.status    = "add";
            db.notifications.Add(n);

            db.SaveChanges();
            return(RedirectToAction("Index"));
        }