public ActionResult AddExpense(DailyExpense dailyexpense)
        {
            var status = "error";

            try
            {
                if (!Authenticated)
                {
                    status = "SESSION EXPIRED";
                }
                else
                {
                    dailyexpense.CreatedOn = DateTime.Now;
                    dailyexpense.CreatedBy = ActiveUserId;
                    dailyexpense.UID       = Guid.NewGuid();
                    dailyexpense.Status    = 1;


                    db.DailyExpenses.Add(dailyexpense);
                    if (db.SaveChanges() > 0)
                    {
                        status = JsonConvert.SerializeObject(dailyexpense);
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "CategoryController", "AddCategory");
            }

            return(Content(status));
        }
        public ActionResult AddAccount(PersonalAccount Account)
        {
            var status = "error";

            try
            {
                if (!Authenticated)
                {
                    status = "SESSION EXPIRED";
                }
                else
                {
                    Account.CreatedOn = DateTime.Now;
                    Account.CreatedBy = ActiveUserId;
                    Account.UID       = Guid.NewGuid();
                    Account.Status    = 1;


                    db.PersonalAccounts.Add(Account);
                    if (db.SaveChanges() > 0)
                    {
                        status = JsonConvert.SerializeObject(Account);
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "PersonalAccountController", "AddAccount");
            }

            return(Content(status));
        }
        public ActionResult AddSize(Size size)
        {
            var status = "error";
            try
            {
                if (!Authenticated)
                {
                    status = "SESSION EXPIRED";
                }
                else
                {
                    var objSize = db.Sizes.Where(x => x.Name == size.Name).ToList();
                    if (objSize.Count < 1)
                    {
                        objSize = null;
                    }
                    if (objSize == null)
                    {
                        if (size.IsActive == null)
                        {
                            size.IsActive = false;
                        }
                        size.CreatedOn = DateTime.Now;
                        size.UID = Guid.NewGuid();
                        size.CreatedBy = ActiveUserId;

                        db.Sizes.Add(size);

                        if (db.SaveChanges() > 0)
                        {
                            var ListRelation = (from s in db.Sizes
                                                where s.UID==size.UID

                                                select
                                               new
                                               {
                                                   UID = s.UID,
                                                   Name = s.Name,
                                                   Code = s.Code,
                                                   IsActive = s.IsActive
                                               });

                            status = JsonConvert.SerializeObject(ListRelation);
                        }
                    }
                    else

                    {
                        status = "exist";
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "SizeController", "AddSize");
            }

            return Content(status);
        }
        public string Save(int[] sel, int UserID)
        {
            string status = "Error";

            try
            {
                if (UserID > 0)
                {
                    List <AssignedPermission> asigned = db.AssignedPermissions.Where(x => x.UserId == UserID).ToList();
                    db.AssignedPermissions.RemoveRange(asigned);

                    List <AssignedPermission> NewPermissions = new List <AssignedPermission>();
                    foreach (int i in sel)
                    {
                        AssignedPermission a = new AssignedPermission();
                        a.CreatedBy    = ActiveUserId;
                        a.CreatedOn    = DateTime.Now;
                        a.PermissionId = i;
                        a.UserId       = UserID;
                        a.UID          = Guid.NewGuid();
                        NewPermissions.Add(a);
                    }
                    db.AssignedPermissions.AddRange(NewPermissions);
                    if (db.SaveChanges() > 0)
                    {
                        status = "Success";
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.ToString(), ex.StackTrace, "UserRightsController", "Save");
            }
            return(status);
        }
        public ReturnMessageModel CreateEditResourceAuthor(ResourceAuthorModel raModel)
        {
            try
            {
                using (PointOfSaleEntities _context = new PointOfSaleEntities())
                {
                    var rtRow = _context.ResourceAuthors.Where(x => x.AuthorId == raModel.AuthorId).FirstOrDefault();
                    if (rtRow == null)
                    {
                        rtRow = new ResourceAuthor();
                    }

                    rtRow.Author      = raModel.Author;
                    rtRow.Nationality = raModel.Nationality;
                    rtRow.Genere      = raModel.Genere;
                    rtRow.IsActive    = raModel.IsActive;

                    if (raModel.AuthorId == 0)
                    {
                        rtRow.CreatedBy   = WebSecurity.CurrentUserId;
                        rtRow.CreatedDate = System.DateTime.Now;
                        _context.ResourceAuthors.Add(rtRow);
                        _context.SaveChanges();
                    }
                    else
                    {
                        rtRow.ModifiedBy   = WebSecurity.CurrentUserId;
                        rtRow.ModifiedDate = System.DateTime.Now;
                        _context.ResourceAuthors.Attach(rtRow);
                        _context.Entry(rtRow).State = EntityState.Modified;
                        _context.SaveChanges();
                    }



                    rModel.Msg     = "Resource Type Saved Successfully";
                    rModel.Success = true;
                    return(rModel);
                }
            }
            catch (Exception ex)
            {
                rModel.Msg     = "Resource Type Saved Failed";
                rModel.Success = false;
                return(rModel);
            }
        }
示例#6
0
        public ActionResult AddCategory(Category category)
        {
            var status = "error";

            try
            {
                if (!Authenticated)
                {
                    status = "SESSION EXPIRED";
                }
                else
                {
                    var objCategory = db.Categories.Where(x => x.Name == category.Name).ToList();
                    if (objCategory.Count < 1)
                    {
                        objCategory = null;
                    }
                    if (objCategory == null)
                    {
                        if (category.IsActive == null)
                        {
                            category.IsActive = false;
                        }
                        category.CreatedOn = DateTime.Now;
                        category.UID       = Guid.NewGuid();
                        category.CreatedBy = ActiveUserId;

                        db.Categories.Add(category);
                        db.SaveChanges();
                        status = JsonConvert.SerializeObject(category);
                    }
                    else
                    {
                        status = "exist";
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "CategoryController", "AddCategory");
            }

            return(Content(status));
        }
示例#7
0
        public ReturnMessageModel CreateEditCountry(CountryModel cModel)
        {
            try
            {
                using (PointOfSaleEntities _context = new PointOfSaleEntities())
                {
                    var rtRow = _context.Countries.Where(x => x.CountryId == cModel.CountryId).FirstOrDefault();
                    if (rtRow == null)
                    {
                        rtRow = new Country();
                    }

                    rtRow.CountryName = cModel.CountryName;
                    rtRow.IsActive    = cModel.IsActive;


                    if (cModel.CountryId == 0)
                    {
                        rtRow.CreatedBy   = WebSecurity.CurrentUserId;
                        rtRow.CreatedDate = System.DateTime.Now;
                        _context.Countries.Add(rtRow);
                        _context.SaveChanges();
                    }
                    else
                    {
                        rtRow.ModifiedBy   = WebSecurity.CurrentUserId;
                        rtRow.ModifiedDate = System.DateTime.Now;
                        _context.Countries.Attach(rtRow);
                        _context.Entry(rtRow).State = EntityState.Modified;
                        _context.SaveChanges();
                    }

                    rModel.Msg     = "Country Saved Successfully";
                    rModel.Success = true;
                    return(rModel);
                }
            }
            catch (Exception ex)
            {
                rModel.Msg     = "Country Saved Failed";
                rModel.Success = false;
                return(rModel);
            }
        }
示例#8
0
        public ReturnMessageModel CreateResourceCopies(ResourceGenerationModel rgModel)
        {
            try
            {
                using (PointOfSaleEntities context = new PointOfSaleEntities())
                {
                    var gRow = new ResourceGeneration();
                    gRow.ResourceId          = rgModel.ResourceId;
                    gRow.Remarks             = rgModel.Remarks;
                    gRow.GenerationCopyCount = rgModel.GenerationCopyCount;
                    gRow.GenerationDate      = CommonService.GetEnglishDate(rgModel.GenerationDateNepali);
                    context.ResourceGenerations.Add(gRow);
                    context.SaveChanges();

                    //for Resoruce copies

                    for (int i = 0; i < rgModel.GenerationCopyCount; i++)
                    {
                        var rRow = new ResourceCopy();
                        rRow.GenerationId       = gRow.GenerationId;
                        rRow.ResourceId         = rgModel.ResourceId;
                        rRow.ResourceCopyCount  = i + 1;
                        rRow.ResourceCopyNumber = rgModel.ResourceName + "-" + rgModel.ResourceId.ToString() + ":" + gRow.GenerationId.ToString() + ":" + i.ToString();
                        rRow.Remarks            = rgModel.Remarks;
                        rRow.IsAvailable        = rgModel.IsAvailable;
                        rRow.PublishedDate      = CommonService.GetEnglishDate(rgModel.GenerationDateNepali);
                        rRow.Edition            = "new edition";
                        context.ResourceCopies.Add(rRow);
                    }
                    context.SaveChanges();
                    rModel.Msg     = "SUceess";
                    rModel.Success = true;
                    return(rModel);
                }
            }
            catch (Exception ex)
            {
                rModel.Msg     = "fail";
                rModel.Success = false;
                return(rModel);
            }
        }
        public void ApplicationExceptionLogging(string ExceptionMessage, string StackTrace, string Controller, string Method)
        {
            try
            {
                ApplicationLogging al = new ApplicationLogging();

                al.Application = "Point Of Sale";
                al.Message     = ExceptionMessage;
                al.StackTrace  = StackTrace;
                al.Controller  = Controller;
                al.Method      = Method;
                al.CreatedOn   = DateTime.Now;
                db.ApplicationLoggings.Add(al);
                db.SaveChanges();
            }
            catch
            { }
        }
示例#10
0
        public ReturnMessageModel CreateResourceIssue(ResourceIssueModel riModel)
        {
            try
            {
                using (PointOfSaleEntities _context = new PointOfSaleEntities())
                {
                    var rtRow = _context.ResourceIssues.Where(x => x.IssueId == riModel.IssueId).FirstOrDefault();
                    if (rtRow == null)
                    {
                        rtRow = new ResourceIssue();
                    }

                    rtRow.ResourceCopyId = riModel.ResourceCopyId;
                    rtRow.IssueDate      = CommonService.GetEnglishDate(riModel.IssueDateNepali);
                    rtRow.ReturnBackDate = CommonService.GetEnglishDate(riModel.ReturnDateNepali);
                    rtRow.ReturnedDate   = CommonService.GetEnglishDate(riModel.ReturnDateNepali);
                    rtRow.Remarks        = riModel.Remarks;

                    rtRow.subscriber = riModel.SubscriberId;



                    _context.ResourceIssues.Add(rtRow);
                    _context.SaveChanges();



                    rModel.Msg     = "Issue Saved Successfully";
                    rModel.Success = true;
                    return(rModel);
                }
            }
            catch (Exception ex)
            {
                rModel.Msg     = "Issue Saved Failed";
                rModel.Success = false;
                return(rModel);
            }
        }
        public ReturnMessageModel CreateResourceGeneration(ResourceGenerationModel rgModel)
        {
            try
            {
                using (PointOfSaleEntities _context = new PointOfSaleEntities())
                {
                    var rtRow = _context.ResourceGenerations.Where(x => x.GenerationId == rgModel.GenerationId).FirstOrDefault();

                    if (rtRow == null)
                    {
                        rtRow = new ResourceGeneration();
                    }
                    rtRow.ResourceId = rgModel.ResourceId;
                    //rtRow.GenerationDate = rgModel.GenerationDate;
                    rtRow.GenerationCopyCount = rgModel.GenerationCopyCount;
                    rtRow.Remarks             = rgModel.Remarks;


                    if (rgModel.GenerationId == 0)
                    {
                        rtRow.GenerationDate = System.DateTime.Now;
                        _context.ResourceGenerations.Add(rtRow);
                        _context.SaveChanges();
                    }
                    else
                    {
                        _context.ResourceGenerations.Attach(rtRow);
                        _context.Entry(rtRow).State = EntityState.Modified;
                        _context.SaveChanges();
                    }


                    var gRow = _context.ResourceCopies.Where(x => x.ResourceCopyId == rgModel.ResourceCopyId).FirstOrDefault();
                    if (gRow == null)
                    {
                        gRow = new ResourceCopy();
                    }

                    for (int i = 1; i < rgModel.GenerationCopyCount; i++)
                    {
                        gRow.ResourceCopyId    = rgModel.ResourceCopyId;
                        gRow.ResourceId        = rgModel.ResourceId;
                        gRow.GenerationId      = rgModel.GenerationId;
                        gRow.ResourceCopyCount = i;
                        //gRow.ResourceCopyNumber = ResourceId.ToString() + rgModel.GenerationId + rgModel.ResourceCopyId;
                    }
                    //rtRow.GenerationId


                    rModel.Msg     = "Resource Type Saved Successfully";
                    rModel.Success = true;
                    return(rModel);
                }
            }
            catch (Exception ex)
            {
                rModel.Msg     = "Resource Type Saved Failed";
                rModel.Success = false;
                return(rModel);
            }
        }
        //pay to customer

        public ActionResult PaymentToCustomer(Guid UID, double totalPay)
        {
            string status = "error";

            try
            {
                var c     = db.Customers.Where(x => x.UID == UID).FirstOrDefault();
                var objCp = new CustomerPayment();



                // Entry in customer Payment

                objCp.UID            = Guid.NewGuid();
                objCp.CustomerId     = c.Id;
                objCp.EntryType      = 5;
                objCp.PaymentMethode = 1;
                objCp.Credit         = Convert.ToDecimal(totalPay);
                objCp.Debit          = 0;
                objCp.EntryDate      = DateTime.Now;
                objCp.CreatedBy      = ActiveUserId;
                objCp.CreatedOn      = DateTime.Now;
                objCp.UpdatedBy      = ActiveUserId;
                objCp.UpdatedOn      = DateTime.Now;
                db.CustomerPayments.Add(objCp);
                db.SaveChanges();

                var objCpl = new CustomerPaymentLog();

                objCpl.UID               = Guid.NewGuid();
                objCpl.CustomerId        = c.Id;
                objCpl.EntryType         = 5;
                objCpl.CustomerPaymentId = objCp.Id;
                objCpl.PaymentMethode    = 1;
                objCpl.CreatedBy         = ActiveUserId;
                objCpl.Credit            = Convert.ToDecimal(totalPay);
                objCpl.Debit             = 0;
                objCpl.CreatedOn         = DateTime.Now;
                objCpl.UpdatedBy         = ActiveUserId;
                objCpl.UpdatedOn         = DateTime.Now;
                db.CustomerPaymentLogs.Add(objCpl);

                db.SaveChanges();


                //return UID and Balance  to js
                var objUpdatedCustomer = db.Customers.Where(cU => cU.UID == UID).Select(s => new
                {
                    UID     = s.UID,
                    CpId    = objCp.Id,
                    Balance = (db.CustomerPayments.Where(x => x.CustomerId == c.Id).Sum(cp => cp.Debit)) - (db.CustomerPayments.Where(x => x.CustomerId == c.Id).Sum(cp => cp.Credit))
                }).FirstOrDefault();

                status = Newtonsoft.Json.JsonConvert.SerializeObject(objUpdatedCustomer);
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "CustomerManagementController", "LoadGridPayments");
            }
            return(Content(status));
        }
        public ActionResult EditColor(Color objdata)
        {
            if (!Authenticated)
            {
                return(RedirectToAction("Login", "Authentication"));
            }
            string status = "error";

            try
            {
                if (!Authenticated)
                {
                    status = "SESSION EXPIRED";
                }
                else
                {
                    var objColor = db.Colors.Where(x => x.Name == objdata.Name && x.UID != objdata.UID).ToList();
                    if (objColor.Count < 1)
                    {
                        objColor = null;
                    }
                    if (objColor == null)
                    {
                        Color obj = db.Colors.FirstOrDefault(x => x.UID == objdata.UID);


                        if (obj.IsAssigned != true)
                        {
                            obj.Code = objdata.Code;
                            obj.Name = objdata.Name;
                            if (objdata.IsActive == null)
                            {
                                objdata.IsActive = false;
                            }
                            obj.IsActive = objdata.IsActive;

                            obj.UpdatedBy = ActiveUserId;
                            obj.UpdatedOn = DateTime.Now;

                            if (db.SaveChanges() > 0)
                            {
                                status = JsonConvert.SerializeObject(obj);
                            }
                        }
                        else
                        {
                            status = "assigned";
                        }
                    }
                    else
                    {
                        status = "exist";
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.ToString(), ex.StackTrace, "ColorManagementController", "EditColor");
            }

            return(Content(status));
        }
        public ActionResult AddItem(Item objitem)
        {
            var status = "error";

            try
            {
                if (!Authenticated)
                {
                    status = "SESSION EXPIRED";
                }
                else if (objitem.SalePrice < objitem.CostPrice)
                {
                    status = "costgreaterthansale";
                }
                else
                {
                    var objExist = db.Items.Where(x => x.Name == objitem.Name && x.CategoryId == objitem.CategoryId && x.SubCategoryId == objitem.SubCategoryId).ToList();
                    if (objExist.Count < 1)
                    {
                        objExist = null;
                    }
                    if (objExist == null)
                    {
                        if (objitem.IsActive == null)
                        {
                            objitem.IsActive = false;
                        }
                        if (objitem.SubCategoryId == 0 || objitem.SubCategoryId == null)
                        {
                            objitem.SubCategoryId = null;
                        }
                        objitem.UID       = Guid.NewGuid();
                        objitem.CreatedBy = ActiveUserId;
                        objitem.CreatedOn = DateTime.Now;
                        db.Items.Add(objitem);
                        if (db.SaveChanges() > 0)
                        {
                            var item = db.GetItemByUID(objitem.UID);
                            status = JsonConvert.SerializeObject(item);
                            //Assigned true to size ,uom and color that use in this item
                            var objSize        = db.Sizes.Where(x => x.Id == objitem.SizeId).SingleOrDefault();
                            var objUom         = db.UnitOfMeasures.Where(x => x.Id == objitem.UomId).SingleOrDefault();
                            var objColor       = db.Colors.Where(x => x.Id == objitem.ColorId).SingleOrDefault();
                            var objCategory    = db.Categories.Where(x => x.Id == objitem.CategoryId).SingleOrDefault();
                            var objSubCategory = db.SubCategories.Where(x => x.Id == objitem.SubCategoryId).SingleOrDefault();
                            objSize.IsAssigned        = true;
                            objUom.IsAssigned         = true;
                            objColor.IsAssigned       = true;
                            objCategory.IsAssigned    = true;
                            objSubCategory.IsAssigned = true;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        status = "exist";
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "ItemManagementController", "AddItem");
            }

            return(Content(status));
        }
示例#15
0
        public ActionResult AddSubCategory(SubCategory subcategory)
        {
            var status = "error";

            try
            {
                if (!Authenticated)
                {
                    status = "SESSION EXPIRED";
                }
                else
                {
                    if (subcategory.CategoryId > 0)
                    {
                        var objSubCategory = db.SubCategories.Where(x => x.Name == subcategory.Name && x.CategoryId == subcategory.CategoryId).ToList();
                        if (objSubCategory.Count < 1)
                        {
                            objSubCategory = null;
                        }
                        if (objSubCategory == null)
                        {
                            if (subcategory.IsActive == null)
                            {
                                subcategory.IsActive = false;
                            }
                            subcategory.CreatedOn = DateTime.Now;
                            subcategory.UID       = Guid.NewGuid();
                            subcategory.CreatedBy = ActiveUserId;

                            db.SubCategories.Add(subcategory);
                            if (db.SaveChanges() > 0)
                            {
                                var item = (from c in db.Categories
                                            join
                                            sc in db.SubCategories
                                            on
                                            c.Id equals sc.CategoryId

                                            where sc.UID == subcategory.UID
                                            select
                                            new
                                {
                                    UID = sc.UID,
                                    Code = sc.Code,
                                    Name = sc.Name,
                                    CategoryName = c.Name,
                                    Status = sc.IsActive
                                });
                                status = JsonConvert.SerializeObject(item);
                            }
                        }
                        else
                        {
                            status = "exist";
                        }
                    }
                    else
                    {
                        status = "categorymissing";
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "SubCategoryController", "AddSubCategory");
            }

            return(Content(status));
        }
        public ActionResult AddUser(User objUser)
        {
            string status = "error";

            //if (Authenticated)
            //{
            try
            {
                User obj = db.Users.Where(x => x.UserName == objUser.UserName).FirstOrDefault();


                if (obj != null)
                {
                    status = "exist";
                }
                else
                {
                    if (objUser.IsActive == null)
                    {
                        objUser.IsActive = false;
                    }

                    objUser.Password = ApplicationSecurity.Encrypt(objUser.Password);


                    objUser.UID       = Guid.NewGuid();
                    objUser.CreatedOn = DateTime.Now;
                    objUser.CreatedBy = ActiveUserId;
                    //objUser.UpdatedOn = DateTime.Now;
                    //objUser.UpdatedBy = ActiveUserId;

                    db.Users.Add(objUser);
                    if (db.SaveChanges() > 0)
                    {
                        var str = (from u in db.Users
                                   join
                                   t in db.UserTypeLookups
                                   on u.UserTypeId equals t.Id
                                   where u.Id == objUser.Id
                                   select
                                   new UserGrid
                        {
                            UID = u.UID,
                            Name = u.Name,
                            UserName = u.UserName,
                            Email = u.Email,
                            ContactNo = u.ContactNo,
                            UserType = t.Name,
                            IsActive = u.IsActive
                        }).ToList <UserGrid>();

                        status = Newtonsoft.Json.JsonConvert.SerializeObject(str);
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.ToString(), ex.StackTrace, "UserManagementController", "AddUser");
            }
            //}
            return(Content(status));
        }
        public ActionResult AddBarcode(AddBarcode objitem)
        {
            var status = "error";

            try
            {
                if (!Authenticated)
                {
                    status = "SESSION EXPIRED";
                }
                else
                {
                    var checkbarcode = db.Barcodes.Where(x => x.Barcode1 == objitem.Barcode).ToList();
                    if (checkbarcode.Count < 1)
                    {
                        checkbarcode = null;
                    }
                    if (checkbarcode == null)
                    {
                        Item objItemss = db.Items.Where(x => x.UID == objitem.UID).SingleOrDefault();
                        if (objItemss != null)
                        {
                            Barcode objBrcode = new Barcode();

                            objBrcode.ItemId     = objItemss.Id;
                            objBrcode.ColorId    = objitem.ColorId;
                            objBrcode.CategoryId = (int)objItemss.CategoryId;
                            //    if (objItemss.SubCategoryId == 0 || objItemss.SubCategoryId == null)
                            //    {
                            //        objBrcode.SubCategoryId = "NULL";
                            //    }

                            //objBrcode.SubCategoryId = (int)objItemss.SubCategoryId;
                            objBrcode.BarcodeType = (int)objitem.BarcodeType;
                            objBrcode.Barcode1    = objitem.Barcode;
                            objBrcode.UID         = Guid.NewGuid();
                            objBrcode.CreatedBy   = ActiveUserId;
                            objBrcode.CreatedOn   = DateTime.Now;
                            objBrcode.UpdatedBy   = SiteUser.Id;
                            objBrcode.UpdatedOn   = DateTime.Now;

                            db.Barcodes.Add(objBrcode);
                            if (db.SaveChanges() > 0)
                            {
                                status = JsonConvert.SerializeObject(db.LoadProductBarcode());
                            }
                        }
                    }
                    else
                    {
                        status = "exist";
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "ItemManagementController", "AddBarcode");
            }

            return(Content(status));
        }
示例#18
0
        public ActionResult EditUnitOfMeasure(UnitOfMeasure objdata)
        {
            string status = "error";

            //if (IsAdminUser)
            //{
            try
            {
                if (!Authenticated)
                {
                    status = "SESSION EXPIRED";
                }
                else
                {
                    var objUom = db.UnitOfMeasures.Where(x => x.Name == objdata.Name).ToList();
                    if (objUom.Count < 1)
                    {
                        objUom = null;
                    }
                    if (objUom == null)
                    {
                        UnitOfMeasure obj = db.UnitOfMeasures.FirstOrDefault(x => x.UID == objdata.UID);
                        if (obj.IsAssigned != true)
                        {
                            obj.Code = objdata.Code;
                            obj.Name = objdata.Name;
                            if (objdata.IsActive == null)
                            {
                                objdata.IsActive = false;
                            }
                            obj.IsActive  = objdata.IsActive;
                            obj.UpdatedBy = ActiveUserId;
                            obj.UpdatedOn = DateTime.Now;
                            if (db.SaveChanges() > 0)
                            {
                                status = JsonConvert.SerializeObject(obj);
                            }
                        }
                        else
                        {
                            status = "assigned";
                        }
                    }
                    else
                    {
                        UnitOfMeasure obj = db.UnitOfMeasures.FirstOrDefault(x => x.UID == objdata.UID);
                        if (objdata.IsActive == null)
                        {
                            objdata.IsActive = false;
                        }
                        obj.IsActive  = objdata.IsActive;
                        obj.UpdatedBy = ActiveUserId;
                        obj.UpdatedOn = DateTime.Now;
                        if (db.SaveChanges() > 0)
                        {
                            status = JsonConvert.SerializeObject(obj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.ToString(), ex.StackTrace, "UnitOfMeasureManagementController", "EditUnitOfMeasure");
            }
            //}
            return(Content(status));
        }
示例#19
0
        public ActionResult AddTransaction(string tNo, string tDate, int ShipToLoc, WarehouseTransfer[] GridItems)
        {
            var status = "error";

            try
            {
                WarehouseTransferMain objWHTM = new WarehouseTransferMain();
                objWHTM.TransactionNo = tNo;
                objWHTM.TransferDate  = DateTime.Parse(tDate);
                objWHTM.LocationId    = ShipToLoc;
                objWHTM.UID           = Guid.NewGuid();
                objWHTM.CreatedBy     = ActiveUserId;
                objWHTM.UpdatedBy     = ActiveUserId;
                objWHTM.CreatedOn     = DateTime.Now;
                objWHTM.UpdatedOn     = DateTime.Now;
                db.WarehouseTransferMains.Add(objWHTM);
                db.SaveChanges();


                WarehouseTransfer objWhT = new WarehouseTransfer();
                for (var i = 0; i < GridItems.Length; i++)
                {
                    var items   = GridItems[i];
                    var objItem = (from itm in db.Items where itm.Id == items.ItemId select itm).SingleOrDefault();
                    var objWh   = (from w in db.Warehouses where w.ItemId == items.ItemId select w).SingleOrDefault();

                    objWhT.ItemId       = items.ItemId;
                    objWhT.WtmId        = objWHTM.Id;
                    objWhT.CategoryId   = objItem.CategoryId;
                    objWhT.UomId        = objItem.UomId;
                    objWhT.Barcode      = objItem.Barcode;
                    objWhT.AvailableQty = objWh.QtyAvailable;
                    objWhT.IssueQty     = items.IssueQty;
                    objWhT.BalanceQty   = (objWhT.AvailableQty) - (items.IssueQty);
                    objWhT.SaleRate     = objWh.SaleRate;
                    objWhT.CostRate     = objWh.CostRate;
                    objWhT.CreatedOn    = DateTime.Now;
                    objWhT.CreatedBy    = ActiveUserId;

                    objWh.QtyAvailable = (objWh.QtyAvailable) - (items.IssueQty);
                    db.WarehouseTransfers.Add(objWhT);

                    //save in selling item table
                    var         alreadyExist = db.SellingItems.Where(x => x.ItemId == items.ItemId).SingleOrDefault();
                    SellingItem objSi        = new SellingItem();
                    if (alreadyExist == null)
                    {
                        objSi.ItemId     = items.ItemId;
                        objSi.Barcode    = objItem.Barcode;
                        objSi.CategoryId = objItem.CategoryId;
                        objSi.UomId      = objItem.UomId;
                        objSi.Quantity   = items.IssueQty;
                        objSi.CostRate   = objWh.CostRate;
                        objSi.SaleRate   = objWh.SaleRate;
                        objSi.CreatedBy  = ActiveUserId;
                        objSi.CreatedOn  = DateTime.Now;
                        db.SellingItems.Add(objSi);
                    }
                    else
                    {
                        alreadyExist.Quantity += items.IssueQty;
                        alreadyExist.CostRate  = objWh.CostRate;
                        alreadyExist.SaleRate  = objWh.SaleRate;
                        alreadyExist.UpdatedBy = ActiveUserId;
                        alreadyExist.UpdatedOn = DateTime.Now;
                    }

                    db.SaveChanges();
                }
                status = "Success";
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "StockTransfer", "AddTransaction");
            }
            return(Content(status));
        }
示例#20
0
        public ActionResult AddVendor(Vendor objVendor)
        {
            string status = "error";

            try
            {
                if (!Authenticated)
                {
                    status = "Session Expired";
                }
                else
                {
                    if (objVendor.IsActive == null)
                    {
                        objVendor.IsActive = false;
                    }

                    objVendor.UID       = Guid.NewGuid();
                    objVendor.CreatedBy = ActiveUserId;
                    objVendor.CreatedOn = DateTime.Now;
                    objVendor.UpdatedBy = ActiveUserId;
                    objVendor.UpdatedOn = DateTime.Now;

                    db.Vendors.Add(objVendor);
                    if (db.SaveChanges() > 0)
                    {
                        // Entry in Vendor Payment

                        var objVp = new VendorPayment();
                        objVp.UID      = Guid.NewGuid();
                        objVp.VendorId = objVendor.Id;
                        if (objVendor.OpeningBalance == 0)
                        {
                            objVp.Debit  = 0;
                            objVp.Credit = 0;
                        }
                        if (objVendor.OpeningBalance > 0)
                        {
                            objVp.Debit  = objVendor.OpeningBalance;
                            objVp.Credit = 0;
                        }
                        if (objVendor.OpeningBalance < 0)
                        {
                            objVp.Credit = -(objVendor.OpeningBalance);
                            objVp.Debit  = 0;
                        }
                        objVp.EntryType      = 1;
                        objVp.PaymentMethode = 1;
                        objVp.EntryDate      = DateTime.Now;
                        objVp.CreatedBy      = ActiveUserId;
                        objVp.CreatedOn      = DateTime.Now;
                        objVp.UpdatedBy      = ActiveUserId;
                        objVp.UpdatedOn      = DateTime.Now;
                        db.VendorPayments.Add(objVp);

                        // Entry in Vendor Payment Logs
                        var objVpl = new VendorPaymentLog();

                        objVpl.UID      = Guid.NewGuid();
                        objVpl.VendorId = objVendor.Id;
                        if (objVendor.OpeningBalance == 0)
                        {
                            objVpl.Debit  = 0;
                            objVpl.Credit = 0;
                        }
                        if (objVendor.OpeningBalance > 0)
                        {
                            objVpl.Debit  = objVendor.OpeningBalance;
                            objVpl.Credit = 0;
                        }
                        if (objVendor.OpeningBalance < 0)
                        {
                            objVpl.Credit = -(objVendor.OpeningBalance);
                            objVpl.Debit  = 0;
                        }
                        objVpl.EntryType      = 1;
                        objVpl.PaymentMethode = 1;
                        objVpl.CreatedBy      = ActiveUserId;
                        objVpl.CreatedOn      = DateTime.Now;
                        objVpl.UpdatedBy      = ActiveUserId;
                        objVpl.UpdatedOn      = DateTime.Now;
                        db.VendorPaymentLogs.Add(objVpl);

                        db.SaveChanges();

                        status = Newtonsoft.Json.JsonConvert.SerializeObject(objVendor);
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "VendorManagementController", "AddVendor");
            }
            return(Content(status));
        }
        public ReturnMessageModel CreateEditConfigChoiceCategory(ConfigChoiceCategoryModel iModel)
        {
            try
            {
                var cccRow = _context.ConfigChoiceCategories.Where(x => x.CategoryId == iModel.CategoryId).FirstOrDefault();
                if (cccRow == null)
                {
                    cccRow = new ConfigChoiceCategory();
                }

                cccRow.Category            = iModel.Category;
                cccRow.CategoryNepali      = iModel.CategoryNepali;
                cccRow.CategoryDescription = iModel.CategoryDescription;
                cccRow.IsActive            = iModel.IsActive;
                if (cccRow.CategoryId == 0)
                {
                    _context.ConfigChoiceCategories.Add(cccRow);
                    _context.SaveChanges();
                }
                else
                {
                    _context.ConfigChoiceCategories.Attach(cccRow);
                    _context.Entry(cccRow).State = EntityState.Modified;
                    _context.SaveChanges();
                }

                rModel.Msg     = "ConfigChoiceCategory Saved Successfully!!";
                rModel.Success = true;
                return(rModel);
            }
            catch (Exception ex)
            {
                rModel.Msg     = "ConfigChoiceCategory Save Failed!!";
                rModel.Success = false;
                return(rModel);
            }
        }