Ejemplo n.º 1
0
        public void SaveSubAllotmentsAmount(String fsh, String data)
        {
            List <Object> list = JsonConvert.DeserializeObject <List <Object> >(data);
            Int32         id   = 0;

            foreach (Object s in list)
            {
                try
                {
                    dynamic sb = JsonConvert.DeserializeObject <dynamic>(s.ToString());
                    if (UacsHelper.ExpenseExist(Convert.ToString(sb.expense_title)))
                    {
                        id = Convert.ToInt32(sb.ID);
                        var fsa = db.fsa.Where(p => p.ID == id && p.fundsource == fsh).FirstOrDefault();
                        fsa.expense_title = sb.expense_title;
                        fsa.amount        = Convert.ToDouble(sb.amount);
                        try { db.SaveChanges(); } catch { }
                    }
                }
                catch (Exception ex)
                {
                    dynamic sb = JsonConvert.DeserializeObject <dynamic>(s.ToString());
                    try
                    {
                        if (UacsHelper.ExpenseExist(Convert.ToString(sb.expense_title)))
                        {
                            if (sb.expense_title != null)
                            {
                                Object uacs_obj      = sb.expense_title;
                                String uacs          = uacs_obj.ToString();
                                var    expense_exist = (from exist in db.fsa where exist.expense_title == uacs && exist.fundsource == fsh select exist).ToList();
                                if (expense_exist.Count <= 0)
                                {
                                    FundSourceAmount fsa = new FundSourceAmount();
                                    fsa.expense_title = sb.expense_title;
                                    try { fsa.amount = Convert.ToDouble(sb.amount); } catch { fsa.amount = 0.00; }
                                    fsa.fundsource = fsh;
                                    db.fsa.Add(fsa);
                                    try { db.SaveChanges(); } catch { }
                                }
                            }
                        }
                    }
                    catch { }
                }
            }
        }
