コード例 #1
0
        public ActionResult DeletePassedOnBilling(int idToDelete, FormCollection frm)
        {
            var    id        = frm[0].ToString();
            int    CompanyId = int.Parse(id);
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            PassedOnBillingInformation passedOnBillingInformation = new PassedOnBillingInformation();

            passedOnBillingInformation = db.PassedOnBillingInformation.Find(idToDelete);
            db.PassedOnBillingInformation.Remove(passedOnBillingInformation);
            db.SaveChanges();
            PassedOnBillingViewModel passedonBillingViewModels = new PassedOnBillingViewModel();

            passedonBillingViewModels.CompanyList         = db.Company.Where(m => m.CompanyID == CompanyId).ToList();
            passedonBillingViewModels.PassedOnBillingList = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompanyId).ToList();
            try
            {
                passedonBillingViewModels.TotalAmount = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompanyId).Sum(x => x.Amount);
                SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Passed OnBilling - Delete Record -from Terminal:" + ipaddress);
            }
            catch (Exception)
            {
                passedonBillingViewModels.TotalAmount = 0;
            }

            ViewBag.CompanySelected = "OK";

            passedonBillingViewModels.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).ToList();
            var billp = passedonBillingViewModels.BillingPeriodList.OrderByDescending(m => m.BillingPeriodId);

            passedonBillingViewModels.BillingPeriodList = billp.ToList();
            TempData["TransactionSuccess"]  = "delete";
            TempData["PassedOnBillingData"] = passedonBillingViewModels;
            return(RedirectToAction("ViewPassedOnBillingPRG", "DataEntryPassedOnBilling"));
        }
コード例 #2
0
        public ActionResult DisplayPassedOnBilling(int CompId, FormCollection frmcollection)
        {
            PassedOnBillingViewModel searchcompany = new PassedOnBillingViewModel();

            searchcompany.ZoneList = db.Zone.Select(x => x).ToList();
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            var    username  = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.PassedOnBilling;
            PassedOnBillingViewModel SearchCompanyViewModels = new PassedOnBillingViewModel();

            if (frmcollection.Count == 0)
            {
                SearchCompanyViewModels.PassedOnBillingList = db.PassedOnBillingInformation.SqlQuery("Select * from SecurityGuardFeeInformations where CompanyId = '" + frmcollection["CompanyId"] + "'").ToList();
                SearchCompanyViewModels.TotalAmount         = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompId).Sum(x => x.Amount);
                return(View(SearchCompanyViewModels));
            }
            else if (frmcollection.Count >= 1)
            {
                PassedOnBillingViewModel passedonBillingViewModels = new PassedOnBillingViewModel();
                int parsedID = int.Parse(frmcollection["PassedOnBillingInformationId"]);
                PassedOnBillingInformation securityfee = db.PassedOnBillingInformation.Find(parsedID);
                //db.PassedOnBillingInformation.Remove(securityfee);
                //db.SaveChanges();
                passedonBillingViewModels.CompanyList         = db.Company.Where(m => m.CompanyID == CompId).ToList();
                passedonBillingViewModels.PassedOnBillingList = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompId).ToList();
                passedonBillingViewModels.TotalAmount         = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompId).Sum(x => x.Amount);
                return(View("ViewPassedOnBilling", passedonBillingViewModels));
            }
            ViewBag.CompanySelected = "OK";
            //SearchCompanyViewModels.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).Where(m => m.Finalized.ToUpper() != "YES").ToList();
            SearchCompanyViewModels.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).ToList();
            var billp = SearchCompanyViewModels.BillingPeriodList.OrderByDescending(m => m.BillingPeriodId);

            SearchCompanyViewModels.BillingPeriodList = billp.ToList();
            return(View());
        }
