Example #1
0
 public ResponseModel CreateProductPrice(InvProductPrice aObj)
 {
     try
     {
         if (aObj.ProductPriceId == 0)
         {
             aObj.CreatedDate = DateTime.Now;
             _aRepository.Insert(aObj);
             _aRepository.Save();
             return(_aModel.Respons(true, "New ProductPrice Successfully Saved"));
         }
         else
         {
             _aRepository.Update(aObj);
             _aRepository.Save();
             return(_aModel.Respons(true, "ProductPrice Successfully Updated"));
         }
     }
     catch (Exception)
     {
         return(_aModel.Respons(false, "Sorry! Some Error Happned."));
     }
 }
 public ResponseModel CreateCity(InvCityList aObj)
 {
     try
     {
         if (aObj.CityId == 0)
         {
             //aObj.CreatedDate = DateTime.Now;
             _aRepository.Insert(aObj);
             _aRepository.Save();
             return(_aModel.Respons(true, "New City Successfully Saved"));
         }
         else
         {
             _aRepository.Update(aObj);
             _aRepository.Save();
             return(_aModel.Respons(true, "City Successfully Updated"));
         }
     }
     catch (Exception)
     {
         return(_aModel.Respons(false, "Sorry! Some Error Happned."));
     }
 }
Example #3
0
        public ResponseModel A_GlAccountCombo()
        {
            var data = _aGlAccount.SelectAll().Where(gl => gl.TransactionAllowed == true).Select(a => new
            {
                id   = a.A_GlAccountId,
                text = a.Name + "(" + a.Code + ")"
            }).ToList();

            //var aaa = data.ToList();
            return(_aModel.Respons(data));
        }
Example #4
0
        public ResponseModel GetHomeOperations()
        {
            var        homeData = (Home)aHomeSocialManager.GetHomeOperations().Data;
            HomeSocial _data    = new HomeSocial()
            {
                Title         = homeData.Title,
                SubTitle      = homeData.SubTitle,
                HomeImageLink = homeData.HomeImageLink
            };
            List <Social> socialData = (List <Social>)aHomeSocialManager.GetSocalLink().Data;

            _data.SocialList = new List <Social>();
            // _data.SocialList.Add(socialData);
            foreach (Social aSocial in (IEnumerable)socialData)
            {
                _data.SocialList.Add((Social)aSocial);
            }
            return(_aModel.Respons(_data));
        }
Example #5
0
        public ResponseModel SaveBlogs(Blog aObj)
        {
            try
            {
                aObj.LastUpdateOn = DateTime.Now;
                if (aObj.BlogId != 0)
                {
                    _aRepository.Update(aObj);
                }
                else
                {
                    _aRepository.Insert(aObj);
                }

                _aRepository.Save();
                return(_aModel.Respons(true, "Data Successfully Saved"));
            }
            catch (Exception ex)
            {
                return(_aModel.Respons(false, "Sorry! There is some ERROR. " + ex));
            }
        }