Ejemplo n.º 2
0
        public JsonResult SaveExpenseSubAllotment(FormCollection collection)
        {
            List <Object> list = JsonConvert.DeserializeObject <List <Object> >(collection.Get("data"));

            Int32 id = 0;

            foreach (Object s in list)
            {
                try
                {
                    dynamic sb = JsonConvert.DeserializeObject <dynamic>(s.ToString());
                    id = Convert.ToInt32(sb.ID);
                    // var fsa = db.expense_suballotment_expensecode.Where(p => p.ID == id ).FirstOrDefault();
                    //fsa.expensecode = sb.expense_code;
                    // fsa.amount = Convert.ToDouble(sb.amount);
                    try { db.SaveChanges(); } catch { }
                }
                catch (Exception ex)
                {
                    dynamic sb = JsonConvert.DeserializeObject <dynamic>(s.ToString());
                    try
                    {
                        if (sb.expense_code != null)
                        {
                            Object uacs_obj      = sb.expense_code;
                            String uacs          = uacs_obj.ToString();
                            var    expense_exist = (from exist in db.fsa where exist.expense_title == uacs && exist.fundsource == collection.Get("fundsource") select exist).ToList();
                            if (expense_exist.Count <= 0)
                            {
                                FundSourceAmount fsa = new FundSourceAmount();
                                fsa.expense_title = sb.expense_title;
                                try { fsa.amount = Convert.ToDouble(sb.amount); } catch { fsa.amount = 0.00; }
                                fsa.fundsource = collection.Get("fundsource");
                                db.fsa.Add(fsa);
                                try { db.SaveChanges(); } catch { }
                            }
                        }
                    }
                    catch { }
                }
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public JsonResult SaveOrsObligation(FormCollection collection)
        {
            Int32         id      = Convert.ToInt32(collection.Get("ID"));
            String        data    = collection.Get("data");
            Int32         line_id = 0;
            List <Object> list    = JsonConvert.DeserializeObject <List <Object> >(data);

            foreach (Object s in list)
            {
                try
                {
                    dynamic sb             = JsonConvert.DeserializeObject <dynamic>(s.ToString());
                    String  expenese_title = (String)sb.expense_title;
                    var     uacs           = db.uacs.Where(p => p.Title == expenese_title).FirstOrDefault();
                    if (uacs != null)
                    {
                        line_id = Convert.ToInt32(sb.ID);
                        var ors_uacs = db.ors_expense_codes.Where(p => p.ID == line_id).FirstOrDefault();

                        if (User.IsInRole("Admin") || User.IsInRole("Employee"))
                        {
                            ors_uacs.uacs = sb.expense_title;

                            try { ors_uacs.amount = Convert.ToDouble(sb.amount); } catch { ors_uacs.amount = 0.00; }
                            try { ors_uacs.NetAmount = Convert.ToDouble(sb.NetAmount); } catch { ors_uacs.NetAmount = 0.00; }
                            try { ors_uacs.TaxAmount = Convert.ToDouble(sb.TaxAmount); } catch { ors_uacs.TaxAmount = 0.00; }
                            try { ors_uacs.Others = Convert.ToDouble(sb.Others); } catch { ors_uacs.Others = 0.00; }
                        }
                        else if (User.IsInRole("Cashier"))
                        {
                            try { ors_uacs.NetAmount = Convert.ToDouble(sb.NetAmount); } catch { ors_uacs.NetAmount = 0.00; }
                            try { ors_uacs.TaxAmount = Convert.ToDouble(sb.TaxAmount); } catch { ors_uacs.TaxAmount = 0.00; }
                            try { ors_uacs.Others = Convert.ToDouble(sb.Others); } catch { ors_uacs.Others = 0.00; }
                        }

                        try { db.SaveChanges(); } catch { }
                    }
                }
                catch (Exception ex)
                {
                    dynamic sb = JsonConvert.DeserializeObject <dynamic>(s.ToString());
                    try
                    {
                        String expenese_title = (String)sb.expense_title;
                        var    uacs           = db.uacs.Where(p => p.Title == expenese_title).FirstOrDefault();
                        if (uacs != null)
                        {
                            if (User.IsInRole("Admin") || User.IsInRole("Cashier"))
                            {
                                var uacs_exist = (from exist in db.ors_expense_codes where exist.uacs == expenese_title && exist.ors_obligation == id select exist).ToList();
                                if (uacs_exist.Count <= 0)
                                {
                                    ORS_EXPENSE_CODES oec = new ORS_EXPENSE_CODES();
                                    oec.uacs           = sb.expense_title;
                                    oec.ors_obligation = id;
                                    try { oec.amount = Convert.ToDouble(sb.amount); } catch { oec.amount = 0.00; }
                                    try { oec.TaxAmount = Convert.ToDouble(sb.TaxAmount); } catch { oec.TaxAmount = 0.00; }
                                    try { oec.NetAmount = Convert.ToDouble(sb.NetAmount); } catch { oec.NetAmount = 0.00; }
                                    try { oec.Others = Convert.ToDouble(sb.Others); } catch { oec.Others = 0.00; }
                                    db.ors_expense_codes.Add(oec);
                                    db.SaveChanges();

                                    ORSHelper.InsertORSNo(id);

                                    var ors_allotments = (from ors in db.ors
                                                          join allotments in db.allotments on ors.allotment equals allotments.ID
                                                          where ors.ID == id
                                                          select new
                                    {
                                        _allotment = allotments.ID,
                                        fundsource_id = (from _fsh in db.fsh where _fsh.allotment == allotments.ID.ToString() && _fsh.Code == ors.FundSource select _fsh.ID).FirstOrDefault()
                                    }).FirstOrDefault();

                                    var ors_fundsource_uacs = (from _fsa in db.fsa where _fsa.fundsource == ors_allotments.fundsource_id.ToString() && _fsa.expense_title == oec.uacs select _fsa.ID).ToList();

                                    if (ors_fundsource_uacs.Count <= 0)
                                    {
                                        FundSourceAmount new_fsa = new FundSourceAmount();
                                        new_fsa.expense_title = oec.uacs;
                                        new_fsa.amount        = 0;
                                        new_fsa.fundsource    = ors_allotments.fundsource_id.ToString();
                                        db.fsa.Add(new_fsa);
                                        db.SaveChanges();
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception innerex) { }
                }
            }
            return(GetORSUacs(id.ToString()));
        }