コード例 #3
0
        public void ProcessRequest(HttpContext context)
        {
            var                a          = context.Request.QueryString["Copy"].ToString();
            var                b          = context.Request.QueryString["Type"].ToString();
            var                origin     = context.Request.QueryString["Origin"].ToString();
            var                billing    = context.Request.QueryString["Billing"].ToString();
            DateTime           originNew  = Convert.ToDateTime(origin);
            DateTime           billingNew = Convert.ToDateTime(billing);
            HttpFileCollection files      = context.Request.Files;
            HttpPostedFile     file       = files["uploadData"];

            int copy = int.Parse(a);

            BCS_Context db = new BCS_Context();

            if ((file != null) && (file.ContentLength > 0) && (!string.IsNullOrEmpty(file.FileName)))
            {
                using (var dbtransaction = db.Database.BeginTransaction())
                {
                    try
                    {
                        ApplicationDbContext con = new ApplicationDbContext();
                        //db.PassedOnBillingInformation.RemoveRange(db.PassedOnBillingInformation)
                        var userid    = System.Web.HttpContext.Current.User.Identity.GetUserId();
                        var zonegroup = con.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
                        SearchCompanyPerGroup searchCompanyPerGroup = new SearchCompanyPerGroup(zonegroup);
                        IEnumerable <Company> company = searchCompanyPerGroup.Companies;
                        using (var package = new ExcelPackage(file.InputStream))
                        {
                            var currentSheet = package.Workbook.Worksheets;
                            var workSheet    = currentSheet.First();
                            var noOfCol      = workSheet.Dimension.End.Column;
                            var noOfRow      = workSheet.Dimension.End.Row;

                            for (int rowIterator = 12; rowIterator <= noOfRow; rowIterator++)
                            {
                                var     compid    = workSheet.Cells[rowIterator, 3].Value;
                                var     newCompId = int.Parse(compid.ToString());
                                Company comp      = company.Where(m => m.CompanyID == newCompId).FirstOrDefault();
                                var     type      = workSheet.Cells[rowIterator, 12].Value.ToString() != null ? workSheet.Cells[rowIterator, 12].Value.ToString() : "";

                                if (type == b)
                                {
                                    PassedOnBillingInformation passedOnBillingInformation = new PassedOnBillingInformation();
                                    passedOnBillingInformation.Type = type;
                                    var cid = workSheet.Cells[rowIterator, 3].Value != null ? workSheet.Cells[rowIterator, 3].Value : 0;
                                    passedOnBillingInformation.CompanyId     = int.Parse(cid.ToString());
                                    passedOnBillingInformation.BillingPeriod = int.Parse(a);
                                    var amt = workSheet.Cells[rowIterator, 13].Value != null ? workSheet.Cells[rowIterator, 13].Value : 0;
                                    passedOnBillingInformation.Amount      = decimal.Parse(amt.ToString());
                                    passedOnBillingInformation.CreatedBy   = userid;
                                    passedOnBillingInformation.CreateDate  = DateTime.Now;
                                    passedOnBillingInformation.OriginDate  = originNew;
                                    passedOnBillingInformation.BillingDate = billingNew;
                                    passedOnBillingInformation.Remarks     = workSheet.Cells[rowIterator, 14].ToString();

                                    db.PassedOnBillingInformation.Add(passedOnBillingInformation);
                                    db.SaveChanges();
                                }
                            }
                        }
                        dbtransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        var error = ex.Message;
                        dbtransaction.Rollback();
                    }
                }
            }
        }