Example #6
0
        public ResponseModel ViewBookClosing()
        {
            var bookClosing = _db.A_BookValue.ToString();

            return(_aModel.Respons(bookClosing));
        }
        public ResponseModel OutletPoReturnDetails(OutletPOReturnDetailsViewModel OutletPOReturnData, List <ProductOutletPOReturnVM> productList)
        {
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    DateTime aDate = DateTime.Now;

                    InvOutletPOReturnMaster aOutletPOReturnMaster = new InvOutletPOReturnMaster()
                    {
                        OutletPOReturnMasterId    = OutletPOReturnData.OutletPOReturnMasterId,
                        Original_OutletPOMasterId = OutletPOReturnData.OutletPOMasterId,
                        WarehouseId = OutletPOReturnData.WarehouseId, ///////When Identity will complete then we takeidies from WarehouseId and Outletet Id w
                        OutletId    = OutletPOReturnData.OutletId,

                        //WarehouseId=1,
                        //OutletId =1,
                        Status      = 0,
                        IsActive    = true,
                        IsChanged   = false,
                        IsDeleted   = false,
                        IsEdited    = false,
                        IsReceived  = false,
                        IsReturned  = 1,
                        CreatedDate = aDate,
                    };

                    if (OutletPOReturnData.OutletPOReturnMasterId == 0)
                    {
                        _db.InvOutletPOReturnMasters.Add(aOutletPOReturnMaster);
                        _db.SaveChanges();

                        foreach (var aData in productList)
                        {
                            InvOutletPOReturnDetail aOutletPOReturnDetail = new InvOutletPOReturnDetail()
                            {
                                OutletPOReturnMasterId     = aOutletPOReturnMaster.OutletPOReturnMasterId,
                                OutletPOReturnDetailsId    = aData.OutletPOReturnDetailsId,
                                Original_OutletPODetailsId = aData.OutletPODetailsId,
                                ProductId       = aData.ProductId,
                                ProductQuantity = aData.ProductQuantity,
                                IsActive        = true,
                                IsChanged       = false,
                                IsDeleted       = false,
                                IsEdited        = false,
                                IsReceived      = false,
                                IsReturned      = 1,
                                CreatedDate     = aDate,
                            };
                            _db.InvOutletPOReturnDetails.Add(aOutletPOReturnDetail);
                            _db.SaveChanges();
                        }
                        _db.SaveChanges();
                        transaction.Commit();
                        return(_aModel.Respons(true, "Outlet PO return request Successful."));
                    }

                    else if (OutletPOReturnData.OutletPOReturnMasterId > 0)
                    {
                        _db.InvOutletPOReturnMasters.Attach(aOutletPOReturnMaster);
                        _db.Entry(aOutletPOReturnMaster).State = EntityState.Modified;
                        _db.SaveChanges();

                        var invOutletPOReturnDetails = _db.InvOutletPOReturnDetails.Find(OutletPOReturnData.OutletPOReturnDetailsId);

                        invOutletPOReturnDetails.IsActive     = false;
                        invOutletPOReturnDetails.ModifiedDate = aDate;

                        _db.InvOutletPOReturnDetails.Add(invOutletPOReturnDetails);
                        _db.Entry(invOutletPOReturnDetails).State = EntityState.Modified;
                        _db.SaveChanges();

                        foreach (var aData in productList)
                        {
                            InvOutletPOReturnDetail aOutletPOReturnDetail = new InvOutletPOReturnDetail()
                            {
                                OutletPOReturnMasterId     = aOutletPOReturnMaster.OutletPOReturnMasterId,
                                OutletPOReturnDetailsId    = aData.OutletPOReturnDetailsId,
                                Original_OutletPODetailsId = aData.OutletPODetailsId,
                                ProductId       = aData.ProductId,
                                ProductQuantity = aData.ProductQuantity,
                                IsActive        = true,
                                CreatedDate     = aDate
                            };
                            _db.InvOutletPOReturnDetails.Add(aOutletPOReturnDetail);
                            _db.Entry(aOutletPOReturnDetail).State = EntityState.Modified;
                            _db.SaveChanges();
                        }
                        transaction.Commit();
                        return(_aModel.Respons(true, "Successfully  Outlet PO returned "));
                    }
                    _db.SaveChanges();
                    transaction.Commit();
                    return(_aModel.Respons(true, "Sorry Outlet PO returned failed"));
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    return(_aModel.Respons(true, "Sorry Some Error Happned"));
                }
            }
        }
        public ResponseModel CreateOutletSaleUIDetails(OutletSaleUIDetailsViewModel OutletSaleUIData, List <OutletSaleUIVM> productList)
        {
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    DateTime aDate = DateTime.Now;


                    InvOutletInvoiceMaster aOutletSaleInvoiceMaster = new InvOutletInvoiceMaster()
                    {
                        OutletInvoiceMasterId = OutletSaleUIData.OutletInvoiceMasterId,
                        OutletSaleInvoiceNo   = Convert.ToInt32(_invoiceNo.GetNewInvoiceNo()),
                        //OutletId = OutletSaleUIData.OutletId,
                        OutletId     = 1,
                        CustomerId   = 1, //// Now default value is 1 but after add Identity it will be >> CustomerId = OutletSaleUIData.CustomerId,
                        SalePersonId = 1, /////Now default value is 1 but after add Identity it will be >>SalePersonId = OutletSaleUIData.SalePersonId,


                        TotalItem       = OutletSaleUIData.TotalItem,
                        TotalGrandPrice = OutletSaleUIData.TotalGrandPrice,
                        VAT             = OutletSaleUIData.VAT,
                        PaymentMode     = OutletSaleUIData.PaymentMode,
                        Cash            = OutletSaleUIData.Cash,
                        Credit          = OutletSaleUIData.Credit,
                        Discount        = OutletSaleUIData.Discount,
                        Rounding        = OutletSaleUIData.Rounding,
                        PayableAmount   = OutletSaleUIData.PayableAmount,
                        PaidAmount      = OutletSaleUIData.PaidAmount,
                        DueOrRefund     = OutletSaleUIData.DueOrRefund,

                        //IsFullPaid = OutletSaleUIData.IsFullPaid,
                        IsActive  = true,
                        IsChanged = false,
                        IsDeleted = false,
                        IsEdited  = false,


                        IsReturned  = -1,////////
                        Status      = 2,
                        Note        = "Sold",
                        CreatedDate = DateTime.Now,
                    };
                    aOutletSaleInvoiceMaster.IsFullPaid = OutletSaleUIData.DueOrRefund <= 0;   //////////OR, if (OutletSaleUIData.DueOrRefund <= 0) { aOutletSaleInvoiceMaster.IsFullPaid = true; } else { aOutletSaleInvoiceMaster.IsFullPaid = false; }
                    //aOutletSaleInvoiceMaster.OutletSaleInvoiceNo = aDate.Year +''+ aDate.Month +''+ aDate.Day +''+ aOutletSaleInvoiceMaster.OutletId;
                    // var invoiceId = aDate.Year().toString().substr(2) + "" + (aDate.Month() + 1) + "" + (aDate.Day() + "" + 1);

                    if (OutletSaleUIData.OutletInvoiceMasterId == 0)
                    {
                        if ((OutletSaleUIData.Cash > 0) && (OutletSaleUIData.Credit <= 0) && (OutletSaleUIData.PaidAmount > 0))
                        {
                            aOutletSaleInvoiceMaster.PaymentMode = "Cash";
                        }
                        else if ((OutletSaleUIData.Credit > 0) && (OutletSaleUIData.Cash <= 0) && (OutletSaleUIData.PaidAmount > 0))
                        {
                            aOutletSaleInvoiceMaster.PaymentMode = "Credit";
                        }
                        else if ((OutletSaleUIData.Cash > 0) && (OutletSaleUIData.Credit > 0) && (OutletSaleUIData.PaidAmount > 0))
                        {
                            aOutletSaleInvoiceMaster.PaymentMode = "Cash & Credit";
                        }
                        else
                        {
                            aOutletSaleInvoiceMaster.PaymentMode = "None";
                        }
                        _db.InvOutletInvoiceMasters.Add(aOutletSaleInvoiceMaster);
                        _db.SaveChanges();


                        foreach (var aData in productList)
                        {
                            //break;
                            InvOutletInvoiceDetail aOutletSaleInvoiceDetails = new InvOutletInvoiceDetail()
                            {
                                OutletInvoiceMasterId = aOutletSaleInvoiceMaster.OutletInvoiceMasterId,
                                ProductId             = aData.ProductId,
                                ProductQuantity       = aData.ProductQuantity,
                                Discount = aData.Discount,
                                //DiscountPercent = aData.DiscountPercent,
                                UnitPrice   = aData.UnitPrice,
                                TotalPrice  = aData.TotalPrice,
                                IsActive    = true,
                                IsChanged   = false,
                                IsDeleted   = false,
                                IsEdited    = false,
                                IsReturned  = -1,
                                Note        = "Sold",
                                CreatedDate = DateTime.Now
                            };
                            _db.InvOutletInvoiceDetails.Add(aOutletSaleInvoiceDetails);
                            _db.SaveChanges();

                            InvOutletStock aStock = new InvOutletStock()
                            {
                                ProductId = aData.ProductId,
                                //OutletId = aData.OutletId,
                                OutletId            = aOutletSaleInvoiceMaster.OutletId,
                                IsActive            = true,
                                IsChanged           = false,
                                IsDeleted           = false,
                                IsEdited            = false,
                                IsReturned          = -1,
                                InOut               = 2,
                                Note                = "Sold",
                                OutletStockQuantity = aData.ProductQuantity,
                                CreatedDate         = DateTime.Now
                            };
                            _db.InvOutletStocks.Add(aStock);
                            _db.SaveChanges();
                        }
                        _db.SaveChanges();
                        transaction.Commit();
                        var invoiceData = _db.spSaleInvoice(aOutletSaleInvoiceMaster.OutletSaleInvoiceNo).ToList();
                        //return _aModel.Respons(true, "Sale Info Successfully Saved");
                        return(_aModel.Respons(invoiceData));
                    }

                    else if (OutletSaleUIData.OutletInvoiceMasterId > 0)
                    {
                        _db.InvOutletInvoiceMasters.Attach(aOutletSaleInvoiceMaster);
                        _db.Entry(aOutletSaleInvoiceMaster).State = EntityState.Modified;
                        _db.SaveChanges();

                        var invOutletInvoice = _db.InvOutletInvoiceDetails.Find(OutletSaleUIData.OutletInvoiceDetailsId);

                        invOutletInvoice.IsActive     = false;
                        invOutletInvoice.ModifiedDate = DateTime.Now;

                        _db.InvOutletInvoiceDetails.Attach(invOutletInvoice);
                        _db.Entry(invOutletInvoice).State = EntityState.Modified;
                        _db.SaveChanges();

                        foreach (var aData in productList)
                        {
                            InvOutletInvoiceDetail aOutletSaleInvoiceDetails = new InvOutletInvoiceDetail()
                            {
                                OutletInvoiceMasterId = aOutletSaleInvoiceMaster.OutletInvoiceMasterId,
                                ProductId             = aData.ProductId,
                                ProductQuantity       = aData.ProductQuantity,
                                CreatedDate           = DateTime.Now,
                            };
                            _db.InvOutletInvoiceDetails.Add(aOutletSaleInvoiceDetails);
                            _db.Entry(aOutletSaleInvoiceDetails).State = EntityState.Modified;
                            _db.SaveChanges();
                        }
                        transaction.Commit();
                        return(_aModel.Respons(true, "Successfully Updated  Sale Data"));
                    }
                    _db.SaveChanges();
                    transaction.Commit();
                    return(_aModel.Respons(true, "Sorry Failed to Update  Sale Data"));
                }
                catch (Exception ex)
                {
                    //_db.SaveChanges();
                    transaction.Rollback();
                    return(_aModel.Respons(true, "Sorry Some Error Happned"));
                }
            }
        }
        public ResponseModel PortfolioTypeDownData()
        {
            var data = _aRepository.SelectAll();

            var listB = data.Select(a => new
            {
                id   = a.PortfolioTypeId,
                text = a.Type
            });

            return(_aModel.Respons(listB));
        }
        public ResponseModel CreateStudentDetails(StudentDetails aObj)
        {
            //_aRepository.Insert(aObj);
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    if (aObj.StudentId == 0)
                    {
                        //var status = _aRepository.SelectAll().Where(a => a.StudentCode == aObj.StudentCode);
                        //if (status.Any())
                        //{
                        //    return _aModel.Respons(false, "Student Code Already Exist.");
                        //}

                        DateTime aDate = DateTime.Now;

                        TestStudent aStudent = new TestStudent()
                        {
                            StudentName  = aObj.StudentName,
                            StudentPhone = aObj.StudentPhone
                        };


                        //aObj.CreatedDate = aDate;
                        _db.TestStudents.Add(aStudent);
                        _db.SaveChanges();

                        TestStudentAddress aStudentAddress = new TestStudentAddress()
                        {
                            Address   = aObj.Address,
                            Country   = aObj.Country,
                            StudentId = aStudent.StudentId
                        };
                        // List<TestStudentAddress> aStudentAddress;
                        //foreach (var testStudentAddress in aStudentAddress)
                        //{
                        //    _db.TestStudentAddresses.Add(testStudentAddress);
                        //}
                        //_db.SaveChanges();
                        _db.TestStudentAddresses.Add(aStudentAddress);
                        // throw new Exception("good");

                        TestStudentHistory aStudentHistory = new TestStudentHistory()
                        {
                            HistoryDetials = aObj.HistoryDetials,
                            HistoryTitle   = aObj.HistoryTitle,
                            StudentId      = aStudent.StudentId
                        };
                        _db.TestStudentHistories.Add(aStudentHistory);
                        _db.SaveChanges();


                        transaction.Commit();
                        return(_aModel.Respons(true, "New Student Successfully Saved"));
                    }
                    else
                    {
                        DateTime aDate = DateTime.Now;
                        //aObj.CreatedDate = aDate;
                        //_aRepository.Update(aObj);
                        //_aRepository.Save();
                        return(_aModel.Respons(true, "New Student Successfully Updated"));
                    }
                }
                catch (Exception)
                {
                    transaction.Rollback();
                    return(_aModel.Respons(false, "Sorry! Some Error Error Happned"));
                }
            }
        }
        public ResponseModel CreatSupplierInvestment(SupplierInvestment aObj, string currentUserId)
        {
            try
            {
                if (aObj.SupplierInvestmentId == 0)
                {
                    var data =
                        _db.SupplierInvestments.Where(
                            i => i.TransactionDate == aObj.TransactionDate && i.Amount == aObj.Amount && i.SupplierId == aObj.SupplierId && i.Reason == aObj.Reason);

                    var a = data.ToList();
                    if (a.Count > 0)
                    {
                        throw new Exception("This Value will be Duplicated please check");
                    }

                    //static data add
                    aObj.ProcessStatus = 1;
                    aObj.Particular    = "Supplier Investment";
                    aObj.IsActive      = true;
                    aObj.IsDelete      = false;
                    //
                    aObj.CreatedBy   = currentUserId;
                    aObj.CreatedDate = DateTime.Now;
                    _aRepository.Insert(aObj);
                    _aRepository.Save();
                    return(_aModel.Respons(true, "Data Saved Successfully "));
                }
                else
                {
                    // var data =
                    //_db.SupplierInvestments.Where(
                    //    i => i.TransactionDate.Year == aObj.TransactionDate.Year && i.TransactionDate.Month == aObj.TransactionDate.Month && i.TransactionDate.Day == aObj.TransactionDate.Day && i.Amount == aObj.Amount && i.SupplierId == aObj.SupplierId && i.Reason == aObj.Reason && i.SupplierInvestmentId != aObj.SupplierInvestmentId);

                    var data =
                        _db.SupplierInvestments.Where(
                            i => i.TransactionDate == aObj.TransactionDate && i.Amount == aObj.Amount && i.SupplierId == aObj.SupplierId && i.Reason == aObj.Reason && i.SupplierInvestmentId != aObj.SupplierInvestmentId);

                    var a = data.ToList();
                    if (a.Count > 0)
                    {
                        throw new Exception("This Value will be Duplicated please check");
                    }

                    var aData = _aRepository.SelectedById(aObj.SupplierInvestmentId);
                    aData.A_GlTransactionId = aObj.A_GlTransactionId;

                    aData.Amount          = aObj.Amount;
                    aData.MemberName      = aObj.MemberName;
                    aData.MemberNid       = aObj.MemberNid;
                    aData.Particular      = aObj.Particular;
                    aData.ProcessStatus   = aObj.ProcessStatus;
                    aData.Reason          = aObj.Reason;
                    aData.SupplierId      = aObj.SupplierId;
                    aData.TransactionDate = aObj.TransactionDate;

                    aData.UpdatedBy     = currentUserId;
                    aData.UpdatedDate   = DateTime.Now;
                    aData.ProcessStatus = 1;
                    aData.Particular    = "Supplier Investment";
                    _aRepository.Update(aData);
                    _aRepository.Save();
                    return(_aModel.Respons(true, "Data Updated Successfully "));
                }
            }
            catch (Exception ex)
            {
                return(_aModel.Respons(false, "Sorry! Some Error Happened." + ex.Message));
            }
        }
