Пример #1
0
        public ActionResult FundSource(String ID)
        {
            int id        = Convert.ToInt32(ID);
            var allotment = db.allotments.Where(p => p.ID == id).FirstOrDefault();

            GlobalData.allotment = allotment.ID.ToString();
            var fundsources = (from list in db.fsh where list.allotment == allotment.ID.ToString() && list.type == "REG" && list.active == 1 select list).ToList();

            ViewBag.Message = @GlobalData.Year + " Budget Fund Source for " + allotment.Code;
            ORS ors = new ORS();

            return(View(fundsources));
        }
Пример #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());
        }