Ejemplo n.º 1
0
        public ActionResult ForgotPassword(UserLoginVM vm)
        {
            string emailid = vm.UserName;
            var    _user   = db.UserRegistrations.Where(cc => cc.UserName == emailid).FirstOrDefault();

            if (_user != null)
            {
                PickupRequestDAO _dao        = new PickupRequestDAO();
                string           newpassword = _dao.RandomPassword(6);

                _user.Password        = newpassword;
                db.Entry(_user).State = EntityState.Modified;
                db.SaveChanges();
                EmailDAO _emaildao = new EmailDAO();
                _emaildao.SendForgotMail(_user.UserName, "User", newpassword);
                TempData["SuccessMsg"] = "Reset Password Details are sent,Check Email!";

                return(RedirectToAction("Home", "Home"));
                //return Json(new { status = "ok", message = "Reset Password Details are sent,Check Email" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                Session["ForgotStatus"]  = "Forgot";
                Session["StatusMessage"] = "Invalid EmailId!";
                return(RedirectToAction("Home", "Home"));
                //return Json(new { status = "Failed", message = "Invalid EmailId!" }, JsonRequestBehavior.AllowGet);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create()
        {
            int depotid  = Convert.ToInt32(Session["CurrentDepotID"].ToString());
            int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int userId   = Convert.ToInt32(Session["UserID"].ToString());

            ViewBag.depot = db.tblDepots.ToList();
            //ViewBag.depot = (from c in db.tblDepots where c.ID == depotid select c).ToList();
            ViewBag.employee           = db.EmployeeMasters.ToList();
            ViewBag.employeerec        = db.EmployeeMasters.ToList();
            ViewBag.Customer           = db.CustomerMasters.ToList();
            ViewBag.Movement           = db.CourierMovements.ToList();
            ViewBag.Employee           = db.EmployeeMasters.ToList();
            ViewBag.FAgent             = db.ForwardingAgentMasters.ToList();
            ViewBag.Movement           = db.CourierMovements.ToList();
            ViewBag.ProductType        = db.ProductTypes.ToList();
            ViewBag.parceltype         = db.ParcelTypes.ToList();
            ViewBag.customerrate       = db.CustomerRates.ToList();
            ViewBag.TypeofGoods        = db.TypeOfGoods.ToList();
            ViewBag.CourierDescription = db.CourierDescriptions.ToList();
            InScanMasterVM   obj   = new InScanMasterVM();
            PickupRequestDAO _dao  = new PickupRequestDAO();
            string           AWBNo = _dao.GetMaAWBNo(branchid);

            obj.AWBNo       = AWBNo;
            obj.BranchID    = branchid;
            obj.DepotID     = depotid;
            obj.AcCompanyID = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            obj.DeviceID    = "WebSite";
            int pickedupid = (from e in db.EmployeeMasters where e.UserID == userId select e.EmployeeID).First();

            obj.TransactionDate = DateTime.Now;
            return(View(obj));
        }
Ejemplo n.º 3
0
        public JsonResult GetRandomPassword()
        {
            PickupRequestDAO _dao  = new PickupRequestDAO();
            string           passw = _dao.RandomPassword(6);

            return(Json(new { data = passw }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create()
        {
            var transtypes = new SelectList(new[]
            {
                new { ID = "Cr", trans = "Credit" },
                new { ID = "Dr", trans = "Debit" },
            },
                                            "ID", "trans", 1);



            ViewBag.businessType = db.BusinessTypes.ToList();
            ViewBag.country      = db.CountryMasters.ToList();
            ViewBag.city         = db.CityMasters.ToList();
            ViewBag.location     = db.LocationMasters.ToList();
            ViewBag.currency     = db.CurrencyMasters.ToList();
            ViewBag.employee     = db.EmployeeMasters.ToList();
            ViewBag.roles        = db.RoleMasters.ToList();
            int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());

            PickupRequestDAO doa = new PickupRequestDAO();

            ViewBag.CustomerNo = doa.GetMaxCustomerCode(branchid);
            CustmorVM obj = new CustmorVM();

            obj.RoleID   = 13;
            obj.Password = doa.RandomPassword(6);
            return(View(obj));
        }
Ejemplo n.º 5
0
 public JsonResult SaveRoleAccess(int RoleId, string menus)
 {
     try
     {
         PickupRequestDAO _dao = new PickupRequestDAO();
         _dao.SaveMenuAccess(RoleId, menus);
         return(Json(new { status = "ok", message = "saved successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { status = "faiiled", message = ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult Create(int id = 0)
        {
            var transtypes = new SelectList(new[]
            {
                new { ID = "Cr", trans = "Credit" },
                new { ID = "Dr", trans = "Debit" },
            },
                                            "ID", "trans", 1);



            ViewBag.businessType = db.BusinessTypes.ToList();
            ViewBag.country      = db.CountryMasters.ToList();
            ViewBag.city         = db.CityMasters.ToList();
            ViewBag.location     = db.LocationMasters.ToList();
            ViewBag.currency     = db.CurrencyMasters.ToList();
            ViewBag.employee     = db.EmployeeMasters.ToList();
            ViewBag.roles        = db.RoleMasters.ToList();
            int BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            var data     = db.tblDepots.Where(c => c.BranchID == BranchID).ToList();

            ViewBag.Depot = data;

            int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());

            ViewBag.UserRoleId = Convert.ToInt32(Session["UserRoleID"].ToString());
            CustmorVM obj = new CustmorVM();

            if (id == 0)
            {
                ViewBag.Title = "Customer - Create";
                PickupRequestDAO doa = new PickupRequestDAO();
                ViewBag.CustomerNo = "";// doa.GetMaxCustomerCode(branchid);
                obj.CustomerID     = 0;
                obj.RoleID         = 13;
                obj.CustomerType   = "CS";

                obj.Password         = doa.RandomPassword(6);
                obj.ApprovedBy       = Convert.ToInt32(Session["UserID"]);
                obj.ApprovedUserName = Convert.ToString(Session["UserName"]);
                obj.CurrenceyID      = Convert.ToInt32(Session["CurrencyId"].ToString());
            }
            else
            {
                ViewBag.Title = "Customer - Modify";
                obj           = GetDetail(id);
            }

            return(View(obj));
        }
Ejemplo n.º 7
0
 public JsonResult GetTDMAxNo(string vehicletype)
 {
     try
     {
         int FYearId = Convert.ToInt32(Session["fyearid"].ToString());
         ViewBag.Currency = db.CurrencyMasters.ToList();
         int branchid          = Convert.ToInt32(Session["CurrentBranchID"].ToString());
         int companyId         = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
         PickupRequestDAO _dao = new PickupRequestDAO();
         var maxno             = _dao.GetTDSReceiptNo(companyId, branchid, vehicletype, FYearId);
         return(Json(new { status = "ok", TDNo = maxno }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { status = "failed", TDNo = 0 }, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 8
0
        public ActionResult Create(int id = 0)
        {
            int BranchId  = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int depotid   = Convert.ToInt32(Session["CurrentDepotID"].ToString());
            int companyid = Convert.ToInt32(Session["CurrentCompanyID"].ToString());

            //ViewBag.depot = db.tblDepots.ToList();
            ViewBag.depot          = (from c in db.tblDepots where c.BranchID == BranchId select c).ToList();
            ViewBag.employee       = db.EmployeeMasters.ToList();
            ViewBag.employeerec    = db.EmployeeMasters.ToList();
            ViewBag.Vehicles       = db.VehicleMasters.ToList();
            ViewBag.Agents         = db.AgentMasters.ToList();
            ViewBag.CourierService = db.CourierServices.ToList();
            if (id == 0)
            {
                ViewBag.Title = "InScan Import -Create";
                InScanVM vm = new InScanVM();
                vm.QuickInscanID = 0;

                PickupRequestDAO _dao = new PickupRequestDAO();
                vm.InScanSheetNo = _dao.GetMaxInScanSheetNo(companyid, BranchId, "Import");
                vm.DepotID       = depotid;
                ViewBag.EditMode = "false";
                return(View(vm));
            }
            else
            {
                QuickInscanMaster qvm = db.QuickInscanMasters.Find(id);
                InScanVM          vm  = new InScanVM();
                vm.QuickInscanID = qvm.QuickInscanID;
                vm.AgentID       = Convert.ToInt32(qvm.AgentID);
                vm.ReceivedByID  = Convert.ToInt32(qvm.ReceivedByID);
                vm.DriverName    = qvm.DriverName;
                vm.InScanSheetNo = qvm.InscanSheetNumber;
                vm.VehicleId     = Convert.ToInt32(qvm.VehicleId);
                vm.DepotID       = Convert.ToInt32(qvm.DepotId);
                vm.BranchId      = Convert.ToInt32(qvm.BranchId);
                ViewBag.EditMode = "true";
                ViewBag.Title    = "InScan Import - Modify";
                return(View(vm));
            }
        }
Ejemplo n.º 9
0
        public ActionResult Index()
        {
            CustomerInvoiceSearch obj   = (CustomerInvoiceSearch)Session["CustomerInvoiceSearch"];
            CustomerInvoiceSearch model = new CustomerInvoiceSearch();
            int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int depotId  = Convert.ToInt32(Session["CurrentDepotID"].ToString());
            int yearid   = Convert.ToInt32(Session["fyearid"].ToString());

            if (obj == null)
            {
                DateTime pFromDate;
                DateTime pToDate;
                //int pStatusId = 0;
                pFromDate     = CommanFunctions.GetFirstDayofMonth().Date;
                pToDate       = CommanFunctions.GetLastDayofMonth().Date;
                obj           = new CustomerInvoiceSearch();
                obj.FromDate  = pFromDate;
                obj.ToDate    = pToDate;
                obj.InvoiceNo = "";
                Session["CustomerInvoiceSearch"] = obj;
                model.FromDate  = pFromDate;
                model.ToDate    = pToDate;
                model.InvoiceNo = "";
            }
            else
            {
                model = obj;
            }
            List <CustomerInvoiceVM> lst = PickupRequestDAO.GetInvoiceList(obj.FromDate, obj.ToDate, model.InvoiceNo, yearid);

            if (lst != null)
            {
                model.InvoiceTotal = Convert.ToDecimal(lst.Sum(cc => cc.InvoiceTotal).ToString()); // ReceiptDAO.GetCustomerInvoiceTotal(obj.FromDate, obj.ToDate);
            }
            model.Details = lst;

            return(View(model));
        }
Ejemplo n.º 10
0
        public ActionResult Create(int id = 0)
        {
            int BranchId  = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int CompanyId = Convert.ToInt32(Session["CurrentCompanyID"].ToString());

            ViewBag.Deliverdby = db.EmployeeMasters.ToList();
            ViewBag.vehicle    = db.VehicleMasters.ToList();
            ViewBag.Checkedby  = db.EmployeeMasters.ToList();
            DRSVM v = new DRSVM();

            if (id > 0)
            {
                DR d = db.DRS.Find(id);
                v.DRSID                = d.DRSID;
                v.DRSNo                = d.DRSNo;
                v.DRSDate              = d.DRSDate;
                v.DeliveredBy          = d.DeliveredBy;
                v.CheckedBy            = d.CheckedBy;
                v.TotalAmountCollected = d.TotalAmountCollected;
                v.VehicleID            = d.VehicleID;
                v.StatusDRS            = d.StatusDRS;
                v.AcCompanyID          = d.AcCompanyID;
                v.StatusInbound        = d.StatusInbound;
                v.DrsType              = d.DrsType;
                ViewBag.EditMode       = "true";
                ViewBag.Title          = "OutScan - Modify";
            }
            else
            {
                PickupRequestDAO _dao = new PickupRequestDAO();
                v.DRSID          = 0;
                v.DRSNo          = _dao.GetMaxDRSNo(CompanyId, BranchId);
                ViewBag.EditMode = "false";
                ViewBag.Title    = "OutScan - Create";
            }
            return(View(v));
        }
        public ActionResult Create(CustmorVM c)
        {
            string locationname = c.LocationName;
            string country      = c.CountryName;
            string city         = c.CityName;


            CustomerMaster   obj  = new CustomerMaster();
            PickupRequestDAO _dao = new PickupRequestDAO();

            if (c.CustomerID == 0)
            {
                int max         = (from d in db.CustomerMasters orderby d.CustomerID descending select d.CustomerID).FirstOrDefault();
                int accompanyid = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
                int branchid    = Convert.ToInt32(Session["CurrentBranchID"].ToString());
                obj.CustomerID  = max + 1;
                obj.AcCompanyID = accompanyid;

                obj.CustomerCode = c.CustomerCode; //  _dao.GetMaxCustomerCode(branchid); // c.CustomerCode;
            }
            else
            {
                obj = db.CustomerMasters.Find(c.CustomerID);
            }
            obj.CustomerName = c.CustomerName;
            obj.CustomerType = c.CustomerType;

            obj.ReferenceCode = c.ReferenceCode;
            obj.ContactPerson = c.ContactPerson;
            obj.Address1      = c.Address1;
            obj.Address2      = c.Address2;
            obj.Address3      = c.Address3;
            obj.Phone         = c.Phone;
            obj.Mobile        = c.Mobile;
            obj.Fax           = c.Fax;
            obj.Email         = c.Email;
            obj.WebSite       = c.Website;
            obj.CountryID     = c.CountryID;
            if (c.CityID == 0)
            {
                obj.CityID = null;
            }
            else
            {
                obj.CityID = c.CityID;
            }
            if (c.LocationID == 0)
            {
                obj.LocationID = null;
            }
            else
            {
                obj.LocationID = c.LocationID;
            }
            obj.CountryName  = c.CountryName;
            obj.CityName     = c.CityName;
            obj.LocationName = c.LocationName;
            if (c.CurrenceyID == 0)
            {
                c.CurrenceyID = Convert.ToInt32(Session["CurrencyId"].ToString());
            }
            else
            {
                obj.CurrencyID = c.CurrenceyID;
            }
            obj.StatusActive     = c.StatusActive;
            obj.CreditLimit      = c.CreditLimit;
            obj.StatusTaxable    = c.StatusTaxable;
            obj.EmployeeID       = c.EmployeeID;
            obj.statusCommission = c.StatusCommission;
            obj.VATTRN           = c.VATTRN;

            obj.CourierServiceID = c.CourierServiceID;
            obj.BranchID         = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            obj.CustomerUsername = c.CustomerUsername;
            //obj.Password = c.Password;
            obj.Password        = _dao.RandomPassword(6);
            obj.BusinessTypeId  = c.BusinessTypeId;
            obj.Referal         = c.Referal;
            obj.OfficeOpenTime  = c.OfficeTimeFrom;
            obj.OfficeCloseTime = c.OfficeTimeTo;
            if (c.DepotID == null)
            {
                obj.DepotID = Convert.ToInt32(Session["CurrentDepotID"].ToString());
            }
            else
            {
                obj.DepotID = c.DepotID;
            }

            if (c.CustomerType == "CR" && c.ChkApprovedBy)
            {
                obj.ApprovedBy = Convert.ToInt32(Session["UserID"]);
                obj.ApprovedOn = c.ApprovedOn;
            }

            //UserRegistration u = new UserRegistration();
            //if (c.Email != null)
            //{
            //    if (c.Email != "")
            //    {

            //        UserRegistration x = (from a in db.UserRegistrations where a.UserName == c.Email select a).FirstOrDefault();
            //        if (x == null)
            //        {

            //            int max1 = (from c1 in db.UserRegistrations orderby c1.UserID descending select c1.UserID).FirstOrDefault();
            //            u.UserID = max1 + 1;
            //            u.UserName = c.Email;
            //            u.EmailId = c.Email;
            //            u.Password = obj.Password;
            //            u.Phone = c.Phone;
            //            u.IsActive = true;
            //            u.RoleID = c.RoleID;


            //        }
            //        try
            //        {
            //            db.UserRegistrations.Add(u);
            //            db.SaveChanges();
            //        }
            //        catch (DbEntityValidationException e)
            //        {
            //            foreach (var eve in e.EntityValidationErrors)
            //            {
            //                Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
            //                    eve.Entry.Entity.GetType().Name, eve.Entry.State);
            //                foreach (var ve in eve.ValidationErrors)
            //                {
            //                    Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
            //                        ve.PropertyName, ve.ErrorMessage);
            //                }

            //            }
            //        }
            //    }
            //}

            try
            {
                //  obj.UserID = u.UserID;
                if (c.CustomerID > 0)
                {
                    db.Entry(obj).State = EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    db.CustomerMasters.Add(obj);
                    db.SaveChanges();
                    ReceiptDAO.ReSaveCustomerCode();
                }


                if (c.EmailNotify == true)
                {
                    EmailDAO _emaildao = new EmailDAO();
                    _emaildao.SendCustomerEmail(c.Email, c.CustomerName, obj.Password);
                }
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                    }
                }
            }


            TempData["SuccessMsg"] = "You have successfully added Customer.";
            return(RedirectToAction("Index"));



            return(View());
        }
Ejemplo n.º 12
0
        public ActionResult Create(int Id)
        {
            int FYearId = Convert.ToInt32(Session["fyearid"].ToString());

            //ViewBag.Branch = db.BranchMasters.ToList();
            ViewBag.Routes = db.RouteMasters.ToList();
            //ViewBag.Locations = db.LocationMasters.ToList();
            ViewBag.Currency = db.CurrencyMasters.ToList();
            int branchid  = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int companyId = Convert.ToInt32(Session["CurrentCompanyID"].ToString());

            ViewBag.Achead       = db.AcHeads.Where(d => d.AcBranchID == branchid).ToList();
            ViewBag.Drivers      = db.DriverMasters.ToList();
            ViewBag.Vehicles     = db.VehicleMasters.ToList();
            ViewBag.Countries    = db.CountryMasters.ToList();
            ViewBag.parceltype   = db.ParcelTypes.ToList();
            ViewBag.Documents    = db.DocumentSetups.ToList();
            ViewBag.VehicleTypes = db.VehicleTypes.ToList();
            ViewBag.FwdAgents    = db.SupplierMasters.Where(c => c.SupplierTypeID == 2).ToList();
            ViewBag.OtherCharge  = db.OtherCharges.ToList();
            var transtypes = new SelectList(new[]
            {
                new { ID = "N", trans = "Select" },
                new { ID = "C", trans = "Cash" },
                new { ID = "B", trans = "Bank" },
            },
                                            "ID", "trans", "N");

            ViewBag.StatusPaymentMode = transtypes;
            ViewBag.Title             = "Daily Trips - Create";
            TruckDetailVM1 vm1         = new TruckDetailVM1();
            var            truckDetail = (from d in db.TruckDetails where d.TruckDetailID == Id select d).FirstOrDefault();

            if (truckDetail == null)
            {
                truckDetail         = new TruckDetail();
                ViewBag.VehicleType = "H";
                var Truck = db.TruckDetails.ToList().LastOrDefault();
                var MaxId = 1000;
                if (Truck == null)
                {
                    MaxId = 1;
                }
                else
                {
                    MaxId = Truck.TruckDetailID + 1;
                }
                var ReceiptNo         = "TDS-" + MaxId;
                PickupRequestDAO _dao = new PickupRequestDAO();
                vm1.ReceiptNo         = _dao.GetTDSReceiptNo(companyId, branchid, "H", FYearId);
                vm1.VehicleType       = "H";
                vm1.CurrencyIDRent    = Convert.ToInt32(Session["CurrencyId"].ToString());
                vm1.PaymentCurrencyID = Convert.ToInt32(Session["CurrencyId"].ToString());
                var ac = db.AcHeadControls.Where(cc => cc.Pagecontrol == 1 && cc.AccountName == "Rent Account").FirstOrDefault();
                if (ac != null)
                {
                    vm1.RentAcHeadID = ac.AccountHeadID;
                    vm1.RentAcHead   = db.AcHeads.Where(cc => cc.AcHeadID == vm1.RentAcHeadID).FirstOrDefault().AcHead1;
                }

                List <TruckDetailOtherChargeVM> otherchargesvm = new List <TruckDetailOtherChargeVM>();
                vm1.otherchargesVM = otherchargesvm;
                ViewBag.EditMode   = "false";
            }
            else
            {
                ViewBag.EditMode = "true";
                List <TruckDetailOtherChargeVM> otherchargesvm = new List <TruckDetailOtherChargeVM>();
                ViewBag.Title         = "Daily Trips - Modify";
                vm1.TruckDetailID     = truckDetail.TruckDetailID;
                vm1.VehicleType       = truckDetail.VehicleType;
                vm1.DriverName        = truckDetail.DriverName;
                vm1.ReceiptNo         = truckDetail.ReceiptNo;
                vm1.TDDate            = truckDetail.TDDate;
                vm1.DriverID          = truckDetail.DriverID;
                vm1.VehicleID         = truckDetail.VehicleID;
                vm1.RouteID           = truckDetail.RouteID;
                vm1.OriginName        = truckDetail.OriginName;
                vm1.DestinationName   = truckDetail.DestinationName;
                vm1.RegNo             = truckDetail.RegNo;
                vm1.Rent              = truckDetail.Rent;
                vm1.RentAcHeadID      = truckDetail.RentAcHeadID;
                vm1.RentAcHead        = db.AcHeads.Find(truckDetail.RentAcHeadID).AcHead1;
                vm1.ParcelTypeId      = truckDetail.ParcelTypeId;
                vm1.TDRemarks         = truckDetail.TDRemarks;
                vm1.VehicleType       = truckDetail.VehicleType;
                vm1.OtherCharges      = truckDetail.OtherCharges;
                vm1.StatusPaymentMode = truckDetail.StatusPaymentMode.Trim();
                vm1.ChequeDate        = truckDetail.ChequeDate;
                vm1.ChequeNo          = truckDetail.ChequeNo;
                vm1.ConsignmentNoNote = truckDetail.ConsignmentNoNote;
                vm1.Amount            = truckDetail.Amount;
                vm1.FYearID           = truckDetail.FYearID;
                vm1.CurrencyIDRent    = truckDetail.CurrencyIDRent;
                vm1.PaymentCurrencyID = truckDetail.PaymentCurrencyID;
                vm1.PaymentHeadID     = truckDetail.PaymentHeadID;
                vm1.Remarks           = truckDetail.Remarks;
                if (truckDetail.PaymentHeadID != null)
                {
                    vm1.PaymentHead = db.AcHeads.Find(truckDetail.PaymentHeadID).AcHead1;
                }
                if (truckDetail.TDcontrolAcHeadID != null)
                {
                    vm1.TDcontrolAcHeadID = truckDetail.TDcontrolAcHeadID;
                    vm1.TDcontrolAcHead   = db.AcHeads.Find(truckDetail.TDcontrolAcHeadID).AcHead1;
                }

                if (truckDetail.VehicleType == "F")
                {
                    vm1.ForwardAgentID = truckDetail.ForwardAgentID;
                }
                otherchargesvm = (from c in db.TruckDetailOtherCharges join o in db.OtherCharges on c.OtherChargeID equals o.OtherChargeID where c.TruckDetailId == Id select new TruckDetailOtherChargeVM {
                    TruckDetailId = Id, OtherChargeID = c.OtherChargeID, OtherChargeName = o.OtherCharge1, Amount = c.Amount
                }).ToList();
                if (otherchargesvm == null)
                {
                    otherchargesvm     = new List <TruckDetailOtherChargeVM>();
                    vm1.otherchargesVM = otherchargesvm;
                }
                else
                {
                    vm1.otherchargesVM = otherchargesvm;
                }
            }

            return(View(vm1));
        }
      //SaveSupplierInvoice
      public JsonResult SaveSupplierInvoice(int Id, int SupplierID, string InvoiceDate, string InvoiceNo, string Remarks, int SupplierTypeId, string Details)
      {
          try
          {
              var IDetails = JsonConvert.DeserializeObject <List <SupplierInvoiceDetailVM> >(Details);
              List <SupplierInvoiceConsignmentVM> AWBAllocationall = new List <SupplierInvoiceConsignmentVM>();
              List <SupplierInvoiceConsignmentVM> AWBAllocation    = new List <SupplierInvoiceConsignmentVM>();
              AWBAllocationall = (List <SupplierInvoiceConsignmentVM>)Session["SIAWBAllocation"];
              var Supplierinvoice = (from d in db.SupplierInvoices where d.SupplierInvoiceID == Id select d).FirstOrDefault();
              if (Supplierinvoice == null)
              {
                  Supplierinvoice = new SupplierInvoice();
              }
              else
              {
                  var details = (from d in db.SupplierInvoiceDetails where d.SupplierInvoiceID == Supplierinvoice.SupplierInvoiceID select d).ToList();
                  db.SupplierInvoiceDetails.RemoveRange(details);
                  db.SaveChanges();

                  var consignmentdetails = (from d in db.SupplierInvoiceConsignments where d.SupplierInvoiceId == Supplierinvoice.SupplierInvoiceID select d).ToList();
                  db.SupplierInvoiceConsignments.RemoveRange(consignmentdetails);
                  db.SaveChanges();
              }

              Supplierinvoice.SupplierID     = SupplierID;
              Supplierinvoice.InvoiceDate    = Convert.ToDateTime(InvoiceDate);
              Supplierinvoice.InvoiceNo      = InvoiceNo;
              Supplierinvoice.AccompanyID    = Convert.ToInt32(Session["CurrentCompanyID"]);
              Supplierinvoice.BranchId       = Convert.ToInt32(Session["CurrentBranchID"]);
              Supplierinvoice.FyearID        = Convert.ToInt32(Session["fyearid"]);
              Supplierinvoice.InvoiceTotal   = IDetails.Sum(d => d.Value);
              Supplierinvoice.StatusClose    = false;
              Supplierinvoice.IsDeleted      = false;
              Supplierinvoice.Remarks        = Remarks;
              Supplierinvoice.SupplierTypeId = SupplierTypeId;
              if (Supplierinvoice.SupplierInvoiceID == 0)
              {
                  db.SupplierInvoices.Add(Supplierinvoice);
              }
              db.SaveChanges();
              foreach (var item in IDetails)
              {
                  var InvoiceDetail = new SupplierInvoiceDetail();
                  InvoiceDetail.SupplierInvoiceID = Supplierinvoice.SupplierInvoiceID;
                  InvoiceDetail.AcHeadID          = item.AcHeadId;
                  InvoiceDetail.Particulars       = item.Particulars;
                  InvoiceDetail.Quantity          = item.Quantity;
                  InvoiceDetail.Rate           = item.Rate;
                  InvoiceDetail.CurrencyID     = item.CurrencyID;
                  InvoiceDetail.CurrencyAmount = item.CurrencyAmount;
                  InvoiceDetail.Amount         = item.Amount;
                  InvoiceDetail.TaxPercentage  = item.TaxPercentage;
                  InvoiceDetail.Value          = item.Value;

                  db.SupplierInvoiceDetails.Add(InvoiceDetail);
                  db.SaveChanges();

                  //adding consignment referece to this entry
                  int acheadid = Convert.ToInt32(item.AcHeadId);

                  if (AWBAllocationall != null)
                  {
                      var list = AWBAllocationall.Where(cc => cc.AcHeadId == acheadid).ToList();
                      if (list != null)
                      {
                          foreach (var item2 in list)
                          {
                              SupplierInvoiceConsignment accons = new SupplierInvoiceConsignment();
                              accons.SupplierInvoiceId       = Supplierinvoice.SupplierInvoiceID;
                              accons.SupplierInvoiceDetailId = item.SupplierInvoiceDetailID;
                              accons.AcHeadId = acheadid;
                              accons.InScanID = Convert.ToInt32(item2.InScanID);
                              accons.Amount   = item2.Amount;
                              db.SupplierInvoiceConsignments.Add(accons);
                              db.SaveChanges();
                          }
                      }
                  }
              }

              PickupRequestDAO dao = new PickupRequestDAO();
              dao.GenerateSupplierInvoicePosting(Supplierinvoice.SupplierInvoiceID);

              return(Json(new { status = "ok", message = "Invoice Submitted Successfully!" }, JsonRequestBehavior.AllowGet));
          }
          catch (Exception e)
          {
              return(Json(new { status = "failed", message = e.Message.ToString() }, JsonRequestBehavior.AllowGet));
          }
      }
Ejemplo n.º 14
0
        public ActionResult Create(RevenueUpdateMasterVM vm)
        {
            ViewBag.Title = "Revenue Update - Create";
            int userId = Convert.ToInt32(Session["UserID"].ToString());

            ViewBag.employee = db.EmployeeMasters.ToList();

            ViewBag.PaymentType = db.tblPaymentModes.ToList();
            ViewBag.Currency    = db.CurrencyMasters.ToList();
            ViewBag.Consignment = db.InScanMasters.ToList();
            List <VoucherTypeVM> lsttype = new List <VoucherTypeVM>();

            //lsttype.Add(new VoucherTypeVM { TypeName = "All" });
            lsttype.Add(new VoucherTypeVM {
                TypeName = "Shipper"
            });
            lsttype.Add(new VoucherTypeVM {
                TypeName = "Consignee"
            });

            ViewBag.InvoiceTo = lsttype;
            int branchid          = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int fyearid           = Convert.ToInt32(Session["fyearid"].ToString());
            RevenueUpdateMaster v = new RevenueUpdateMaster();
            bool duplicatecost    = false;

            for (int i = 0; i < vm.DetailVM.Count; i++)
            {
                if (vm.DetailVM[i].IsDeleted != true)
                {
                    for (int j = i + 1; j < vm.DetailVM.Count; j++)
                    {
                        if (vm.DetailVM[i].RevenueCostMasterID == vm.DetailVM[j].RevenueCostMasterID && vm.DetailVM[j].IsDeleted != true)
                        {
                            duplicatecost = true;

                            TempData["ErrorMsg"]           = "Revenue Component should not be Duplicated!";
                            Session["CreateRevenueUpdate"] = vm;
                            ViewBag.Title = "Revenue Update - Modify";

                            return(View(vm));
                        }
                    }
                }
            }
            if (vm.ID == 0)
            {
                ViewBag.Title = "Revenue Update - Create";

                v.EntryDate         = vm.EntryDate;
                v.EmployeeID        = vm.EmployeeID;
                v.InScanID          = vm.InScanID;
                v.BranchID          = branchid;
                v.AcFinancialYearID = fyearid;
                v.CreatedBy         = userId;
                v.CreatedDate       = CommanFunctions.GetCurrentDateTime();
                v.ModifiedBy        = userId;
                v.ModifiedDate      = CommanFunctions.GetCurrentDateTime();
                db.RevenueUpdateMasters.Add(v);
                db.SaveChanges();
            }
            else
            {
                ViewBag.Title       = "Revenue Update - Modify";
                v                   = db.RevenueUpdateMasters.Find(vm.ID);
                v.EntryDate         = vm.EntryDate;
                v.EmployeeID        = vm.EmployeeID;
                v.InScanID          = vm.InScanID;
                v.BranchID          = branchid;
                v.AcFinancialYearID = fyearid;
                v.ModifiedBy        = userId;
                v.ModifiedDate      = CommanFunctions.GetCurrentDateTime();
                db.Entry(v).State   = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }

            for (int i = 0; i < vm.DetailVM.Count; i++)
            {
                if (vm.DetailVM[i].IsDeleted != true)
                {
                    if (vm.DetailVM[i].ID == 0)
                    {
                        RevenueUpdateDetail detail = new RevenueUpdateDetail();
                        detail.MasterID            = v.ID;
                        detail.RevenueCostMasterID = vm.DetailVM[i].RevenueCostMasterID;
                        detail.AcHeadCreditId      = vm.DetailVM[i].AcHeadCreditId;
                        detail.AcHeadDebitId       = vm.DetailVM[i].AcHeadDebitId;
                        detail.Amount        = vm.DetailVM[i].Amount;
                        detail.CurrencyId    = vm.DetailVM[i].CurrencyId;
                        detail.CustomerId    = vm.DetailVM[i].CustomerId;
                        detail.ExchangeRate  = vm.DetailVM[i].ExchangeRate;
                        detail.TaxPercent    = vm.DetailVM[i].TaxPercent;
                        detail.TaxAmount     = vm.DetailVM[i].TaxAmount;
                        detail.TotalCharge   = vm.DetailVM[i].TotalCharge;
                        detail.PaymentModeId = vm.DetailVM[i].PaymentModeId;
                        detail.InvoiceTo     = vm.DetailVM[i].InvoiceTo;

                        db.RevenueUpdateDetails.Add(detail);
                        db.SaveChanges();
                    }
                    else
                    {
                        RevenueUpdateDetail detail = db.RevenueUpdateDetails.Find(vm.DetailVM[i].ID);
                        if (detail != null)
                        {
                            detail.MasterID            = v.ID;
                            detail.RevenueCostMasterID = vm.DetailVM[i].RevenueCostMasterID;
                            detail.AcHeadCreditId      = vm.DetailVM[i].AcHeadCreditId;
                            detail.AcHeadDebitId       = vm.DetailVM[i].AcHeadDebitId;
                            detail.Amount        = vm.DetailVM[i].Amount;
                            detail.CurrencyId    = vm.DetailVM[i].CurrencyId;
                            detail.CustomerId    = vm.DetailVM[i].CustomerId;
                            detail.ExchangeRate  = vm.DetailVM[i].ExchangeRate;
                            detail.PaymentModeId = vm.DetailVM[i].PaymentModeId;
                            detail.InvoiceTo     = vm.DetailVM[i].InvoiceTo;

                            db.Entry(detail).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                }
                else
                {
                    if (vm.DetailVM[i].ID > 0)
                    {
                        RevenueUpdateDetail detail = db.RevenueUpdateDetails.Find(vm.DetailVM[i].ID);
                        db.RevenueUpdateDetails.Remove(detail);
                        db.SaveChanges();
                    }
                }
            }


            //update inscan revenue update status
            var inscan = db.InScanMasters.Find(vm.InScanID);

            inscan.Remarks         = vm.Remarks;
            inscan.RevenueUpdate   = true;
            db.Entry(inscan).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();

            PickupRequestDAO _dao = new PickupRequestDAO();

            _dao.GenerateRevenueUpdatePosting(v.ID);
            Session["CreateRevenueUpdate"] = null;
            TempData["SuccessMsg"]         = "Revenue of Consignment Updated Successfully!";
            return(RedirectToAction("Index"));
            //ViewBag.Title = "Revenue Update - Create";
            //ViewBag.employee = db.EmployeeMasters.ToList();
            //List<VoucherTypeVM> lsttype = new List<VoucherTypeVM>();
            //lsttype.Add(new VoucherTypeVM { TypeName = "Pickup Cash" });
            //lsttype.Add(new VoucherTypeVM { TypeName = "Customer" });
            //lsttype.Add(new VoucherTypeVM { TypeName = "Shipper" });

            //ViewBag.PaymentType = lsttype;
            //ViewBag.Currency = db.CurrencyMasters.ToList();
            //return View();
        }
Ejemplo n.º 15
0
        public ActionResult Create(int id = 0)
        {
            int uid = Convert.ToInt32(Session["UserID"].ToString());

            int branchid  = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int depotId   = Convert.ToInt32(Session["CurrentDepotID"].ToString());
            int companyId = Convert.ToInt32(Session["CurrentCompanyID"].ToString());

            ViewBag.Vehicle      = db.VehicleMasters.ToList();
            ViewBag.Employee     = db.EmployeeMasters.ToList();
            ViewBag.Customer     = db.CustomerMasters.ToList();
            ViewBag.RequestType  = db.RequestTypes.ToList();
            ViewBag.DocumentType = db.tblDocumentTypes.ToList();
            ViewBag.PaymentMode  = db.tblPaymentModes.ToList();
            //ViewBag.PickupRequestStatus = db.PickUpRequestStatus.ToList();

            ViewBag.PickupRequestStatus = db.CourierStatus.Where(cc => cc.StatusTypeID == 1).ToList();

            ViewBag.PickupSubReason = db.SubStatus.ToList();
            PickupRequestVM v = new PickupRequestVM();

            UserRegistration u = (from c in db.UserRegistrations where c.UserID == uid select c).FirstOrDefault();
            int    empid       = u.UserID;
            string empname     = u.UserName;

            ViewBag.empname = empname;
            ViewBag.empid   = empid;

            if (id == 0)
            {
                PickupRequestDAO doa = new PickupRequestDAO();
                ViewBag.RequestNo = doa.GetMaxPickupRequest(companyId, branchid);
                ViewBag.StatusId  = 1;
                int Customerid = 0;
                if (Session["UserType"].ToString() == "Customer")
                {
                    Customerid   = Convert.ToInt32(Session["CustomerId"].ToString());
                    v.CustomerID = Customerid;
                    var _cust = db.CustomerMasters.Find(Customerid);
                    v.CustomerName         = _cust.CustomerName;
                    v.CustomerCode         = _cust.CustomerCode;
                    v.Consignor            = _cust.CustomerName;
                    v.ConsignorPhone       = _cust.Phone;
                    v.OfficeTimeFrom       = _cust.OfficeOpenTime;
                    v.OfficeTimeTo         = _cust.OfficeCloseTime;
                    v.ConsignorAddress     = _cust.Address1;
                    v.ConsignorAddress1    = _cust.Address2;
                    v.ConsignorAddress2    = _cust.Address3;
                    v.ConsignorCountryName = _cust.CountryName;
                    v.ConsignorCityName    = _cust.CityName;
                    v.ConsignorContact     = _cust.ContactPerson;
                }
            }
            else
            {
                v                         = GetPickupRequestDetail(id);
                ViewBag.AWBNo             = v.AWBNo;
                ViewBag.StatusId          = v.PickupRequestStatusId;
                ViewBag.SubReasonStatusId = v.SubReasonId;
                ViewBag.Status            = db.CourierStatus.Where(cc => cc.CourierStatusID == v.PickupRequestStatusId).FirstOrDefault().CourierStatus;
            }

            return(View(v));
        }
Ejemplo n.º 16
0
        public ActionResult Create(PickupRequestVM v)
        {
            PickupRequestDAO _dao = new PickupRequestDAO();
            int branchid          = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int depotId           = Convert.ToInt32(Session["CurrentDepotID"].ToString());
            int companyId         = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            int uid            = Convert.ToInt32(Session["UserID"].ToString());
            UserRegistration u = (from c in db.UserRegistrations where c.UserID == uid select c).FirstOrDefault();
            int    empid       = u.UserID;
            string empname     = u.UserName;

            InScanMaster _enquiry = new InScanMaster();

            if (v.InScanID == 0)
            {
                int id = (from c in db.InScanMasters orderby c.InScanID descending select c.InScanID).FirstOrDefault();
                _enquiry.InScanID        = id + 1;
                _enquiry.EnquiryNo       = _dao.GetMaxPickupRequest(companyId, branchid); // (id + 1).ToString();
                _enquiry.ConsignmentNo   = _dao.GetMaAWBNo(companyId, branchid);
                _enquiry.AcCompanyID     = companyId;
                _enquiry.BranchID        = branchid;
                _enquiry.DepotID         = depotId;
                _enquiry.TransactionDate = DateTime.Now;
                _enquiry.DeviceID        = "WebSite";
                _enquiry.IsDeleted       = false;
                int statustypeid = db.tblStatusTypes.Where(c => c.Name == "PICKUP REQUEST").FirstOrDefault().ID;
                _enquiry.StatusTypeId = statustypeid; //pickuprequest
            }
            else
            {
                _enquiry = db.InScanMasters.Find(v.InScanID);
            }

            _enquiry.DocumentSetupID   = v.DocumentTypeId;
            _enquiry.PickupRequestDate = Convert.ToDateTime(v.EnquiryDate);
            _enquiry.CustomerID        = v.CustomerID;

            _enquiry.ConsignorCountryName  = v.ConsignorCountryName;
            _enquiry.ConsignorCityName     = v.ConsignorCityName;
            _enquiry.ConsigneeLocationName = v.ConsigneeLocationName;
            _enquiry.ConsignorLocationName = v.ConsignorLocationName;

            _enquiry.ConsigneeCountryName = v.ConsigneeCountryName;
            _enquiry.ConsigneeCityName    = v.ConsigneeCityName;
            _enquiry.Weight = Convert.ToDecimal(v.Weight);


            _enquiry.Consignee = v.Consignee;
            _enquiry.Consignor = v.Consignor;
            _enquiry.ConsignorAddress1_Building = v.ConsignorAddress;
            _enquiry.ConsignorAddress2_Street   = v.ConsignorAddress1;
            _enquiry.ConsignorAddress3_PinCode  = v.ConsignorAddress2;
            _enquiry.ConsigneeAddress1_Building = v.ConsigneeAddress;
            _enquiry.ConsigneeAddress2_Street   = v.ConsigneeAddress1;
            _enquiry.ConsigneeAddress3_PinCode  = v.ConsigneeAddress2;
            _enquiry.ConsignorPhone             = v.ConsignorPhone;
            _enquiry.ConsigneePhone             = v.ConsigneePhone;

            _enquiry.AssignedEmployeeID = v.EmployeeID;

            _enquiry.Remarks       = v.Remarks;
            _enquiry.PickedUpEmpID = v.CollectedEmpID;
            _enquiry.PickedupDate  = v.CollectedTime;

            //_enquiry.ShipmentType = v.ShipmentType;
            //if (v.vehreq == true)
            //{
            //    _enquiry.Vehicle = v.Vehicle;
            //    _enquiry.VehicleID = v.VehicleID;
            //}


            _enquiry.ConsigneeContact = v.ConsigneeContact;
            _enquiry.ConsignorContact = v.ConsignorContact;
            _enquiry.EnteredByID      = empid; //userid
            _enquiry.IsEnquiry        = true;

            _enquiry.PickupReadyTime = v.ReadyTime;

            //_enquiry.OfficeTimeFrom = v.OfficeTimeFrom;
            //_enquiry.OfficeTimeTo = v.OfficeTimeTo;

            _enquiry.RequestSource = v.RequestSource;

            if (_enquiry.StatusTypeId == 1)
            {
                if (_enquiry.AssignedEmployeeID == null)
                {
                    _enquiry.CourierStatusID = 1;
                }
                else if (_enquiry.AssignedEmployeeID != null && _enquiry.PickedUpEmpID == null)
                {
                    _enquiry.CourierStatusID = 2;
                }
                //else if (_enquiry.PickedUpEmpID != null)
                //{
                //    _enquiry.PickupRequestStatusId = 3;
                //}
                else if (_enquiry.StatusTypeId == 1 && _enquiry.CourierStatusID == null)
                {
                    _enquiry.CourierStatusID = 1; //request
                }
            }

            //db.CustomerEnquiries.Add(_enquiry);
            if (v.InScanID == 0)
            {
                db.InScanMasters.Add(_enquiry);
                db.SaveChanges();
                //
                AWBTrackStatu _awbstatus = new AWBTrackStatu();
                int?          id         = (from c in db.AWBTrackStatus orderby c.AWBTrackStatusId descending select c.AWBTrackStatusId).FirstOrDefault();

                if (id == null)
                {
                    id = 1;
                }
                else
                {
                    id = id + 1;
                }

                _awbstatus.AWBTrackStatusId = Convert.ToInt32(id);
                _awbstatus.AWBNo            = _enquiry.ConsignmentNo;
                _awbstatus.EntryDate        = DateTime.Now;
                _awbstatus.InScanId         = _enquiry.InScanID;
                _awbstatus.StatusTypeId     = Convert.ToInt32(_enquiry.StatusTypeId);
                _awbstatus.CourierStatusId  = Convert.ToInt32(_enquiry.CourierStatusID);
                _awbstatus.ShipmentStatus   = db.tblStatusTypes.Find(_enquiry.StatusTypeId).Name;
                _awbstatus.CourierStatus    = db.CourierStatus.Find(_enquiry.CourierStatusID).CourierStatus;
                _awbstatus.UserId           = uid;

                db.AWBTrackStatus.Add(_awbstatus);
                db.SaveChanges();
                //

                SaveConsignee(v);
                TempData["SuccessMsg"] = "You have successfully added Pickup Request.";
            }
            else
            {
                SaveConsignee(v);
                db.Entry(_enquiry).State = EntityState.Modified;
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully updated Pickup Request.";
            }

            return(RedirectToAction("Index"));

            //}
            //else
            //{
            //    int uid = Convert.ToInt32(Session["UserID"].ToString());

            //    UserRegistration u = (from c in db.UserRegistrations where c.UserID == uid select c).FirstOrDefault();
            //    int empid = u.UserID;
            //    string empname = u.UserName;

            //    ViewBag.Country = db.CountryMasters.ToList();
            //    ViewBag.City = db.CityMasters.ToList();
            //    ViewBag.Location = db.LocationMasters.ToList();
            //    ViewBag.Vehicle = db.VehicleMasters.ToList();
            //    ViewBag.Employee = db.EmployeeMasters.ToList();
            //    ViewBag.Customer = db.CustomerMasters.ToList();
            //    ViewBag.RequestType = db.RequestTypes.ToList();
            //    ViewBag.empname = empname;
            //    ViewBag.empid = empid;
            //    PickupRequestDAO doa = new PickupRequestDAO();
            //    ViewBag.RequestNo = doa.GetMaxPickupRequest();
            //    return View();
            //}
        }
Ejemplo n.º 17
0
        public ActionResult Create(AgentVM item)
        {
            int              companyId = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            int              BranchID  = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int?             max       = (from c in db.AgentMasters orderby c.AgentID descending select c.AgentID).FirstOrDefault();
            AgentMaster      a         = new AgentMaster();
            PickupRequestDAO _dao      = new PickupRequestDAO();
            int              roleid    = db.RoleMasters.Where(t => t.RoleName == "Agent").FirstOrDefault().RoleID;

            UserRegistration u = new UserRegistration();

            UserRegistration x = (from b in db.UserRegistrations where b.UserName == item.Email select b).FirstOrDefault();

            if (x == null)
            {
                int max1 = (from c1 in db.UserRegistrations orderby c1.UserID descending select c1.UserID).FirstOrDefault();

                u.UserID   = max1 + 1;
                u.UserName = item.Email;
                u.EmailId  = item.Email;

                if (item.Password == null)
                {
                    u.Password = _dao.RandomPassword(6);
                }
                else
                {
                    u.Password = item.Password;
                }

                u.Phone    = item.Phone;
                u.IsActive = true;
                u.RoleID   = roleid;
                db.UserRegistrations.Add(u);
                db.SaveChanges();
            }

            if (max == null || max == 0)
            {
                a.AgentID       = 1;
                a.Name          = item.AgentName;
                a.AgentCode     = item.AgentCode;
                a.Address1      = item.Address1;
                a.Address2      = item.Address2;
                a.Address3      = item.Address3;
                a.Phone         = item.Phone;
                a.Fax           = item.Fax;
                a.WebSite       = item.WebSite;
                a.ContactPerson = item.ContactPerson;
                a.AcCompanyID   = companyId;
                //a.CountryID = item.CountryID;
                //a.CityID = item.CityID;
                //a.LocationID = item.LocationID;
                a.CurrencyID     = item.CurrencyID;
                a.ZoneCategoryID = item.ZoneCategoryID;
                a.AcHeadID       = item.AcHeadID;
                a.CreditLimit    = item.CreditLimit;
                a.CountryName    = item.CountryName;
                a.CityName       = item.CityName;
                a.LocationName   = item.LocationName;
                a.Email          = item.Email;
                a.Password       = "";
                a.AgentType      = item.AgentType;
                a.UserID         = u.UserID;

                if (item.StatusActive == null)
                {
                    a.StatusActive = false;
                }
                else
                {
                    a.StatusActive = Convert.ToBoolean(item.StatusActive);
                }

                a.BranchID = BranchID;
            }
            else
            {
                a.AgentID        = Convert.ToInt32(max) + 1;
                a.Name           = item.AgentName;
                a.AgentCode      = item.AgentCode;
                a.Address1       = item.Address1;
                a.Address2       = item.Address2;
                a.Address3       = item.Address3;
                a.Phone          = item.Phone;
                a.Fax            = item.Fax;
                a.WebSite        = item.WebSite;
                a.ContactPerson  = item.ContactPerson;
                a.AcCompanyID    = companyId;
                a.CountryName    = item.CountryName;
                a.CityName       = item.CityName;
                a.LocationName   = item.LocationName;
                a.CurrencyID     = item.CurrencyID;
                a.ZoneCategoryID = item.ZoneCategoryID;
                a.AcHeadID       = item.AcHeadID;
                a.CreditLimit    = item.CreditLimit;

                a.Email     = item.Email;
                a.Password  = "";
                a.AgentType = item.AgentType;
                a.UserID    = u.UserID;
                a.BranchID  = BranchID;
                if (item.StatusActive == null)
                {
                    a.StatusActive = false;
                }
                else
                {
                    a.StatusActive = Convert.ToBoolean(item.StatusActive);
                }
            }

            try
            {
                db.AgentMasters.Add(a);
                db.SaveChanges();

                if (item.EmailNotify == true)
                {
                    EmailDAO _emaildao = new EmailDAO();
                    _emaildao.SendCustomerEmail(item.Email, item.Email, u.Password);
                }

                TempData["SuccessMsg"] = "You have successfully added Agent.";
                return(RedirectToAction("Index"));
            }

            catch (Exception ex)
            {
                ViewBag.currency       = db.CurrencyMasters.ToList();
                ViewBag.zonecategory   = db.ZoneCategories.ToList();
                ViewBag.achead         = db.AcHeads.ToList();
                ViewBag.roles          = db.RoleMasters.ToList();
                TempData["WarningMsg"] = ex.Message;
                return(View(item));
            }
        }
Ejemplo n.º 18
0
        public ActionResult Create(InScanMasterVM v)
        {
            //PickupRequestDAO _dao = new PickupRequestDAO();

            if (ModelState.IsValid)
            {
                int depotid  = Convert.ToInt32(Session["CurrentDepotID"].ToString());
                int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());

                int uid = Convert.ToInt32(Session["UserID"].ToString());


                InScanMaster _enquiry = new InScanMaster();

                int id = (from c in db.CustomerEnquiries orderby c.EnquiryID descending select c.EnquiryID).FirstOrDefault();

                PickupRequestDAO _dao  = new PickupRequestDAO();
                string           AWBNo = _dao.GetMaAWBNo(branchid);

                _enquiry.ConsignmentNo   = v.AWBNo;
                _enquiry.TransactionDate = DateTime.Now;

                _enquiry.Consignor                  = v.Consignor;
                _enquiry.ConsignorContact           = v.ConsignorContact;
                _enquiry.ConsignorPhone             = v.ConsignorPhone;
                _enquiry.ConsignorAddress1_Building = v.ConsignorAddress1_Building;
                _enquiry.ConsignorAddress2_Street   = v.ConsignorAddress2_Street;
                _enquiry.ConsignorAddress3_PinCode  = v.ConsignorAddress2_Pincode;
                _enquiry.ConsignorCityName          = v.ConsignorCityName;
                _enquiry.ConsignorCountryName       = v.ConsignorCountryName;
                _enquiry.ConsignorLocationName      = v.ConsignorLocationName;


                _enquiry.Consignee             = v.Consignee;
                _enquiry.ConsigneeContact      = v.ConsigneeContact;
                _enquiry.ConsigneePhone        = v.ConsigneePhone;
                _enquiry.ConsigneeLocationName = v.ConsigneeLocationName;
                _enquiry.ConsigneeCountryName  = v.ConsigneeCountryName;
                _enquiry.ConsigneeCityName     = v.ConsigneeCityName;

                _enquiry.Weight      = v.Weight;
                _enquiry.AcCompanyID = 1;
                _enquiry.CustomerID  = v.CustomerID;


                _enquiry.PickedupDate  = v.PickupDateTime;
                _enquiry.PickedUpEmpID = v.PickupBy;
                _enquiry.Remarks       = v.Remarks;

                _enquiry.DepotReceivedBy = v.ReceivedByID;

                db.InScanMasters.Add(_enquiry);
                db.SaveChanges();

                TempData["SuccessMsg"] = "You have successfully added InScan Master";
                return(RedirectToAction("Index"));
            }
            else
            {
                int depotid = Convert.ToInt32(Session["CurrentDepotID"].ToString());
                int userId  = Convert.ToInt32(Session["CurrentUserID"].ToString());
                ViewBag.depot = db.tblDepots.ToList();
                //ViewBag.depot = (from c in db.tblDepots where c.ID == depotid select c).ToList();
                ViewBag.employee           = db.EmployeeMasters.ToList();
                ViewBag.employeerec        = db.EmployeeMasters.ToList();
                ViewBag.Customer           = db.CustomerMasters.ToList();
                ViewBag.Movement           = db.CourierMovements.ToList();
                ViewBag.Employee           = db.EmployeeMasters.ToList();
                ViewBag.FAgent             = db.ForwardingAgentMasters.ToList();
                ViewBag.Movement           = db.CourierMovements.ToList();
                ViewBag.ProductType        = db.ProductTypes.ToList();
                ViewBag.parceltype         = db.ParcelTypes.ToList();
                ViewBag.customerrate       = db.CustomerRates.ToList();
                ViewBag.TypeofGoods        = db.TypeOfGoods.ToList();
                ViewBag.CourierDescription = db.CourierDescriptions.ToList();
                //InScanMasterVM obj = new InScanMasterVM();
                //obj.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString());
                //obj.DepotID = Convert.ToInt32(Session["CurrentDepotID"].ToString());
                //obj.AcCompanyID = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
                //obj.DeviceID = "WebSite";
                //int pickedupid = (from e in db.EmployeeMasters where e.UserID == userId select e.EmployeeID).First();

                //obj.TransactionDate = DateTime.Now;
                return(View(v));
            }
            //else
            //{
            //    int uid = Convert.ToInt32(Session["UserID"].ToString());

            //    UserRegistration u = (from c in db.UserRegistrations where c.UserID == uid select c).FirstOrDefault();
            //    int empid = u.UserID;
            //    string empname = u.UserName;

            //    ViewBag.Country = db.CountryMasters.ToList();
            //    ViewBag.City = db.CityMasters.ToList();
            //    ViewBag.Location = db.LocationMasters.ToList();
            //    ViewBag.Vehicle = db.VehicleMasters.ToList();
            //    ViewBag.Employee = db.EmployeeMasters.ToList();
            //    ViewBag.Customer = db.CustomerMasters.ToList();
            //    ViewBag.RequestType = db.RequestTypes.ToList();
            //    ViewBag.empname = empname;
            //    ViewBag.empid = empid;
            //    PickupRequestDAO doa = new PickupRequestDAO();
            //    ViewBag.RequestNo = doa.GetMaxPickupRequest();
            //    return View();
            //}
        }
Ejemplo n.º 19
0
        public ActionResult Create()
        {
            int        branchid   = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int        companyid  = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            int        yearid     = Convert.ToInt32(Session["fyearid"].ToString());
            DatePicker datePicker = SessionDataModel.GetTableVariable();

            ViewBag.Token    = datePicker;
            ViewBag.Movement = db.CourierMovements.ToList();
            if (datePicker != null)
            {
                ViewBag.Customer = (from c in db.InScanMasters
                                    join cust in db.CustomerMasters on c.CustomerID equals cust.CustomerID
                                    where (c.TransactionDate >= datePicker.FromDate && c.TransactionDate < datePicker.ToDate)
                                    select new CustmorVM {
                    CustomerID = cust.CustomerID, CustomerName = cust.CustomerName
                }).Distinct();
            }

            CustomerInvoiceVM _custinvoice = new CustomerInvoiceVM();
            PickupRequestDAO  _dao         = new PickupRequestDAO();
            DateTime          saveNow      = DateTime.Now;
            DateTime          myDt;

            myDt = DateTime.SpecifyKind(saveNow, DateTimeKind.Unspecified);

            _custinvoice.InvoiceDate       = myDt;// DateTimeKind. DateTimeOffset.Now.UtcDateTime.AddHours(5.30); // DateTime.Now;
            _custinvoice.CustomerInvoiceNo = _dao.GetMaxInvoiceNo(companyid, branchid);
            //_custinvoice.FromDate = datePicker.FromDate;
            //_custinvoice.ToDate = datePicker.ToDate.Date.AddHours(23).AddMinutes(59).AddSeconds(59);
            List <CustomerInvoiceDetailVM> _details = new List <CustomerInvoiceDetailVM>();

            if (datePicker != null)
            {
                if (datePicker.CustomerId != null)
                {
                    _custinvoice.CustomerID = Convert.ToInt32(datePicker.CustomerId);
                }
                _details = RevenueDAO.GenerateInvoice(datePicker.FromDate, datePicker.ToDate, Convert.ToInt32(datePicker.CustomerId), yearid, 0);

                int _index = 0;
                _custinvoice.InvoiceTotal = 0;

                foreach (var item in _details)
                {
                    _details[_index].AWBChecked = true;
                    _custinvoice.TotalCharges   = _custinvoice.TotalCharges + _details[_index].TotalCharges;
                    _index++;
                }

                _custinvoice.InvoiceTotal = _custinvoice.TotalCharges;
                //_custinvoice.InvoiceTotal = Convert.ToDecimal(customerinvoice.TotalCharges) + Convert.ToDecimal(customerinvoice.ChargeableWT) + customerinvoice.AdminAmt + customerinvoice.FuelAmt + customerinvoice.OtherCharge;
            }


            ////CustomerInvoiceDetailVM _detail = new CustomerInvoiceDetailVM();
            ////_detail.AWBNo = "1010";
            ////_detail.CourierCharge = 100;
            ////_detail.OtherCharge = 2020;
            ////_details.Add(_detail);
            ///
            _custinvoice.CustomerInvoiceDetailsVM = _details;
            if (_details.Count == 0)
            {
                TempData["SuccessMsg"] = "No more Items pending to Invoice!";
            }
            Session["InvoiceListing"] = _details;
            return(View(_custinvoice));
        }
Ejemplo n.º 20
0
        public ActionResult Create(CustomerInvoiceVM model)
        {
            int branchid  = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int companyId = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            var userid    = Convert.ToInt32(Session["UserID"]);
            int yearid    = Convert.ToInt32(Session["fyearid"].ToString());

            if (model.CustomerInvoiceID == 0)
            {
                CustomerInvoice _custinvoice = new CustomerInvoice();
                var             max          = db.CustomerInvoices.Select(x => x.CustomerInvoiceID).DefaultIfEmpty(0).Max() + 1;
                _custinvoice.CustomerInvoiceID = max;
                _custinvoice.CustomerInvoiceNo = model.CustomerInvoiceNo;
                _custinvoice.InvoiceDate       = model.InvoiceDate;
                _custinvoice.CustomerID        = model.CustomerID;
                //_custinvoice.CustomerInvoiceTax = model.CustomerInvoiceTax;
                //_custinvoice.ChargeableWT = model.ChargeableWT;
                //_custinvoice.AdminPer = model.AdminPer;
                //_custinvoice.AdminAmt = model.AdminAmt;
                //_custinvoice.FuelPer = model.FuelPer;
                //_custinvoice.FuelAmt = model.FuelAmt;
                //_custinvoice.OtherCharge = model.OtherCharge;
                _custinvoice.InvoiceTotal      = model.InvoiceTotal;
                _custinvoice.AcFinancialYearID = yearid;
                _custinvoice.AcCompanyID       = companyId;
                _custinvoice.BranchID          = branchid;
                _custinvoice.Remarks           = model.Remarks;
                _custinvoice.CreatedBy         = userid;
                _custinvoice.CreatedDate       = CommanFunctions.GetCurrentDateTime();
                _custinvoice.ModifiedBy        = userid;
                _custinvoice.ModifiedDate      = CommanFunctions.GetCurrentDateTime();
                db.CustomerInvoices.Add(_custinvoice);
                db.SaveChanges();

                List <CustomerInvoiceDetailVM> e_Details = model.CustomerInvoiceDetailsVM; //  Session["InvoiceListing"] as List<CustomerInvoiceDetailVM>;

                model.CustomerInvoiceDetailsVM = e_Details;

                if (model.CustomerInvoiceDetailsVM != null)
                {
                    foreach (var e_details in model.CustomerInvoiceDetailsVM)
                    {
                        if (e_details.CustomerInvoiceDetailID == 0 && e_details.AWBChecked)
                        {
                            CustomerInvoiceDetail _detail = new CustomerInvoiceDetail();
                            _detail.CustomerInvoiceDetailID = db.CustomerInvoiceDetails.Select(x => x.CustomerInvoiceDetailID).DefaultIfEmpty(0).Max() + 1;
                            _detail.CustomerInvoiceID       = _custinvoice.CustomerInvoiceID;
                            _detail.ConsignmentNo           = e_details.ConsignmentNo;
                            _detail.InScanID = e_details.InScanID;
                            //_detail.StatusPaymentMode = e_details.StatusPaymentMode;
                            _detail.FreightCharge = e_details.FreightCharge;
                            _detail.CustomsCharge = e_details.CustomsCharge;
                            _detail.OtherCharge   = e_details.OtherCharge;
                            _detail.DocCharge     = e_details.DocCharge;
                            _detail.NetValue      = e_details.TotalCharges;
                            db.CustomerInvoiceDetails.Add(_detail);
                            db.SaveChanges();

                            //inscan invoice modified
                            InScanMaster _inscan = db.InScanMasters.Find(e_details.InScanID);
                            _inscan.InvoiceID       = _custinvoice.CustomerInvoiceID;
                            db.Entry(_inscan).State = EntityState.Modified;
                            db.SaveChanges();

                            RevenueUpdateMaster _revenueupdate = db.RevenueUpdateMasters.Where(cc => cc.InScanID == e_details.InScanID).FirstOrDefault();
                            var revenuedetails = db.RevenueUpdateDetails.Where(cc => cc.MasterID == _revenueupdate.ID && cc.InvoiceId == null).ToList();
                            foreach (var revdetail in revenuedetails)
                            {
                                revdetail.InvoiceId       = _custinvoice.CustomerInvoiceID;
                                db.Entry(revdetail).State = EntityState.Modified;
                                db.SaveChanges();
                            }
                            _revenueupdate.InvoiceId       = _custinvoice.CustomerInvoiceID;
                            db.Entry(_revenueupdate).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                }

                //Accounts Posting
                PickupRequestDAO _dao = new PickupRequestDAO();
                _dao.GenerateInvoicePosting(_custinvoice.CustomerInvoiceID);

                TempData["SuccessMsg"] = "You have successfully Saved the Customer Invoice";
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 21
0
        public ActionResult Edit(AgentVM item)
        {
            UserRegistration u    = new UserRegistration();
            PickupRequestDAO _dao = new PickupRequestDAO();
            int BranchID          = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int accompanyid       = Convert.ToInt32(Session["CurrentCompanyID"].ToString());

            AgentMaster a = db.AgentMasters.Find(item.ID);

            a.AcCompanyID   = accompanyid;
            a.Name          = item.AgentName;
            a.AgentCode     = item.AgentCode;
            a.Address1      = item.Address1;
            a.Address2      = item.Address2;
            a.Address3      = item.Address3;
            a.Phone         = item.Phone;
            a.Fax           = item.Fax;
            a.WebSite       = item.WebSite;
            a.ContactPerson = item.ContactPerson;
            a.CountryName   = item.CountryName;
            a.CityName      = item.CityName;
            a.LocationName  = item.LocationName;
            a.CurrencyID    = item.CurrencyID;
            // a.ZoneCategoryID = item.ZoneCategoryID;
            //a.AcHeadID = item.AcHeadID;
            a.CreditLimit = item.CreditLimit;
            a.AgentType   = item.AgentType;

            if (item.StatusActive != null)
            {
                a.StatusActive = Convert.ToBoolean(item.StatusActive);
            }
            if (a.BranchID == null)
            {
                a.BranchID = BranchID;
            }

            UserRegistration x = null;

            if (a.UserID != null && a.UserID > 0)
            {
                x = (from b in db.UserRegistrations where b.UserID == a.UserID select b).FirstOrDefault();
            }

            if (a.Email != item.Email || x == null)
            {
                if (x == null)
                {
                    int max1 = (from c1 in db.UserRegistrations orderby c1.UserID descending select c1.UserID).FirstOrDefault();

                    int roleid = db.RoleMasters.Where(t => t.RoleName == "Agent").FirstOrDefault().RoleID;
                    u.UserID   = max1 + 1;
                    u.UserName = item.Email;
                    u.EmailId  = item.Email;

                    if (item.Password == "" || item.Password == null)
                    {
                        u.Password = _dao.RandomPassword(6);
                    }
                    else
                    {
                        u.Password = item.Password;
                    }
                    u.Phone    = item.Phone;
                    u.IsActive = true;
                    u.RoleID   = roleid;
                    db.UserRegistrations.Add(u);
                    db.SaveChanges();

                    a.Email  = item.Email;
                    a.UserID = u.UserID;
                }
                else
                {
                    //checking duplicate
                    UserRegistration x1 = (from b in db.UserRegistrations where b.UserName == item.Email && b.UserID != a.UserID select b).FirstOrDefault();
                    if (x1 == null)
                    {
                        x.EmailId = item.Email;
                        if (item.Password == "")
                        {
                            x.Password = _dao.RandomPassword(6);
                        }
                        else
                        {
                            x.Password = item.Password;
                        }

                        db.Entry(x).State = EntityState.Modified;
                        db.SaveChanges();
                    }

                    a.Email  = item.Email;
                    a.UserID = x.UserID;
                }
            }
            else
            {
                if (a.UserID == null || a.UserID == 0)
                {
                    int max1 = (from c1 in db.UserRegistrations orderby c1.UserID descending select c1.UserID).FirstOrDefault();

                    int roleid = db.RoleMasters.Where(t => t.RoleName == "Agent").FirstOrDefault().RoleID;
                    u.UserID   = max1 + 1;
                    u.UserName = item.Email;
                    u.EmailId  = item.Email;
                    if (item.Password == "")
                    {
                        u.Password = _dao.RandomPassword(6);
                    }
                    else
                    {
                        u.Password = item.Password;
                    }
                    u.Phone    = item.Phone;
                    u.IsActive = true;
                    u.RoleID   = roleid;
                    db.UserRegistrations.Add(u);
                    db.SaveChanges();
                    a.UserID = u.UserID;
                }
                else
                {
                    u = (from b in db.UserRegistrations where b.UserID == a.UserID select b).FirstOrDefault();
                    if (item.Password != u.Password)
                    {
                        u.Password = item.Password;
                    }

                    db.Entry(u).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }



            if (ModelState.IsValid)
            {
                db.Entry(a).State = EntityState.Modified;
                db.SaveChanges();

                if (item.EmailNotify == true)
                {
                    EmailDAO _emaildao = new EmailDAO();
                    _emaildao.SendCustomerEmail(item.Email, item.Email, u.Password);
                }
                TempData["SuccessMsg"] = "You have successfully Updated Agent.";
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Ejemplo n.º 22
0
        public ActionResult Create(EmployeeVM v)
        {
            int BranchID          = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int companyid         = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            PickupRequestDAO _dao = new PickupRequestDAO();
            //if (ModelState.IsValid)
            //{
            EmployeeMaster a   = new EmployeeMaster();
            int            max = (from c in db.EmployeeMasters orderby c.EmployeeID descending select c.EmployeeID).FirstOrDefault();

            a.EmployeeID   = max + 1;
            a.EmployeeName = v.EmployeeName;
            a.EmployeeCode = "";// v.EmployeeCode;
            a.Address1     = v.Address1;
            a.Address2     = v.Address2;
            a.Address3     = v.Address3;
            a.Phone        = v.Phone;

            a.Fax         = v.Fax;
            a.Email       = v.Email;
            a.Mobile      = v.MobileNo;
            a.AcCompanyID = companyid;

            a.CountryName = v.CountryName;
            a.CityName    = v.CityName;

            a.DesignationID    = v.DesignationID;
            a.JoinDate         = Convert.ToDateTime(v.JoinDate);
            a.BranchID         = BranchID;
            a.DepotID          = v.Depot;
            a.Password         = v.Password;
            a.MobileDeviceID   = v.MobileDeviceID;
            a.MobileDevicePwd  = v.MobileDevicePWD;
            a.StatusCommission = v.StatusCommision;
            a.statusDefault    = v.StatusDefault;
            a.StatusActive     = v.StatusActive;
            a.Type             = "E";

            UserRegistration u = new UserRegistration();

            UserRegistration x = (from b in db.UserRegistrations where b.UserName == v.Email select b).FirstOrDefault();

            if (x == null)
            {
                int max1 = (from c1 in db.UserRegistrations orderby c1.UserID descending select c1.UserID).FirstOrDefault();
                u.UserID   = max + 1;
                u.UserName = v.Email;
                u.EmailId  = v.Email;
                u.Password = v.Password;
                u.Phone    = v.Phone;
                u.IsActive = true;
                u.RoleID   = v.RoleID;
                db.UserRegistrations.Add(u);
                db.SaveChanges();
            }

            a.UserID = u.UserID;

            db.EmployeeMasters.Add(a);
            db.SaveChanges();
            ReceiptDAO.ReSaveEmployeeCode();


            TempData["SuccessMsg"] = "You have successfully added Employee.";
            return(RedirectToAction("Index"));
            //}
        }
Ejemplo n.º 23
0
        public ActionResult Edit(CustomerInvoiceVM model)
        {
            var userid = Convert.ToInt32(Session["UserID"]);

            if (model.CustomerInvoiceID > 0)
            {
                CustomerInvoice _custinvoice = new CustomerInvoice();
                _custinvoice                 = db.CustomerInvoices.Find(model.CustomerInvoiceID);
                _custinvoice.InvoiceDate     = model.InvoiceDate;
                _custinvoice.TaxPercent      = model.TaxPercent;
                _custinvoice.InvoiceTotal    = model.InvoiceTotal;
                _custinvoice.Remarks         = model.Remarks;
                _custinvoice.ModifiedBy      = userid;
                _custinvoice.ModifiedDate    = CommanFunctions.GetCurrentDateTime();
                db.Entry(_custinvoice).State = EntityState.Modified;
                db.SaveChanges();

                List <CustomerInvoiceDetailVM> e_Details = model.CustomerInvoiceDetailsVM; //  Session["InvoiceListing"] as List<CustomerInvoiceDetailVM>;

                model.CustomerInvoiceDetailsVM = e_Details;

                if (model.CustomerInvoiceDetailsVM != null)
                {
                    foreach (var e_details in model.CustomerInvoiceDetailsVM)
                    {
                        if (e_details.CustomerInvoiceDetailID == 0 && e_details.AWBChecked)
                        {
                            CustomerInvoiceDetail _detail = new CustomerInvoiceDetail();
                            _detail.CustomerInvoiceDetailID = db.CustomerInvoiceDetails.Select(x => x.CustomerInvoiceDetailID).DefaultIfEmpty(0).Max() + 1;
                            _detail.CustomerInvoiceID       = _custinvoice.CustomerInvoiceID;
                            _detail.ConsignmentNo           = e_details.ConsignmentNo;
                            _detail.InScanID = e_details.InScanID;
                            //_detail.StatusPaymentMode = e_details.StatusPaymentMode;
                            _detail.FreightCharge = e_details.FreightCharge;
                            _detail.CustomsCharge = e_details.CustomsCharge;
                            _detail.DocCharge     = e_details.DocCharge;
                            _detail.OtherCharge   = e_details.OtherCharge;
                            db.CustomerInvoiceDetails.Add(_detail);
                            db.SaveChanges();

                            //inscan invoice modified
                            InScanMaster _inscan = db.InScanMasters.Find(e_details.InScanID);
                            _inscan.InvoiceID       = _custinvoice.CustomerInvoiceID;
                            db.Entry(_inscan).State = EntityState.Modified;
                            db.SaveChanges();

                            RevenueUpdateMaster _revenueupdate = db.RevenueUpdateMasters.Where(cc => cc.InScanID == e_details.InScanID).FirstOrDefault();
                            _revenueupdate.InvoiceId       = _custinvoice.CustomerInvoiceID;
                            db.Entry(_revenueupdate).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                        else if (e_details.CustomerInvoiceDetailID == 0 && e_details.AWBChecked == false)
                        {
                            //CustomerInvoiceDetail _detail = new CustomerInvoiceDetail();
                            //_detail = db.CustomerInvoiceDetails.Find(e_details.CustomerInvoiceID);
                            //_detail.CourierCharge = e_details.CourierCharge;
                            //_detail.CustomCharge = e_details.CustomCharge;
                            //_detail.OtherCharge = e_details.OtherCharge;
                            //db.CustomerInvoiceDetails.Add(_detail);
                            //db.SaveChanges();

                            ////inscan invoice modified
                            //InScanMaster _inscan = db.InScanMasters.Find(e_details.InscanID);
                            //_inscan.InvoiceID = _custinvoice.CustomerInvoiceID;
                            //db.Entry(_inscan).State = System.Data.EntityState.Modified;
                            //db.SaveChanges();
                        }
                        else if (e_details.CustomerInvoiceDetailID > 0 && e_details.AWBChecked == false)
                        {
                            CustomerInvoiceDetail _detail = new CustomerInvoiceDetail();
                            _detail = db.CustomerInvoiceDetails.Find(e_details.CustomerInvoiceDetailID);
                            db.CustomerInvoiceDetails.Remove(_detail);
                            db.SaveChanges();
                            ////inscan invoice modified
                            InScanMaster _inscan = db.InScanMasters.Find(e_details.InScanID);
                            _inscan.InvoiceID       = null;
                            db.Entry(_inscan).State = EntityState.Modified;
                            db.SaveChanges();

                            RevenueUpdateMaster        _revenueupdate       = db.RevenueUpdateMasters.Where(cc => cc.InScanID == e_details.InScanID).FirstOrDefault();
                            List <RevenueUpdateDetail> revenueUpdateDetails = db.RevenueUpdateDetails.Where(cc => cc.MasterID == _revenueupdate.ID).ToList();
                            foreach (RevenueUpdateDetail item in revenueUpdateDetails)
                            {
                                item.InvoiceId       = null;
                                db.Entry(item).State = EntityState.Modified;
                                db.SaveChanges();
                            }
                            //_revenueupdate.InvoiceId = null;
                            //db.Entry(_revenueupdate).State = EntityState.Modified;
                            //db.SaveChanges();
                        }
                    }
                }
                //Accounts Posting
                PickupRequestDAO _dao = new PickupRequestDAO();
                _dao.GenerateInvoicePosting(_custinvoice.CustomerInvoiceID);

                TempData["SuccessMsg"] = "You have successfully Updated the Customer Invoice";
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Ejemplo n.º 24
0
        public ActionResult Edit(EmployeeVM a)
        {
            UserRegistration u       = new UserRegistration();
            PickupRequestDAO _dao    = new PickupRequestDAO();
            int            BranchID  = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int            companyid = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            EmployeeMaster v         = new EmployeeMaster();

            v = db.EmployeeMasters.Find(a.EmployeeID);

            v.EmployeeName = a.EmployeeName;
            v.EmployeeCode = a.EmployeeCode;
            v.Address1     = a.Address1;
            v.Address2     = a.Address2;
            v.Address3     = a.Address3;
            v.Phone        = a.Phone;
            //v.Email = a.Email;
            v.Fax           = a.Fax;
            v.Mobile        = a.MobileNo;
            v.CountryName   = a.CountryName;
            v.AcCompanyID   = companyid;
            v.DesignationID = a.DesignationID;


            v.BranchID = BranchID;
            v.DepotID  = a.Depot;
            //if (v.Password!=a.Password)
            //   v.Password = a.Password;
            v.MobileDeviceID   = a.MobileDeviceID;
            v.MobileDevicePwd  = a.MobileDevicePWD;
            v.JoinDate         = a.JoinDate;
            v.StatusCommission = a.StatusCommision;
            v.statusDefault    = a.StatusDefault;
            v.StatusActive     = a.StatusActive;

            UserRegistration x = null;

            if (a.UserID != null && a.UserID > 0)
            {
                x = (from b in db.UserRegistrations where b.UserID == a.UserID select b).FirstOrDefault();
            }

            if (v.Email != a.Email)
            {
                if (x == null)
                {
                    int max1 = (from c1 in db.UserRegistrations orderby c1.UserID descending select c1.UserID).FirstOrDefault();

                    int roleid = db.RoleMasters.Where(t => t.RoleName == "Agent").FirstOrDefault().RoleID;
                    u.UserID   = max1 + 1;
                    u.UserName = a.Email;
                    u.EmailId  = a.Email;
                    if (a.Password == "")
                    {
                        u.Password = _dao.RandomPassword(6);
                    }
                    else
                    {
                        u.Password = a.Password; //  _dao.RandomPassword(6);
                    }
                    u.Phone    = a.Phone;
                    u.IsActive = true;
                    u.RoleID   = roleid;
                    db.UserRegistrations.Add(u);
                    db.SaveChanges();

                    v.Email  = a.Email;
                    a.UserID = u.UserID;
                }
                else
                {
                    //checking duplicate
                    UserRegistration x1 = (from b in db.UserRegistrations where b.UserName == a.Email && b.UserID != a.UserID select b).FirstOrDefault();
                    if (x1 == null)
                    {
                        x.EmailId = a.Email;
                        if (a.Password == "")
                        {
                            x.Password = _dao.RandomPassword(6);
                        }
                        else
                        {
                            x.Password = a.Password; //  _dao.RandomPassword(6);
                        }
                        db.Entry(x).State = EntityState.Modified;
                        db.SaveChanges();
                    }

                    v.Email  = a.Email;
                    a.UserID = x.UserID;
                }
            }
            else
            {
                if (a.UserID == null || a.UserID == 0)
                {
                    int max1 = (from c1 in db.UserRegistrations orderby c1.UserID descending select c1.UserID).FirstOrDefault();

                    int roleid = db.RoleMasters.Where(t => t.RoleName == "Agent").FirstOrDefault().RoleID;
                    u.UserID   = max1 + 1;
                    u.UserName = a.Email;
                    u.EmailId  = a.Email;

                    if (a.Password == "")
                    {
                        u.Password = _dao.RandomPassword(6);
                    }
                    else
                    {
                        u.Password = a.Password; //  _dao.RandomPassword(6);
                    }
                    u.Phone    = a.Phone;
                    u.IsActive = true;
                    u.RoleID   = a.RoleID;
                    db.UserRegistrations.Add(u);
                    db.SaveChanges();

                    v.UserID = u.UserID;
                }
                else
                {
                    u = (from b in db.UserRegistrations where b.UserID == a.UserID select b).FirstOrDefault();
                    if (u.Password != a.Password)
                    {
                        u.Password = a.Password;
                    }

                    if (u.RoleID != a.RoleID)
                    {
                        u.RoleID = a.RoleID;
                    }
                    if (u.Password == null)
                    {
                        u.Password = "******";
                    }
                    db.Entry(u).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }



            db.Entry(v).State = EntityState.Modified;
            db.SaveChanges();
            TempData["SuccessMsg"] = "You have successfully Update Employee.";
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 25
0
        public ActionResult Create(TruckDetailVM1 data)
        {
            try
            {
                int branchid          = Convert.ToInt32(Session["CurrentBranchID"].ToString());
                int companyId         = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
                int FYearId           = Convert.ToInt32(Session["fyearid"].ToString());
                var TruckDetail       = new TruckDetail();
                var TruckDetailID     = Convert.ToInt32(data.TruckDetailID);
                PickupRequestDAO _dao = new PickupRequestDAO();
                TruckDetail = (from d in db.TruckDetails where d.TruckDetailID == TruckDetailID select d).FirstOrDefault();
                if (TruckDetail == null)
                {
                    TruckDetail = new TruckDetail();
                    var Truck = db.TruckDetails.ToList().LastOrDefault();
                    var MaxId = 1000;
                    if (Truck == null)
                    {
                        MaxId = 1;
                    }
                    else
                    {
                        MaxId = Truck.TruckDetailID + 1;
                    }

                    TruckDetail.ReceiptNo = _dao.GetTDSReceiptNo(companyId, branchid, data.VehicleType, FYearId);
                }

                TruckDetail.VehicleID = Convert.ToInt32(data.VehicleID);
                var vehicle = db.VehicleMasters.Find(data.VehicleID);
                TruckDetail.FYearID     = FYearId;
                TruckDetail.AcCompanyID = companyId;
                TruckDetail.BranchID    = branchid;
                TruckDetail.VehicleType = Convert.ToString(data.VehicleType);

                if (TruckDetail.VehicleType == "F")
                {
                    TruckDetail.ForwardAgentID = Convert.ToInt32(data.ForwardAgentID);
                    TruckDetail.RegNo          = Convert.ToString(data.RegNo);
                }
                else
                {
                    TruckDetail.ForwardAgentID = null;
                    TruckDetail.RegNo          = vehicle.RegistrationNo;
                    TruckDetail.DriverID       = Convert.ToInt32(data.DriverID);
                    TruckDetail.DriverName     = Convert.ToString(data.DriverName);
                }

                TruckDetail.TDDate = Convert.ToDateTime(data.TDDate);
                if (data.StatusPaymentMode != null)
                {
                    TruckDetail.StatusPaymentMode = Convert.ToString(data.StatusPaymentMode);
                }
                else
                {
                    TruckDetail.StatusPaymentMode = "N";
                }
                if (TruckDetail.StatusPaymentMode.Trim() == "B")
                {
                    if (data.ChequeNo != null)
                    {
                        TruckDetail.ChequeNo = Convert.ToString(data.ChequeNo);
                    }
                    try
                    {
                        if (data.ChequeDate != null)
                        {
                            TruckDetail.ChequeDate = Convert.ToDateTime(data.ChequeDate);
                        }
                    }
                    catch (Exception ex1)
                    {
                        TruckDetail.ChequeDate = null;
                    }
                }
                if (data.RouteID != null)
                {
                    TruckDetail.RouteID = Convert.ToInt32(data.RouteID);
                }

                TruckDetail.OriginName        = Convert.ToString(data.OriginName);
                TruckDetail.DestinationName   = Convert.ToString(data.DestinationName);
                TruckDetail.ParcelTypeId      = data.ParcelTypeId;
                TruckDetail.Rent              = Convert.ToDecimal(data.Rent);
                TruckDetail.CurrencyIDRent    = Convert.ToInt32(data.CurrencyIDRent);
                TruckDetail.OtherCharges      = Convert.ToDecimal(data.OtherCharges);
                TruckDetail.ConsignmentNoNote = Convert.ToString(data.ConsignmentNoNote);
                //TruckDetail.CurrencyRent = Convert.ToDecimal(data.CurrencyRent);
                TruckDetail.RentAcHeadID = Convert.ToInt32(data.RentAcHeadID);
                TruckDetail.TDRemarks    = Convert.ToString(data.TDRemarks);

                if (TruckDetail.StatusPaymentMode.Trim() == "C" || TruckDetail.StatusPaymentMode.Trim() == "B")
                {
                    TruckDetail.PaymentHeadID     = Convert.ToInt32(data.PaymentHeadID);
                    TruckDetail.TDcontrolAcHeadID = Convert.ToInt32(data.TDcontrolAcHeadID);
                    TruckDetail.CurrencyAmount    = Convert.ToDecimal(data.Amount);
                    TruckDetail.Amount            = Convert.ToDecimal(data.Amount);
                    TruckDetail.PaymentCurrencyID = Convert.ToInt32(data.PaymentCurrencyID);
                    TruckDetail.Remarks           = Convert.ToString(data.Remarks);
                }
                else
                {
                    TruckDetail.StatusPaymentMode = "N";
                }

                TruckDetail.IsDeleted = false;

                if (TruckDetail.TruckDetailID == 0)
                {
                    db.TruckDetails.Add(TruckDetail);
                }

                db.SaveChanges();
                if (data.TruckDetailID > 0)
                {
                    var details = (from d in db.TruckDetailOtherCharges where d.TruckDetailId == data.TruckDetailID select d).ToList();
                    db.TruckDetailOtherCharges.RemoveRange(details);
                    db.SaveChanges();
                }

                //Other charge data update into inscanothercharge table
                if (data.otherchargesVM != null)
                {
                    for (int j = 0; j < data.otherchargesVM.Count; j++)
                    {
                        if (data.otherchargesVM[j].deleted == false)
                        {
                            //InscanOtherCharge objOtherCharge = new InscanOtherCharge();
                            int oid = Convert.ToInt32(data.otherchargesVM[j].OtherChargeID);
                            TruckDetailOtherCharge objOtherCharge = db.TruckDetailOtherCharges.Where(cc => cc.TruckDetailId == TruckDetail.TruckDetailID && cc.OtherChargeID == oid).FirstOrDefault();
                            if (objOtherCharge == null)
                            {
                                objOtherCharge = new TruckDetailOtherCharge();
                                var maxid = (from c in db.TruckDetailOtherCharges orderby c.TruckDetailOtherChargeID descending select c.TruckDetailOtherChargeID).FirstOrDefault();
                                objOtherCharge.TruckDetailOtherChargeID = maxid + 1;
                                objOtherCharge.TruckDetailId            = TruckDetail.TruckDetailID;
                                objOtherCharge.OtherChargeID            = data.otherchargesVM[j].OtherChargeID;
                                objOtherCharge.Amount = data.otherchargesVM[j].Amount;
                                db.TruckDetailOtherCharges.Add(objOtherCharge);
                                db.SaveChanges();
                                db.Entry(objOtherCharge).State = EntityState.Detached;
                            }
                            else
                            {
                                //objOtherCharge.OtherChargeID = v.otherchargesVM[j].OtherChargeID;
                                objOtherCharge.Amount          = data.otherchargesVM[j].Amount;
                                db.Entry(objOtherCharge).State = EntityState.Modified;
                                db.SaveChanges();
                                db.Entry(objOtherCharge).State = EntityState.Detached;
                            }
                        }
                    }

                    //var otherchargeitems = db.TruckDetailOtherCharges.Where(cc => cc.TruckDetailId==data.TruckDetailID);
                    //var exportdetailsid = data.otherchargesVM.Select(s => s.OtherChargeID).ToList();
                    //foreach (var e_details in otherchargeitems)
                    //{

                    //    var _found = data.otherchargesVM.Where(cc => cc.OtherChargeID == e_details.OtherChargeID).FirstOrDefault();
                    //    if (_found == null)
                    //    {
                    //        db.Entry(e_details).State = EntityState.Deleted;

                    //    }
                    //}

                    //db.SaveChanges();
                }
                /// other charges saving
                _dao.GenerateDailyTripsPosting(TruckDetail.TruckDetailID);
                TempData["SuccessMsg"] = "Daily Trips Saved Successfully!";
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ViewBag.parceltype = db.ParcelTypes.ToList();
                ViewBag.Routes     = db.RouteMasters.ToList();
                ViewBag.Currency   = db.CurrencyMasters.ToList();
                int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());
                ViewBag.Achead       = db.AcHeads.Where(d => d.AcBranchID == branchid).ToList();
                ViewBag.Documents    = db.DocumentSetups.ToList();
                ViewBag.VehicleTypes = db.VehicleTypes.ToList();
                ViewBag.FwdAgents    = db.SupplierMasters.Where(c => c.SupplierTypeID == 2).ToList();
                ViewBag.OtherCharge  = db.OtherCharges.ToList();
                TempData["ErrorMsg"] = e.Message;
                if (data.otherchargesVM == null)
                {
                    data.otherchargesVM = new List <TruckDetailOtherChargeVM>();
                }
                return(View(data));
            }
        }