Example #12
0
        public ResponseModel GetAllWarehousePOReturnData()
        {
            var invWarehousePOReturnMaster = _aRepository.SelectAll();
            var InvWarehousePODetails      = _db.InvWarehousePODetails;

            var data = from pOMast in invWarehousePOReturnMaster
                       join warehouse in _db.InvWarehouses on pOMast.WarehouseId equals warehouse.WarehouseId

                       select new
            {
                pOMast.WarehousePOMasterId,
                warehouse.WarehouseName,
                pOMast.Status,
                pOMast.IsActive,
                ApplyDate       = pOMast.CreatedDate,
                ProductQuantity = InvWarehousePODetails.Where(m => m.WarehousePOMasterId == pOMast.WarehousePOMasterId).Select(m => m.ProductQuantity).Sum(),
            };
            var WarehousePOReturnMasterAndDetail = data.ToList();

            return(_aModel.Respons(WarehousePOReturnMasterAndDetail));
        }
        public ResponseModel SendMessae(Message aObj)
        {
            try
            {
                //   var x = AuditLog.GetAuditLog();
                if (aObj.Name == null)
                {
                    return(_aModel.Respons(false, "Name is required."));
                }
                if (aObj.Subject == null)
                {
                    return(_aModel.Respons(false, "Subject is required."));
                }
                if (aObj.Email == null)
                {
                    return(_aModel.Respons(false, "Email is required."));
                }
                if (aObj.MessageDetails == null)
                {
                    return(_aModel.Respons(false, "Message is required."));
                }
                Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
                Match match = regex.Match(aObj.Email);
                if (!match.Success)
                {
                    return(_aModel.Respons(false, "Please enter valid Email address."));
                }

                aObj.CreateDate = DateTime.Now;
                aObj.IsRead     = false;
                if (aObj.MessageId != 0)
                {
                    _aRepository.Update(aObj);
                }
                else
                {
                    _aRepository.Insert(aObj);
                }

                _aRepository.Save();
                SendEmail(aObj);
                return(_aModel.Respons(true, "Data Successfully Saved"));
            }
            catch (Exception ex)
            {
                IGenericRepository <Audit> _auditRepository = new GenericRepositoryCms <Audit>();
                Audit _audit = new Audit()
                {
                    Message = ex.Message.ToString() + "-" + ex.InnerException,
                    IsAdmin = true
                };
                _auditRepository.Insert(_audit);
                _auditRepository.Save();
                return(_aModel.Respons(false, "Sorry! There is some ERROR. " + ex.Message));
            }
        }
