예제 #1
0
        public ActionResult store()
        {
            var role = RouteData.Values["role"].ToString();

            ViewBag.role   = role;
            ViewBag.layout = "~/Views/Shared/_" + role + "Layout.cshtml";

            tblBranch branchObj = new tblBranch();

            branchObj.branch_id           = Request["branch_id"];
            branchObj.branch_name         = Request["branch_name"];
            branchObj.branch_manager_id   = Request["branch_manager_id"];
            branchObj.mobile_number       = Request["phone"];
            branchObj.alter_mobile_number = Request["alternate_phone"];
            branchObj.street     = Request["street"];
            branchObj.city       = Request["city"];
            branchObj.state      = Request["state"];
            branchObj.pincode    = Request["pin"];
            branchObj.createdat  = null;
            branchObj.modifiedat = null;
            branchObj.deletedat  = null;

            branchObject.tblBranches.InsertOnSubmit(branchObj);
            branchObject.SubmitChanges();
            var redirectUrl = "/profile/" + role + "/branch/index";

            Response.Redirect(redirectUrl);
            return(View());
        }
예제 #2
0
        public JsonResult GetData()
        {
            using (ELaundryDBEntities db = new ELaundryDBEntities())
            {
                MyRoleProvider mr = new MyRoleProvider();
                db.Configuration.LazyLoadingEnabled = false;
                List <UserViewModel> lstuser = new List <UserViewModel>();
                var      lst = db.tblUsers.ToList();
                string[] str = new string[] { };

                foreach (var item in lst)
                {
                    string roles = "";
                    str = mr.GetRolesForUser(item.Username);
                    if (str.Length > 0)
                    {
                        foreach (var r in str)
                        {
                            roles += r.ToString() + ",";
                        }
                        roles = roles.Remove(roles.IndexOf(','));
                    }

                    tblUserBranch tbub = db.tblUserBranches.Where(u => u.UserId == item.UserId).FirstOrDefault();
                    tblBranch     br   = db.tblBranches.Where(u => u.BranchId == tbub.BranchId).FirstOrDefault();

                    lstuser.Add(new UserViewModel()
                    {
                        UserId = item.UserId, Username = item.Username, Fullname = item.Fullname, RoleName = roles, BranchName = br.BranchName
                    });
                }
                return(Json(new { data = lstuser }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #3
0
        public ActionResult Login(LoginViewModel l, string ReturnUrl = "")
        {
            using (ELaundryDBEntities db = new ELaundryDBEntities())
            {
                string password = Utilities.Base64Encode(l.Password);
                var    users    = db.tblUsers.Where(a => a.Username == l.Username && a.Password == password).FirstOrDefault();
                if (users != null)
                {
                    tblUserBranch ubra = db.tblUserBranches.Where(u => u.UserId == users.UserId).FirstOrDefault();
                    Session.Add("branchid", ubra.BranchId);
                    tblBranch br = db.tblBranches.Where(b => b.BranchId == ubra.BranchId).FirstOrDefault();
                    Session.Add("branchname", br.BranchName);
                    Session.Add("username", users.Username);
                    Session.Add("fullname", users.Fullname);
                    FormsAuthentication.SetAuthCookie(l.Username, true);
                    if (Url.IsLocalUrl(ReturnUrl))
                    {
                        return(Redirect(ReturnUrl));
                    }
                    else
                    {
                        Session.Add("userid", users.UserId);

                        return(RedirectToAction("DashBoard", "Admin"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Invalid User");
                }
            }
            return(View());
        }
예제 #4
0
        // Location Update
        /// <summary>
        ///
        /// </summary>
        /// <param name="BusinessObject"></param>
        /// <returns></returns>
        public string UpdateLocation(BusinessObject BusinessObject)
        {
            tblBranch tblBranch = bringlyEntities.tblBranches
                                  .Where(x => x.BranchGuid == BusinessObject.BusinessGuid)
                                  .FirstOrDefault();

            tblBranch.BranchName      = BusinessObject.BusinessName;
            tblBranch.FK_CityGuid     = BusinessObject.CityGuid;
            tblBranch.PNumber         = BusinessObject.PNumber;
            tblBranch.Phone           = BusinessObject.Phone;
            tblBranch.PinCode         = BusinessObject.PinCode;
            tblBranch.ModifiedBy      = UserVariables.LoggedInUserGuid;
            tblBranch.ModifiedDate    = DateTime.Now;
            tblBranch.Address         = BusinessObject.Address;
            tblBranch.Email           = BusinessObject.Email;
            tblBranch.ManagerUserGuid = BusinessObject.ManagerGuid ?? Guid.Empty;
            tblBranch.OrderTiming     = BusinessObject.OrderTiming;
            tblBranch.PickUpTiming    = BusinessObject.PickUpTiming;
            tblBranch.ServiceCharge   = BusinessObject.ServiceCharge;
            tblBranch.ServiceTax      = BusinessObject.ServiceTax;
            tblBranch.FlatRate        = BusinessObject.FlatRate;
            tblBranch.RateAfterKm     = BusinessObject.RateAfterKm;
            tblBranch.Description     = BusinessObject.Description;
            tblBranch.Latitude        = BusinessObject.Latitude;
            tblBranch.Longitude       = BusinessObject.Longitude;
            tblBranch.PlaceId         = BusinessObject.PlaceId;
            tblBranch.Country         = BusinessObject.CountryName;
            bringlyEntities.SaveChanges();

            string cityname = bringlyEntities.tblCities.Where(x => x.CityGuid == BusinessObject.CityGuid).FirstOrDefault().CityName;

            return(cityname);
        }
예제 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="businessObject"></param>
        /// <returns></returns>
        public bool UpdateAboutUsPageMerchant(BusinessObject businessObject)
        {
            tblMerchantAboutUsPage tblMerchantAboutUsPage = bringlyEntities.tblMerchantAboutUsPages
                                                            .Where(x => x.FK_BranchGuid == businessObject.BusinessGuid && x.AboutUsPageGuid == businessObject.AboutUsPageGuid)
                                                            .FirstOrDefault();

            if (tblMerchantAboutUsPage == null)
            {
                tblBranch tblBranch = bringlyEntities.tblBranches
                                      .Where(x => x.FK_CreatedByGuid == UserVariables.LoggedInUserGuid && x.BranchGuid == businessObject.BusinessGuid)
                                      .FirstOrDefault();

                tblMerchantAboutUsPage = new tblMerchantAboutUsPage();
                tblMerchantAboutUsPage.AboutUsPageGuid = Guid.NewGuid();
                tblMerchantAboutUsPage.FK_BranchGuid   = tblBranch.BranchGuid;
                tblMerchantAboutUsPage.CreatedByGuid   = UserVariables.LoggedInUserGuid;
                tblMerchantAboutUsPage.DateCreated     = DateTime.Now;
                tblMerchantAboutUsPage.Description     = businessObject.AboutUsDescription;
                tblMerchantAboutUsPage.IsActive        = true;
                tblMerchantAboutUsPage.IsDelete        = false;
                tblMerchantAboutUsPage.Title           = businessObject.AboutUsTitle;
                bringlyEntities.tblMerchantAboutUsPages.Add(tblMerchantAboutUsPage);
            }
            else
            {
                tblMerchantAboutUsPage.Title       = businessObject.AboutUsTitle;
                tblMerchantAboutUsPage.Description = businessObject.AboutUsDescription;
            }
            bringlyEntities.SaveChanges();

            return(true);
        }
예제 #6
0
 public static BranchCreateModel ConvertToBranch(this tblBranch data)
 {
     return(new BranchCreateModel()
     {
         id = data.ID,
         branchId = data.ID,
         branchName = data.BranchName,
         locationId = data.LocationID,
         locationName = data.tblLocation != null ? data.tblLocation.LocationName : "",
         emailAddress = data.EmailAddress,
         phoneNumber = data.PhoneNumber,
         streetLine1 = data.StreetLine1,
         streetLine2 = data.StreetLine2,
         city = data.City,
         stateId = data.StateID.ToString(),
         stateName = data.tblCountryState != null ? data.tblCountryState.Name : "",
         countryId = data.CountryID.ToString(),
         countryName = data.tblCountry != null ? data.tblCountry.Name : "",
         isActive = data.IsActive,
         isDeleted = data.IsDeleted,
         createdUserID = data.CreatedUserID,
         updatedUserID = data.UpdatedUserID,
         createdTimestamp = data.CreatedTimestamp,
         updatedTimestamp = data.UpdatedTimestamp
     });
 }
예제 #7
0
        public async Task <BranchCreateModel> CreateBranch(BranchCreateModel data)
        {
            try
            {
                BranchCreateModel model      = null;
                tblBranch         dataBranch = await Task.Run(() => ManageBranch.InsertBranch(data.ConvertTotblBranch()));

                model         = (await Task.Run(() => ManageBranch.GetBranchDetails(dataBranch.ID))).ConvertToBranch();
                data.branchId = model.id;

                switch (data.companyType)
                {
                case "MSP":
                    tblMSPLocationBranch dataMSP = await Task.Run(() => ManageMSP.InsertMSPLocationBranch(data.ConvertTotblMSPLocationBranch()));

                    break;

                case "Customer":
                    tblCustomerLocationBranch dataCustomer = await Task.Run(() => ManageCustomer.InsertCustomerLocationBranch(data.ConvertTotblCustomerLocationBranch()));

                    break;

                case "Supplier":
                    tblSupplierLocationBranch dataSupplier = await Task.Run(() => ManageSupplier.InsertSupplierLocationBranch(data.ConvertTotblSupplierLocationBranch()));

                    break;
                }

                return(model);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public ActionResult store()
        {
            tblBranch branchObj = new tblBranch();

            branchObj.branch_id           = Request["branch_id"];
            branchObj.branch_name         = Request["branch_name"];
            branchObj.branch_manager_id   = Request["branch_manager_id"];
            branchObj.mobile_number       = Request["phone"];
            branchObj.alter_mobile_number = Request["alternate_phone"];
            branchObj.street     = Request["street"];
            branchObj.city       = Request["city"];
            branchObj.state      = Request["state"];
            branchObj.pincode    = Request["pin"];
            branchObj.createdat  = null;
            branchObj.modifiedat = null;
            branchObj.deletedat  = null;

            branchObject.tblBranches.InsertOnSubmit(branchObj);
            branchObject.SubmitChanges();



            Response.Redirect("/branch/index");
            return(View());
        }
예제 #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblBranch tblBranch = db.tblBranches.Find(id);

            db.tblBranches.Remove(tblBranch);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #10
0
        public JsonResult LineChart()
        {
            DateTime dt = Convert.ToDateTime(DateTime.Today);
            List <ClosingDisplay> lstclose = new List <ClosingDisplay>();
            List <tblUserRole>    lstur    = _db.tblUserRoles.Where(u => u.RoleId == 2).ToList();

            foreach (var ur in lstur)
            {
                tblUser tb = _db.tblUsers.Where(u => u.UserId == ur.UserId).FirstOrDefault();



                tblUserBranch     tub    = _db.tblUserBranches.Where(u => u.UserId == ur.UserId).FirstOrDefault();
                tblBranch         tbbra  = _db.tblBranches.Where(b => b.BranchId == tub.BranchId).FirstOrDefault();
                decimal           amount = 0M;
                List <tblInvoice> lst    = _db.tblInvoices.Where(t => t.InvoiceDate == dt).Where(u => u.UserId == ur.UserId).ToList();
                if (lst.Count > 0)
                {
                    foreach (var item in lst)
                    {
                        amount += Convert.ToDecimal(item.NetAmount);
                    }

                    ClosingDisplay cd = new ClosingDisplay();
                    cd.UserId      = ur.UserId;
                    cd.TotalAmount = amount;
                    cd.Username    = tb.Username;
                    cd.BranchName  = tbbra.BranchName;
                    cd.BranchId    = tbbra.BranchId;
                    lstclose.Add(cd);
                }
            }
            List <object> iData = new List <object>();
            //Creating sample data
            DataTable dtt = new DataTable();

            dtt.Columns.Add("Username", System.Type.GetType("System.String"));
            dtt.Columns.Add("TotalAmount", System.Type.GetType("System.Decimal"));

            foreach (var item in lstclose)
            {
                DataRow dr = dtt.NewRow();
                dr["Username"]    = item.Username;
                dr["TotalAmount"] = item.TotalAmount;
                dtt.Rows.Add(dr);
            }


            //Looping and extracting each DataColumn to List<Object>
            foreach (DataColumn dc in dtt.Columns)
            {
                List <object> x = new List <object>();
                x = (from DataRow drr in dtt.Rows select drr[dc.ColumnName]).ToList();
                iData.Add(x);
            }
            //Source data returned as JSON
            return(Json(iData, JsonRequestBehavior.AllowGet));
        }
예제 #11
0
        // Delete Location
        /// <summary>
        ///
        /// </summary>
        /// <param name="businessGuid"></param>
        /// <returns></returns>
        public bool DeleteLocation(Guid businessGuid)
        {
            tblBranch tblLocation = bringlyEntities.tblBranches
                                    .Where(x => x.BranchGuid == businessGuid && x.IsDeleted == false)
                                    .FirstOrDefault();

            tblLocation.IsDeleted = true;
            bringlyEntities.SaveChanges();

            return(true);
        }
예제 #12
0
 public ActionResult Edit([Bind(Include = "BranchId,SchoolId,BranchName,AddressLine1,AddressLine2,AddressLine3,City,State,Country,Pincode,ContactNo1,ContactNo2,EmailId,StartingYear,CreateDate,UpdateDate")] tblBranch tblBranch)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblBranch).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SchoolId = new SelectList(db.tblSchools, "Id", "SchoolName", tblBranch.SchoolId);
     return(View(tblBranch));
 }
예제 #13
0
        public async Task <BranchCreateModel> UpdateBranch(BranchCreateModel model)
        {
            try
            {
                tblBranch data = await Task.Run(() => ManageBranch.UpdateBranch(model.ConvertTotblBranch()));

                return(data.ConvertToBranch());
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #14
0
        // GET: Branches/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblBranch tblBranch = db.tblBranches.Find(id);

            if (tblBranch == null)
            {
                return(HttpNotFound());
            }
            return(View(tblBranch));
        }
예제 #15
0
        // GET: Branches/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblBranch tblBranch = db.tblBranches.Find(id);

            if (tblBranch == null)
            {
                return(HttpNotFound());
            }
            ViewBag.SchoolId = new SelectList(db.tblSchools, "Id", "SchoolName", tblBranch.SchoolId);
            return(View(tblBranch));
        }
        public bool Delete(BranchEntity Branch)
        {
            try
            {
                TIMSDBEntities entity    = new TIMSDBEntities();
                tblBranch      tblBranch = entity.tblBranches.Where(x => x.ID == Branch.ID).FirstOrDefault();

                entity.tblBranches.Remove(tblBranch);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #17
0
        public ActionResult Create(tblBranch newBranch)
        {
            if (Session["StudioID"] == null && Session["StudioName"] == null && Session["StudioPhoneNo"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }

            if (ModelState.IsValid)
            {
                newBranch.CreatedDate = DateTime.Now;
                db.tblBranches.Add(newBranch);
                db.SaveChanges();
                return(Json(new { success = true, message = "Record inserted" }, JsonRequestBehavior.AllowGet));
            }

            return(View(newBranch));
        }
예제 #18
0
        internal static async Task DeleteBranch(long Id)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    tblBranch obj = await db.tblBranches.FindAsync(Id);

                    db.tblBranches.Remove(obj);
                    int x = await Task.Run(() => db.SaveChangesAsync());
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public BranchEntity GetSingle(int ID)
        {
            try
            {
                TIMSDBEntities entity = new TIMSDBEntities();

                tblBranch    tblBranch = entity.tblBranches.Where(x => x.ID == ID).FirstOrDefault();
                BranchEntity Branch    = new BranchEntity();
                Branch.ID   = tblBranch.ID;
                Branch.Name = tblBranch.Name;

                return(Branch);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #20
0
 public ActionResult DeleteBranch(int id)
 {
     if (Session["StudioID"] == null && Session["StudioName"] == null && Session["StudioPhoneNo"] == null)
     {
         return(RedirectToAction("Login", "Login"));
     }
     try
     {
         tblBranch tblBranch = db.tblBranches.Find(id);
         db.tblBranches.Remove(tblBranch);
         db.SaveChanges();
         return(Json(new { success = true, message = "Record deleted successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = "Record not deleted" + ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
예제 #21
0
        internal static async Task <tblBranch> UpdateBranch(tblBranch model)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    db.Entry(model).State = EntityState.Modified;

                    int x = await Task.Run(() => db.SaveChangesAsync());

                    return(model);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #22
0
        internal static async Task <tblBranch> InsertBranch(tblBranch model)
        {
            try
            {
                using (db = new eMSPEntities())
                {
                    model = db.tblBranches.Add(model);

                    int x = await Task.Run(() => db.SaveChangesAsync());

                    return(model);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public bool Save(BranchEntity Branch)
        {
            try
            {
                tblBranch tblBranch = new tblBranch();

                tblBranch.ID   = Branch.ID;
                tblBranch.Name = Branch.Name;

                TIMSDBEntities entity = new TIMSDBEntities();
                entity.tblBranches.Add(tblBranch);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #24
0
        public ActionResult MakeClosing()
        {
            DateTime dt = Convert.ToDateTime(DateTime.Today);


            List <ClosingDisplay> lstclose = new List <ClosingDisplay>();

            List <tblUserRole> lstur = db.tblUserRoles.Where(u => u.RoleId == 2).ToList();

            foreach (var ur in lstur)
            {
                tblUser tb = db.tblUsers.Where(u => u.UserId == ur.UserId).FirstOrDefault();

                bool i = cdb.CheckClosingDate(tb.UserId);
                if (!i)
                {
                    tblUserBranch     tub    = db.tblUserBranches.Where(u => u.UserId == ur.UserId).FirstOrDefault();
                    tblBranch         tbbra  = db.tblBranches.Where(b => b.BranchId == tub.BranchId).FirstOrDefault();
                    decimal           amount = 0M;
                    List <tblInvoice> lst    = db.tblInvoices.Where(t => t.InvoiceDate == dt).Where(u => u.UserId == ur.UserId).ToList();
                    if (lst.Count > 0)
                    {
                        foreach (var item in lst)
                        {
                            amount += Convert.ToDecimal(item.NetAmount);
                        }

                        ClosingDisplay cd = new ClosingDisplay();
                        cd.UserId      = ur.UserId;
                        cd.TotalAmount = amount;
                        cd.Username    = tb.Username;
                        cd.BranchName  = tbbra.BranchName;
                        cd.BranchId    = tbbra.BranchId;
                        lstclose.Add(cd);
                    }
                    ViewBag.Records = lstclose;
                }
            }


            return(View());
        }
        public bool Update(BranchEntity Branch)
        {
            try
            {
                tblBranch newBranch = new tblBranch();

                newBranch.ID   = Branch.ID;
                newBranch.Name = Branch.Name;

                TIMSDBEntities entity    = new TIMSDBEntities();
                tblBranch      oldBranch = entity.tblBranches.Where(x => x.ID == Branch.ID).FirstOrDefault();
                entity.Entry(oldBranch).CurrentValues.SetValues(newBranch);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #26
0
        // Add Location
        /// <summary>
        ///
        /// </summary>
        /// <param name="BusinessObject"></param>
        /// <returns></returns>
        public Guid AddLocation(BusinessObject BusinessObject)
        {
            tblBusiness business = bringlyEntities.tblBusinesses
                                   .Where(x => x.FK_CreatedByGuid == UserVariables.LoggedInUserGuid)
                                   .FirstOrDefault();

            tblBranch tblBranch = new tblBranch();

            tblBranch.BranchGuid          = Guid.NewGuid();
            tblBranch.FK_BusinessTypeGuid = business.FK_BusinessTypeGuid;
            tblBranch.BranchName          = BusinessObject.BusinessName;
            tblBranch.FK_CityGuid         = BusinessObject.CityGuid;
            tblBranch.PNumber             = BusinessObject.PNumber;
            tblBranch.Phone            = BusinessObject.Phone;
            tblBranch.PinCode          = BusinessObject.PinCode;
            tblBranch.FK_CreatedByGuid = UserVariables.LoggedInUserGuid;
            tblBranch.DateCreated      = DateTime.Now;
            tblBranch.Address          = BusinessObject.Address;
            tblBranch.Email            = BusinessObject.Email;
            tblBranch.ManagerUserGuid  = (BusinessObject.ManagerGuid == null || (!BusinessObject.ManagerGuid.HasValue || BusinessObject.ManagerGuid.Value == Guid.Empty)) ? UserVariables.LoggedInUserGuid : BusinessObject.ManagerGuid.Value;
            tblBranch.OrderTiming      = BusinessObject.OrderTiming;
            tblBranch.PickUpTiming     = BusinessObject.PickUpTiming;
            tblBranch.ServiceCharge    = BusinessObject.ServiceCharge;
            tblBranch.ServiceTax       = BusinessObject.ServiceTax;
            tblBranch.FlatRate         = BusinessObject.FlatRate;
            tblBranch.RateAfterKm      = BusinessObject.RateAfterKm;
            tblBranch.Description      = BusinessObject.Description;
            tblBranch.IsDeleted        = false;
            tblBranch.Latitude         = BusinessObject.Latitude;
            tblBranch.Longitude        = BusinessObject.Longitude;
            tblBranch.PlaceId          = BusinessObject.PlaceId;
            tblBranch.Country          = BusinessObject.CountryName;
            bringlyEntities.tblBranches.Add(tblBranch);
            bringlyEntities.SaveChanges();

            return(tblBranch.BranchGuid);
        }
예제 #27
0
        public async Task <IActionResult> Branch(BrancViewModel model)
        {
            if (ModelState.IsValid)
            {
                //check if the user exist
                var user = await userManager.FindByIdAsync(model.User_FK);

                if (user == null)
                {
                    ViewBag.ErrorMessage = $"User with Id = {model.User_FK} cannot be found";
                    return(View("NotFound"));
                }

                //Check if the brach has the same brach code
                if (context.Exist <tblBranch>((x) => x.Code == model.Code))
                {
                    ModelState.AddModelError("", $"Brach code: {model.Code} already exist");
                    return(View(model));
                }

                tblBranch table = new tblBranch()
                {
                    Code    = model.Code,
                    Created = DateTime.Now,
                    Id      = Guid.NewGuid().ToString(),
                    Name    = model.Branch,
                    User_FK = model.User_FK
                };

                await context.AddAsync <tblBranch>(table);

                return(RedirectToAction("branches"));
            }

            return(View(model));
        }