コード例 #4
0
        public ActionResult AddPassedOnBilling(int CompanyId, Decimal Amount, DateTime OriginDateAdd, DateTime BillingDateAdd, int BillingPeriod, string Type, string isEdit, string PassedOnBillingInfoId)
        {
            PassedOnBillingViewModel searchcompany = new PassedOnBillingViewModel();
            var    userid    = User.Identity.GetUserId();
            string ZoneGroup = context.Users.FirstOrDefault(m => m.Id == userid).ZoneGroup;
            var    username  = User.Identity.GetUserName();
            RoleAssignmentMatrix roleAssignmentMatrix = db.RoleAssignmentMatrix.FirstOrDefault(m => m.UserName == username);

            ViewBag.IsValidRole = roleAssignmentMatrix.PassedOnBilling;
            //SL.LogInfo(User.Identity.Name, Request.RawUrl, "User Added Item! (Data Entry PassOnBilling) - from Terminal:" + ipaddress);
            PassedOnBillingInformation passedonBillingInfo = null;

            passedonBillingInfo = db.PassedOnBillingInformation.Find(CompanyId);

            if (isEdit != "Edit")
            {
                PassedOnBillingViewModel   passedonBillingViewModels = new PassedOnBillingViewModel();
                PassedOnBillingInformation passedonBillingAssignment = new PassedOnBillingInformation();
                passedonBillingViewModels.ZoneList      = db.Zone.Select(x => x).ToList();
                passedonBillingAssignment.CompanyId     = CompanyId;
                passedonBillingAssignment.Amount        = Amount;
                passedonBillingAssignment.Type          = Type;
                passedonBillingAssignment.OriginDate    = OriginDateAdd;
                passedonBillingAssignment.BillingDate   = BillingDateAdd;
                passedonBillingAssignment.CreateDate    = DateTime.Now;
                passedonBillingAssignment.CreatedBy     = userid;
                passedonBillingAssignment.BillingPeriod = BillingPeriod;
                db.PassedOnBillingInformation.Add(passedonBillingAssignment);
                db.SaveChanges();

                passedonBillingViewModels.CompanyList         = db.Company.Where(m => m.CompanyID == CompanyId).ToList();
                passedonBillingViewModels.PassedOnBillingList = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompanyId).ToList();
                passedonBillingViewModels.TotalAmount         = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompanyId).Sum(x => x.Amount);

                //passedonBillingViewModels.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).Where(m => m.Finalized.ToUpper() != "YES").ToList();
                passedonBillingViewModels.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).ToList();
                var billp = passedonBillingViewModels.BillingPeriodList.OrderByDescending(m => m.BillingPeriodId);
                passedonBillingViewModels.BillingPeriodList = billp.ToList();
                //return View("ViewSecurityGuardFee", SearchSecurityGuardFeeViewModels);
                TempData["TransactionSuccess"] = "Add";
                SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Passed OnBilling - Add -from Terminal:" + ipaddress);
                TempData["PassedOnBillingData"] = passedonBillingViewModels;
            }
            else
            {
                int passedonbillingid = Convert.ToInt32(PassedOnBillingInfoId);
                passedonBillingInfo = db.PassedOnBillingInformation.FirstOrDefault(m => m.PassedOnBillingInformationId == passedonbillingid);
                PassedOnBillingViewModel passedonBillingViewModels = new PassedOnBillingViewModel();
                passedonBillingViewModels.ZoneList  = db.Zone.Select(x => x).ToList();
                passedonBillingInfo.Amount          = Amount;
                passedonBillingInfo.OriginDate      = OriginDateAdd;
                passedonBillingInfo.BillingDate     = BillingDateAdd;
                passedonBillingInfo.BillingPeriod   = BillingPeriod;
                passedonBillingInfo.Type            = Type;
                passedonBillingInfo.UpdatedBy       = userid;
                passedonBillingInfo.UpdateDate      = DateTime.Now;
                db.Entry(passedonBillingInfo).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                passedonBillingViewModels.CompanyList         = db.Company.Where(m => m.CompanyID == CompanyId).ToList();
                passedonBillingViewModels.PassedOnBillingList = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompanyId).ToList();
                passedonBillingViewModels.TotalAmount         = db.PassedOnBillingInformation.Where(m => m.CompanyId == CompanyId).Sum(x => x.Amount);
                ViewBag.CompanySelected = "OK";

                //passedonBillingViewModels.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).Where(m => m.Finalized.ToUpper() != "YES").ToList();
                passedonBillingViewModels.BillingPeriodList = db.BillingPeriod.Where(x => x.groupCode == ZoneGroup).ToList();
                var billp = passedonBillingViewModels.BillingPeriodList.OrderByDescending(m => m.BillingPeriodId);
                passedonBillingViewModels.BillingPeriodList = billp.ToList();
                TempData["TransactionSuccess"] = "Edit";
                SL.LogInfo(User.Identity.Name, Request.RawUrl, "Data Entry Passed OnBilling - Edit -from Terminal:" + ipaddress);
                TempData["PassedOnBillingData"] = passedonBillingViewModels;
            }
            return(RedirectToAction("ViewPassedOnBillingPRG", "DataEntryPassedOnBilling"));
        }