Example #14
0
        public ResponseModel AddAboutDetails(About data)
        {
            try
            {
                data.LastUpdateDate = DateTime.Now;
                if (data.AboutId != 0)
                {
                    _aRepository.Update(data);
                }
                else
                {
                    _aRepository.Insert(data);
                }

                _aRepository.Save();
                return(_aModel.Respons(true, "Data Successfully Saved"));
            }
            catch (Exception ex)
            {
                return(_aModel.Respons(false, "Sorry! There is some ERROR. " + ex));
            }
        }
Example #15
0
        public ResponseModel CreateWarehousePODetails()
        {
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    DateTime aDate = DateTime.Now;
                    //InvWarehousePOMaster aOutletPoMaster = new InvWarehousePOMaster()
                    //{
                    //    WarehousePOMasterId = WarehousePOData.WarehousePOMasterId,
                    //    WarehouseName = WarehousePOData.WarehouseName,
                    //    Status = false,
                    //    CreatedDate = aDate,
                    //};

                    //if (WarehousePOData.WarehousePOMasterId == 0)
                    //{
                    //    _db.InvWarehousePOMasters.Add(aOutletPoMaster);
                    //    _db.SaveChanges();

                    //    foreach (var aData in productList)
                    //    {
                    //        InvWarehousePODetail aOutletPoDetails = new InvWarehousePODetail()
                    //        {
                    //            WarehousePOMasterId = aOutletPoMaster.WarehousePOMasterId,
                    //            ProductId = aData.ProductId,
                    //            ProductQuantity = aData.ProductQuantity,
                    //            CreatedDate = aDate,

                    //        };
                    //        _db.InvWarehousePODetails.Add(aOutletPoDetails);
                    //    }
                    //    _db.SaveChanges();
                    //    transaction.Commit();
                    //    return _aModel.Respons(true, "New WarehousePO Successfully Saved");
                    //}

                    //else if (WarehousePOData.WarehousePOMasterId > 0)
                    //{
                    //    _db.InvWarehousePOMasters.Attach(aOutletPoMaster);
                    //    _db.Entry(aOutletPoMaster).State = EntityState.Modified;
                    //    _db.SaveChanges();

                    //    var invPoDetails = _db.InvWarehousePODetails.Find(WarehousePOData.WarehousePODetailsId);

                    //    invPoDetails.IsActive = false;
                    //    invPoDetails.ModifiedDate = aDate;

                    //    _db.InvWarehousePODetails.Attach(invPoDetails);
                    //    _db.Entry(invPoDetails).State = EntityState.Modified;
                    //    _db.SaveChanges();

                    //    foreach (var aData in productList)
                    //    {
                    //        InvWarehousePODetail aOutletPoDetails = new InvWarehousePODetail()
                    //        {
                    //            WarehousePOMasterId = aOutletPoMaster.WarehousePOMasterId,
                    //            ProductId = aData.ProductId,
                    //            ProductQuantity = aData.ProductQuantity,
                    //            CreatedDate = aDate,
                    //        };
                    //        _db.InvWarehousePODetails.Add(aOutletPoDetails);
                    //        _db.SaveChanges();
                    //    }
                    //    transaction.Commit();
                    //    return _aModel.Respons(true, "Sorry WarehousePO Update Failed");
                    //}

                    _db.SaveChanges();
                    transaction.Commit();
                    return(_aModel.Respons(true, "Sorry WarehousePO Update Failed"));
                }
                catch (Exception)
                {
                    _db.SaveChanges();
                    transaction.Rollback();
                    return(_aModel.Respons(true, "Sorry Some Error Happned"));
                }
            }
        }
        public ResponseModel GetACashReceiveStatemtByDate(DateTime startDate, DateTime endDate)
        {
            var data = _db.spCashReceiveStatement(startDate, endDate);

            return(_aModel.Respons(data));
        }
Example #17
0
        /// <summary>
        /// ///Clock frock
        /// </summary>
        /// <param name="WarehousePOData"></param>
        /// <param name="productList"></param>
        /// <returns></returns>
        public ResponseModel CreateWarehousePODetails(WarehousePODetailsViewModel WarehousePOData, List <ProductWarehousePOVM> productList)
        {
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    DateTime             aDate = DateTime.Now;
                    InvWarehousePOMaster aWarehousePoMaster = new InvWarehousePOMaster()
                    {
                        // WarehouseId = WarehousePOData.WarehouseId,
                        WarehousePOMasterId = WarehousePOData.WarehousePOMasterId,
                        WarehouseId         = 1, //////////In UI there is no Warehouse Id so initialy warehouse id =1 sending to database
                        SupplierId          = WarehousePOData.SupplierId,
                        UniqueId            = WarehousePOData.UniqueId,
                        POReference         = WarehousePOData.POReference,
                        Status      = 0,
                        IsActive    = true,
                        IsDeleted   = false,
                        IsEdited    = false,
                        IsReturned  = false,
                        CreatedDate = aDate,
                    };

                    if (WarehousePOData.WarehousePOMasterId == 0)
                    {
                        _db.InvWarehousePOMasters.Add(aWarehousePoMaster);
                        _db.SaveChanges();

                        foreach (var aData in productList)
                        {
                            InvWarehousePOInvoiceDetail aWarehousePoInvoiceDetails = new InvWarehousePOInvoiceDetail()
                            {
                                WarehousePOInvoiceDetailsId   = aData.WarehousePOInvoiceDetailsId,
                                Original_WarehousePODetailsId = aData.WarehousePODetailsId,
                                ProductId       = aData.ProductId,
                                ProductQuantity = aData.OrderedQuantity,
                                IsActive        = true,
                                IsDeleted       = false,
                                IsEdited        = false,
                                IsReturned      = false,
                                CreatedDate     = aDate,
                            };
                            _db.InvWarehousePOInvoiceDetails.Add(aWarehousePoInvoiceDetails);
                            _db.SaveChanges();
                        }
                        _db.SaveChanges();
                        transaction.Commit();
                        return(_aModel.Respons(true, "Warehouse PO successfully returned"));
                    }
                    _db.SaveChanges();
                    transaction.Commit();
                    return(_aModel.Respons(true, "Sorry Warehouse PO returned Failed"));
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    return(_aModel.Respons(true, "Sorry Some Error Happned"));
                }
            }
        }
        //public ResponseModel CreateProductDetails(ProductDetailsViewModel aObj)
        //{
        //    using (var transaction = _db.Database.BeginTransaction())
        //    {
        //        try
        //        {
        //            DateTime aDate = DateTime.Now;
        //            InvProduct aProduct = new InvProduct()
        //            {
        //                ProductId = aObj.ProductId,
        //                ProductCode = aObj.ProductCode,
        //                ProductName = aObj.ProductName,
        //                ProductMainBarCode = aObj.ProductMainBarCode,
        //                ProductFactoryBarCode = aObj.ProductFactoryBarCode,
        //                ColorId = aObj.ColorId,
        //                ItemId = aObj.ItemId,
        //                SizeId = aObj.SizeId,
        //                UoMId = aObj.UoMId,
        //                MinimumStock = aObj.MinimumStock,
        //                ProductFrontImage = aObj.ProductFrontImage,
        //                ProductBackImage = aObj.ProductBackImage,
        //                CreatedDate = aObj.CreatedDate,
        //                IsActive = aObj.IsActive,

        //            };


        //            _db.InvProducts.Add(aProduct);
        //            _db.SaveChanges();

        //            if (aObj.ProductId == 0)
        //            {
        //                InvProductPrice aProductPrice = new InvProductPrice()
        //                {
        //                    ProductId = aObj.ProductId,
        //                    ProductPriceId = aObj.ProductPriceId,
        //                    CostPrice = aObj.CostPrice,
        //                    WholeSalePrice = aObj.WholeSalePrice,
        //                    RetailPrice = aObj.RetailPrice,
        //                    CreatedDate = aObj.CreatedDate,
        //                    IsActive = true

        //                };
        //                _db.InvProductPrices.Add(aProductPrice);
        //                _db.SaveChanges();
        //                transaction.Commit();
        //                return _aModel.Respons(true, "New Produc Successfully Saevd");
        //            }



        //            else
        //            {

        //                _db.InvProducts.Attach(aProduct);
        //                _db.Entry(aProduct).State=EntityState.Modified;
        //                _db.SaveChanges();


        //                var invProductPrice = _db.InvProductPrices.Find(aObj.ProductPriceId);
        //                if ((invProductPrice.CostPrice != aObj.CostPrice) ||
        //                    (invProductPrice.WholeSalePrice != aObj.WholeSalePrice) ||
        //                    (invProductPrice.RetailPrice != aObj.RetailPrice))
        //                {
        //                    invProductPrice.IsActive = false;
        //                    invProductPrice.ModifiedDate = aDate;
        //                    _db.InvProductPrices.Attach(invProductPrice);
        //                    _db.
        //                    _db.SaveChanges();
        //                }
        //            }



        //            return null;
        //        }
        //        catch (Exception)
        //        {
        //            transaction.Rollback();
        //            return _aModel.Respons(false, "Sorry! Some Error Error Happned");
        //        }
        //    }


        //}



        public ResponseModel CreateProductDetails(ProductDetailsViewModel aObj)
        {
            using (var transaction = _db.Database.BeginTransaction())
            {
                try
                {
                    DateTime   aDate    = DateTime.Now;
                    InvProduct aProduct = new InvProduct()
                    {
                        ProductId             = aObj.ProductId,
                        ProductCode           = aObj.ProductCode,
                        ProductName           = aObj.ProductName,
                        ProductMainBarCode    = aObj.ProductMainBarCode,
                        ProductFactoryBarCode = aObj.ProductFactoryBarCode,
                        ItemId            = aObj.ItemId,
                        SizeId            = aObj.SizeId,
                        ColorId           = aObj.ColorId,
                        UoMId             = aObj.UoMId,
                        MinimumStock      = aObj.MinimumStock,
                        ProductFrontImage = aObj.ProductFrontImage,
                        ProductBackImage  = aObj.ProductBackImage,

                        CreatedDate = aDate,
                        IsActive    = aObj.ProductIsActive,
                    };

                    if ((aObj.ProductId == 0)) //this is new
                    {
                        var statusProductCode =
                            _aRepository.SelectAll().Where((pc => pc.ProductCode == aObj.ProductCode));
                        var statusProductMainBarCode =
                            _aRepository.SelectAll().Where((pc => pc.ProductMainBarCode == aObj.ProductMainBarCode));
                        var statusProductFactoryBarCode =
                            _aRepository.SelectAll()
                            .Where((pc => pc.ProductFactoryBarCode == aObj.ProductFactoryBarCode));


                        if ((aObj.ProductCode == null) || (aObj.ProductMainBarCode == null) || (aObj.ProductFactoryBarCode == null) || (aObj.RetailPrice == null) || (aObj.CostPrice == null) || (aObj.WholeSalePrice == null) || (aObj.ProductCode == null))
                        {
                            return(_aModel.Respons(true, "Plese Fill All the Required Field(s)"));
                        }


                        else if (statusProductCode.Any())
                        {
                            return(_aModel.Respons(true, "Product Code Already Exist."));
                        }

                        else if (statusProductMainBarCode.Any())
                        {
                            return(_aModel.Respons(true, "Product Main Bar Code Already Exist."));
                        }

                        else if (statusProductFactoryBarCode.Any())
                        {
                            return(_aModel.Respons(true, "Product Factory Bar Code Already Exist."));
                        }



                        else if ((aObj.ProductCode != null) && (aObj.ProductMainBarCode != null) && (aObj.ProductFactoryBarCode != null) && (aObj.CostPrice != null) && (aObj.WholeSalePrice != null) &&
                                 (aObj.RetailPrice != null))

                        {
                            _db.InvProducts.Add(aProduct);
                            _db.SaveChanges();

                            InvProductPrice aProductPrice = new InvProductPrice()
                            {
                                ProductPriceId = aObj.ProductPriceId,
                                ProductId      = aProduct.ProductId,
                                CostPrice      = aObj.CostPrice,
                                WholeSalePrice = aObj.WholeSalePrice,
                                RetailPrice    = aObj.RetailPrice,
                                CreatedDate    = aDate,
                                IsActive       = true
                            };



                            _db.InvProductPrices.Add(aProductPrice);
                            _db.SaveChanges();

                            transaction.Commit();
                            return(_aModel.Respons(true, "New Product Successfully Saved"));
                        }

                        else
                        {
                            _db.SaveChanges();
                            transaction.Commit();
                            return(_aModel.Respons(true, "Failed to  Save New Product"));
                        }
                    }

                    else if ((aObj.ProductId > 0))
                    {
                        _db.InvProducts.Attach(aProduct);
                        _db.Entry(aProduct).State = EntityState.Modified;
                        _db.SaveChanges();

                        var invProduct      = _db.InvProducts.Find(aObj.ProductId);
                        var invProductPrice = _db.InvProductPrices.Find(aObj.ProductPriceId);

                        if ((aObj.ProductCode == null) || (aObj.ProductMainBarCode == null) || (aObj.ProductFactoryBarCode == null) || (aObj.RetailPrice == null) || (aObj.CostPrice == null) || (aObj.WholeSalePrice == null) || (aObj.ProductCode == null))
                        {
                            return(_aModel.Respons(true, "Plese Fill All the Required Field(s)"));
                        }


                        else if (((aObj.ProductCode == invProduct.ProductCode) && (aObj.ProductCode != null)) && (aObj.ProductMainBarCode != null) && (aObj.ProductFactoryBarCode != null) && (aObj.ProductCode != null) && (aObj.CostPrice != null) &&
                                 (aObj.WholeSalePrice != null) && (aObj.RetailPrice != null)) // During edit previous saved Product code must be same(not changed).And required fields musnt not null.
                        {
                            //start price checking logic



                            if ((invProductPrice.CostPrice != aObj.CostPrice) || (invProductPrice.WholeSalePrice != aObj.WholeSalePrice) || (invProductPrice.RetailPrice != aObj.RetailPrice))
                            {
                                //inactive previous price
                                invProductPrice.IsActive     = false;
                                invProductPrice.ModifiedDate = aDate;

                                _db.InvProductPrices.Attach(invProductPrice);
                                _db.Entry(invProductPrice).State = EntityState.Modified;
                                _db.SaveChanges();

                                //creaete new price
                                InvProductPrice aProductPrice = new InvProductPrice()
                                {
                                    ProductPriceId = aObj.ProductPriceId,
                                    ProductId      = aObj.ProductId,
                                    CostPrice      = aObj.CostPrice,
                                    WholeSalePrice = aObj.WholeSalePrice,
                                    RetailPrice    = aObj.RetailPrice,
                                    CreatedDate    = aDate,
                                    IsActive       = true
                                };

                                _db.InvProductPrices.Add(aProductPrice);
                                _db.SaveChanges();
                            }

                            transaction.Commit();
                            return(_aModel.Respons(true, "New Product Successfully Updated"));
                        }
                    }



                    else
                    {
                        transaction.Commit();
                        return(_aModel.Respons(true, "Failed to Updated a Product"));
                    }
                } // end of Try section



                catch (Exception e)
                {
                    transaction.Rollback();
                    return(_aModel.Respons(false, "Sorry! Some Error Error Happned"));
                }
            }
        }
Example #19
0
        //public ResponseModel GenarateInvoiceSaleUI(OutletId)
        //{

        //   // return _aModel.Respons(invoceId);
        //}
        public ResponseModel GetAllOutletInvoiceData()
        {
            var invOutletInvoiceMaster = _aRepository.SelectAll();
            var invOutlet = _db.InvOutlets.ToList();
            var invOutletInvoiceDetail = _db.InvOutletInvoiceDetails;

            var data = (from invoiceMast in invOutletInvoiceMaster
                        join outlet in invOutlet on invoiceMast.OutletId equals outlet.OutletId
                        //where invoiceMast.Status < 3
                        select new
            {
                invoiceMast.OutletInvoiceMasterId,
                invoiceMast.OutletSaleInvoiceNo,
                BuyDate = invoiceMast.CreatedDate,
                invoiceMast.CreatedDate,
                invoiceMast.Status,
                invoiceMast.IsActive,
                TotalGrandPrice = GetGrandTotal(invoiceMast.OutletInvoiceMasterId),
                outlet.OutletId,
                outlet.OutletName,
                ProductQuantity = invOutletInvoiceDetail.Where(m => m.OutletInvoiceMasterId == invoiceMast.OutletInvoiceMasterId).Select(m => m.ProductQuantity).Sum(),
            }).ToList();
            var outletinvoiceMasterAndDetail = data.ToList();

            return(_aModel.Respons(outletinvoiceMasterAndDetail));
        }