public ActionResult RetailSale(ViewCreateRetailSaleModel model)
        {
            SuccessErrorModel successErrorModel = new SuccessErrorModel();

            try
            {
                int branchId = Convert.ToInt32(Session["BranchId"]);
                var user     = (ViewUser)Session["user"];
                var filePath = SoldProductXmlFilePath(branchId, user.UserId);
                var products = _iProductManager.GetTempSoldBarcodesFromXmlFile(filePath);
                var retail   = Mapper.Map <ViewCreateRetailSaleModel, RetailSale>(model);
                retail.UserId   = user.UserId;
                retail.BranchId = branchId;
                retail.Products = products.ToList();

                var result = _iOrderManager.SaveSoldProductBarCode(retail);
                if (result)
                {
                    var xmlData = XDocument.Load(filePath);
                    xmlData.Root?.Elements().Remove();
                    xmlData.Save(filePath);
                }
                else
                {
                    successErrorModel.Error = "Invalid";
                }
                return(View());
            }
            catch (Exception exception)
            {
                Log.WriteErrorLog(exception);
                return(PartialView("_ErrorPartial", exception));
            }
        }
        public JsonResult AddRequisitionProductToXmlFile(ViewCreateGeneralRequsitionModel model)
        {
            SuccessErrorModel msgSuccessErrorModel = new SuccessErrorModel();

            try
            {
                var filePath    = GetGeneralRequisitionXmlFilePath();
                var id          = model.RequisitionForId.ToString("D2") + model.ProductId;
                var product     = _iProductManager.GetAll().ToList().Find(n => n.ProductId == model.ProductId);
                var xmlDocument = XDocument.Load(filePath);
                xmlDocument.Element("Products")?.Add(
                    new XElement("Product", new XAttribute("Id", id),
                                 new XElement("ProductId", product.ProductId),
                                 new XElement("ProductName", product.ProductName),
                                 new XElement("Quantity", model.Quantity),
                                 new XElement("RequisitionForId", model.RequisitionForId)
                                 ));
                xmlDocument.Save(filePath);
            }
            catch (Exception exception)
            {
                msgSuccessErrorModel.Message = "<p style='colore:red'>" + exception.Message + "</p>";
            }
            return(Json(msgSuccessErrorModel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public JsonResult RetailSale(ViewCreateRetailSaleModel model)
        {
            SuccessErrorModel successErrorModel = new SuccessErrorModel();

            try
            {
                var retail   = Mapper.Map <ViewCreateRetailSaleModel, RetailSale>(model);
                int branchId = Convert.ToInt32(Session["BranchId"]);
                var user     = (ViewUser)Session["user"];
                retail.UserId   = user.UserId;
                retail.BranchId = branchId;
                var result = _iOrderManager.SaveSoldProductBarCode(retail);
                if (result)
                {
                    ModelState.Clear();
                    successErrorModel.Message = "Save Successfull!";
                }
                else
                {
                    successErrorModel.Error = "Invalid";
                }
                return(Json(successErrorModel));
            }
            catch (Exception exception)
            {
                successErrorModel.Message = "Invalid! ";
                return(Json(successErrorModel));
            }
        }
Exemplo n.º 4
0
        public JsonResult AddMonthlyRequisitionProductToXmlFile(FormCollection collection)
        {
            SuccessErrorModel msgSuccessErrorModel = new SuccessErrorModel();

            try
            {
                int productId   = Convert.ToInt32(collection["ProductId"]);
                var product     = _iProductManager.GetProductByProductId(productId);
                int quantity    = Convert.ToInt32(collection["Quantity"]);
                var filePath    = Server.MapPath("~/Files/" + "Monthly_Requisition_Products.xml");
                var xmlDocument = XDocument.Load(filePath);
                xmlDocument.Element("Products")?.Add(
                    new XElement("Product", new XAttribute("Id", productId),
                                 new XElement("ProductId", product.ProductId),
                                 new XElement("ProductName", product.ProductName),
                                 new XElement("Quantity", quantity),
                                 new XElement("ProductCategory", product.ProductCategory.ProductCategoryName),
                                 new XElement("CategoryId", product.CategoryId)
                                 ));
                xmlDocument.Save(filePath);
            }
            catch (Exception exception)
            {
                msgSuccessErrorModel.Message = "<p style='colore:red'>" + exception.Message + "</p>";
            }
            return(Json(msgSuccessErrorModel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        public JsonResult AddRequisitionProductToXmlFile(FormCollection collection)
        {
            SuccessErrorModel msgSuccessErrorModel = new SuccessErrorModel();

            try
            {
                var filePath = GetBranchWishRequisitionXmlFilePath();

                int productId  = Convert.ToInt32(collection["ProductId"]);
                int toBranchId = Convert.ToInt32(collection["ToBranchId"]);
                var id         = toBranchId.ToString("D2") + productId;
                var product    = _iProductManager.GetAll().ToList().Find(n => n.ProductId == productId);
                int quantity   = Convert.ToInt32(collection["Quantity"]);

                var xmlDocument = XDocument.Load(filePath);
                xmlDocument.Element("Products")?.Add(
                    new XElement("Product", new XAttribute("Id", id),
                                 new XElement("ProductId", product.ProductId),
                                 new XElement("ProductName", product.ProductName),
                                 new XElement("Quantity", quantity),
                                 new XElement("ToBranchId", toBranchId)
                                 ));
                xmlDocument.Save(filePath);
            }
            catch (Exception exception)
            {
                msgSuccessErrorModel.Message = "<p style='colore:red'>" + exception.Message + "</p>";
            }
            return(Json(msgSuccessErrorModel, JsonRequestBehavior.AllowGet));
        }
        public JsonResult TempTransferIssue(CreateTransferIssueViewModel model)
        {
            SuccessErrorModel msgSuccessErrorModel = new SuccessErrorModel();

            try
            {
                List <Product> productList = (List <Product>)Session["factory_transfer_product_list"];
                var            product     = _iProductManager.GetAll().ToList().Find(n => n.ProductId == model.ProductId);
                product.Quantity = model.Quantity;

                if (productList != null)
                {
                    productList.Add(product);
                }
                else
                {
                    productList = new List <Product> {
                        product
                    };
                }

                Session["factory_transfer_product_list"] = productList;
            }
            catch (Exception exception)
            {
                msgSuccessErrorModel.Message = "<p style='colore:red'>" + exception.Message + "</p>";
            }
            return(Json(msgSuccessErrorModel, JsonRequestBehavior.AllowGet));
        }
        public JsonResult ChequeReceiveVoucher(FormCollection collection)
        {
            SuccessErrorModel aModel = new SuccessErrorModel();

            try
            {
                List <Purpose> purposeList   = new List <Purpose>();
                Voucher        voucher       = new Voucher();
                var            amount        = Convert.ToDecimal(collection["Amount"]);
                string         bankCode      = collection["BankCode"];
                string         purposeCode   = collection["PurposeCode"];
                var            creditPurpose = new Purpose
                {
                    PurposeCode   = bankCode,
                    Amounts       = amount,
                    Remarks       = collection["Remarks"],
                    DebitOrCredit = "Dr"
                };
                purposeList.Add(creditPurpose);
                var anUser = (ViewUser)Session["user"];


                var debitPurpose = new Purpose
                {
                    PurposeCode   = purposeCode,
                    Amounts       = amount,
                    Remarks       = collection["Remarks"],
                    DebitOrCredit = "Cr"
                };
                purposeList.Add(debitPurpose);
                //-------------Voucher type  = Cheque receive voucher,transcation type 2 = Bank
                voucher.PurposeList       = purposeList;
                voucher.Remarks           = collection["Remarks"];
                voucher.VoucherType       = 4;
                voucher.VoucherName       = "Cheque Receive Voucher";
                voucher.TransactionTypeId = 2;
                voucher.VoucherDate       = Convert.ToDateTime(collection["Date"]);
                voucher.Amounts           = amount;
                voucher.VoucherByUserId   = anUser.UserId;
                voucher.BranchId          = Convert.ToInt32(Session["BranchId"]);
                voucher.CompanyId         = Convert.ToInt32(Session["CompanyId"]);

                int rowAffected = _iAccountsManager.SaveVoucher(voucher);
                if (rowAffected > 0)
                {
                    aModel.Message = "<p class='text-green'>Saved Cheque Receive voucher successfully!</p>";
                }
                else
                {
                    aModel.Message = "<p class='text-danger'>Failed to save Cheque receive voucher info !</p>";
                }
            }
            catch (Exception exception)
            {
                var ex = exception.Message;
                aModel.Message = "<p style='color:red'>" + ex + "</p>";
                Log.WriteErrorLog(exception);
            }
            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        public void SaveScannedBarcodeToTextFile(string barcode, long salesReturnId)
        {
            SuccessErrorModel model = new SuccessErrorModel();
            ViewWriteLogModel log   = new ViewWriteLogModel();

            try
            {
                var filePath = GetSalesReturnProductFilePath(salesReturnId);

                var scannedBarCode      = barcode.ToUpper();
                int productId           = Convert.ToInt32(scannedBarCode.Substring(2, 3));
                var receivesProductList = _iProductReturnManager.GetReturnDetailsBySalesReturnId(salesReturnId).ToList();

                //------------read Scanned barcode form text file---------
                var barcodeList = _iProductManager.GetScannedProductListFromTextFile(filePath).ToList();

                //------------Load receiveable product---------
                var isvalid = Validator.ValidateProductBarCode(scannedBarCode);

                int requistionQtyByProductId = receivesProductList.ToList().FindAll(n => n.ProductId == productId).Sum(n => n.Quantity);

                int scannedQtyByProductId = barcodeList
                                            .FindAll(n => Convert.ToInt32(n.ProductCode.Substring(2, 3)) == productId).Count;

                bool isScannComplete = requistionQtyByProductId.Equals(scannedQtyByProductId);

                if (isScannComplete)
                {
                    model.Message = "<p style='color:green'> Scanned Complete</p>";
                    // return Json(model, JsonRequestBehavior.AllowGet);
                }
                else if (!isvalid)
                {
                    model.Message = "<p style='color:red'> Invalid Barcode</p>";
                    //return Json(model, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    _iProductManager.AddProductToTextFile(scannedBarCode, filePath);
                }
            }
            catch (FormatException exception)
            {
                log.Heading    = exception.GetType().ToString();
                log.LogMessage = exception.StackTrace;
                Log.WriteErrorLog(log);
                model.Message = "<p style='color:red'>" + exception.GetType() + "</p>";
                //return Json(model, JsonRequestBehavior.AllowGet);
            }
            catch (Exception exception)
            {
                log.Heading    = exception.GetType().ToString();
                log.LogMessage = exception.StackTrace;
                Log.WriteErrorLog(log);
                model.Message = "<p style='color:red'>" + exception.Message + "</p>";
                // return Json(model, JsonRequestBehavior.AllowGet);
            }
            // return Json(model, JsonRequestBehavior.AllowGet);
        }
        public JsonResult ForwardServiceBatteryToDeistributionPoint(long receiveId)
        {
            SuccessErrorModel model = new SuccessErrorModel();
            bool result             = _iServiceManager.ForwardServiceBatteryToDeistributionPoint(receiveId);

            model.Message = result ? "<p class='text-green'>Successfully! Forward to Distribution Point</p>" : "<p class='text-danger'>Failed to Forward to Distribution Point</p>";
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        public void SaveTransferReceivableScannedBarcodeToTextFile(string barcode, long transferId)
        {
            SuccessErrorModel model = new SuccessErrorModel();

            try
            {
                int    branchId       = Convert.ToInt32(Session["BranchId"]);
                int    companyId      = Convert.ToInt32(Session["CompanyId"]);
                var    scannedBarCode = barcode.ToUpper();
                int    productId      = Convert.ToInt32(scannedBarCode.Substring(2, 3));
                string fileName       = "Transfer_Received_Product_For_" + transferId + branchId;
                var    filePath       = Server.MapPath("~/Areas/Sales/Files/Requisitions/" + fileName);

                //------------read Scanned barcode form text file---------
                var barcodeList = _iProductManager.GetScannedProductListFromTextFile(filePath).ToList();
                //------------Load receiveable product---------
                var receivesProductList     = _iInventoryManager.GetAllTransferedListByBranchAndCompanyId(branchId, companyId).ToList().FindAll(n => n.TransferId == transferId);
                var receivesProductCodeList = _iInventoryManager.GetTransferReceiveableBarcodeList(transferId).ToList();
                var isvalid = Validator.ValidateProductBarCode(scannedBarCode);

                int requistionQtyByProductId = receivesProductList.ToList().FindAll(n => n.ProductId == productId).Sum(n => n.Quantity);

                int scannedQtyByProductId = barcodeList
                                            .FindAll(n => Convert.ToInt32(n.ProductCode.Substring(2, 3)) == productId).Count;

                bool isScannComplete = requistionQtyByProductId.Equals(scannedQtyByProductId);

                if (isScannComplete)
                {
                    model.Message = "<p style='color:green'> Scanned Complete</p>";
                    // return Json(model, JsonRequestBehavior.AllowGet);
                }
                else if (!isvalid)
                {
                    model.Message = "<p style='color:red'> Invalid Barcode</p>";
                    //return Json(model, JsonRequestBehavior.AllowGet);
                }

                else if (receivesProductCodeList.Contains(scannedBarCode))
                {
                    _iProductManager.AddProductToTextFile(scannedBarCode, filePath);
                }
            }
            catch (FormatException exception)
            {
                Log.WriteErrorLog(exception);
                model.Message = "<p style='color:red'>" + exception.GetType() + "</p>";
                //return Json(model, JsonRequestBehavior.AllowGet);
            }
            catch (Exception exception)
            {
                Log.WriteErrorLog(exception);
                model.Message = "<p style='color:red'>" + exception.Message + "</p>";
                // return Json(model, JsonRequestBehavior.AllowGet);
            }
            // return Json(model, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 11
0
        public JsonResult HideOrder(int id)
        {
            var user = ((ViewUser)Session["user"]);
            SuccessErrorModel aModel = new SuccessErrorModel();
            var result = _iOrderManager.HideOrderByInvoiceId(id, user.UserId);

            aModel.Message = result ? "Hide order Successfully!" : "Failed to Hide order";
            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }
        public void SaveGeneralReturnScannedBarcodeToTextFile(string barcode, long salesReturnId)
        {
            SuccessErrorModel model = new SuccessErrorModel();

            try
            {
                int branchId          = Convert.ToInt32(Session["BranchId"]);
                var scannedBarCode    = barcode.ToUpper();
                int productId         = Convert.ToInt32(scannedBarCode.Substring(2, 3));
                var returndetailsbyId = _iProductReturnManager.GetGeneralReqReturnDetailsById(salesReturnId).FirstOrDefault();
                var filePath          = GetReceiveProductFilePath(salesReturnId, branchId);

                //------------read Scanned barcode form text file---------
                var barcodeList = _iProductManager.GetScannedProductListFromTextFile(filePath).ToList();
                //------------Load receiveable product---------
                var receivesProductList     = _iProductReturnManager.GetGeneralReqReturnDetailsById(salesReturnId).ToList();
                List <ViewProduct> products = _iDeliveryManager.GetDeliveredProductListByTransactionRef(returndetailsbyId?.DeliveryRef).ToList();
                var receivesProductCodeList = products.Select(n => n.ProductBarCode).ToList();
                var isvalid = Validator.ValidateProductBarCode(scannedBarCode);

                int requistionQtyByProductId = receivesProductList.ToList().FindAll(n => n.ProductId == productId).Sum(n => n.Quantity);

                int scannedQtyByProductId = barcodeList
                                            .FindAll(n => Convert.ToInt32(n.ProductCode.Substring(2, 3)) == productId).Count;

                bool isScannComplete = requistionQtyByProductId.Equals(scannedQtyByProductId);

                if (isScannComplete)
                {
                    model.Message = "<p style='color:green'> Scanned Complete</p>";
                    // return Json(model, JsonRequestBehavior.AllowGet);
                }
                else if (!isvalid)
                {
                    model.Message = "<p style='color:red'> Invalid Barcode</p>";
                    //return Json(model, JsonRequestBehavior.AllowGet);
                }

                else if (receivesProductCodeList.Contains(scannedBarCode))
                {
                    _iProductManager.AddProductToTextFile(scannedBarCode, filePath);
                }
            }
            catch (FormatException exception)
            {
                Log.WriteErrorLog(exception);
                model.Message = "<p style='color:red'>" + exception.GetType() + "</p>";
                //return Json(model, JsonRequestBehavior.AllowGet);
            }
            catch (Exception exception)
            {
                Log.WriteErrorLog(exception);
                model.Message = "<p style='color:red'>" + exception.Message + "</p>";
                // return Json(model, JsonRequestBehavior.AllowGet);
            }
            // return Json(model, JsonRequestBehavior.AllowGet);
        }
        public JsonResult SaveDebitVoucher(FormCollection collection)
        {
            SuccessErrorModel aModel = new SuccessErrorModel();

            try
            {
                List <Purpose> purposeList       = GetDebitPurposesFromXmlFile().ToList();
                Voucher        voucher           = new Voucher();
                int            transacitonTypeId = Convert.ToInt32(collection["TransactionTypeId"]);
                var            amount            = purposeList.Sum(n => n.Amounts);
                var            date       = Convert.ToDateTime(collection["Date"]);
                string         accontCode = collection["AccountCode"];
                Purpose        aPurpose   = new Purpose
                {
                    PurposeCode   = accontCode,
                    Amounts       = amount,
                    DebitOrCredit = "Cr"
                };

                var anUser = (ViewUser)Session["user"];

                purposeList.Add(aPurpose);

                //-------------Voucher type=2 Debit voucher----------
                voucher.PurposeList       = purposeList;
                voucher.Remarks           = collection["Remarks"];
                voucher.VoucherType       = 2;
                voucher.VoucherName       = "Debit Voucher";
                voucher.VoucherDate       = date;
                voucher.Amounts           = amount;
                voucher.VoucherByUserId   = anUser.UserId;
                voucher.BranchId          = Convert.ToInt32(Session["BranchId"]);
                voucher.CompanyId         = Convert.ToInt32(Session["CompanyId"]);
                voucher.TransactionTypeId = transacitonTypeId;
                voucher.AccountCode       = accontCode;

                int rowAffected = _iAccountsManager.SaveVoucher(voucher);
                if (rowAffected > 0)
                {
                    RemoveAllFromTempXmlFile(GetTempDebitVoucherXmlFilePath());
                    aModel.Message = "<p class='text-green'>Saved Debit voucher successfully!</p>";
                }
                else
                {
                    aModel.Message = "<p class='text-danger'>Failed to save Debit voucher info !</p>";
                }
            }
            catch (Exception exception)
            {
                var ex = exception.Message;
                aModel.Message = "<p style='color:red'>" + ex + "</p>";
                Log.WriteErrorLog(exception);
            }
            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }
        //-----------------Delete single product from xml file------------------------
        public JsonResult DeleteProductFromTempReturn(string returnId)
        {
            SuccessErrorModel model = new SuccessErrorModel();
            var filePath            = GetTempReturnProductsXmlFilePath();
            var xmlData             = XDocument.Load(filePath);

            xmlData.Root?.Elements().Where(n => n.Attribute("Id")?.Value == returnId).Remove();
            xmlData.Save(filePath);
            model.Message = "<p style='color:red;'>Product Removed From lsit!</p>";
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 15
0
        public JsonResult UpdateMonthlyRequsiton(int productId)
        {
            SuccessErrorModel model = new SuccessErrorModel();
            var filePath            = Server.MapPath("~/Files/" + "Monthly_Requisition_Products.xml");
            var xmlData             = XDocument.Load(filePath);

            xmlData.Root?.Elements().Where(n => n.Attribute("Id")?.Value == productId.ToString()).Remove();
            xmlData.Save(filePath);
            model.Message = "<p style='color:red'>Deleted..!</p>";
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        public JsonResult DeleteProductFromTempRequisition(string tempRequisitionId)
        {
            SuccessErrorModel model = new SuccessErrorModel();
            var filePath            = Server.MapPath("~/Files/" + "Create_Trip_File.xml");
            var xmlData             = XDocument.Load(filePath);

            xmlData.Root?.Elements().Where(n => n.Attribute("Id")?.Value == tempRequisitionId).Remove();
            xmlData.Save(filePath);
            model.Message = "<p style='color:red;'>Product Removed From lsit!</p>";
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
        public JsonResult ApproveCashAmount(FormCollection collection)
        {
            SuccessErrorModel aModel = new SuccessErrorModel();

            try
            {
                var      anUser        = (ViewUser)Session["user"];
                int      detailsId     = Convert.ToInt32(collection["ChequeDetailsId"]);
                var      chequeDetails = _iAccountsManager.GetReceivableChequeByDetailsId(detailsId);
                Client   aClient       = _iClientManager.GetById(chequeDetails.ClientId);
                DateTime date          = DateTime.Now;
                //Demo  bankCode = "3308011";
                string bankCode = "3105011";

                int        branchId    = Convert.ToInt32(Session["BranchId"]);
                int        companyId   = Convert.ToInt32(Session["CompanyId"]);
                Receivable aReceivable = new Receivable
                {
                    TransactionRef       = chequeDetails.ReceivableRef,
                    SubSubSubAccountCode = bankCode,
                    ReceivableDateTime   = date,
                    BranchId             = branchId,
                    CompanyId            = companyId,
                    Paymode = 'C',
                    UserId  = anUser.UserId,
                    Remarks = "Active receivable by " + anUser.UserId
                };
                bool result = _iAccountsManager.ActiveReceivableCheque(chequeDetails, aReceivable, aClient);
                //if (result)
                //{
                //    //---------Send Mail ----------------
                //    var body = $"Dear {aClient.ClientName}, your receivalbe amount is receive by NBL. thanks and regards Accounts Departments NBL.";
                //    var subject = $"Receiable Confirm at {DateTime.Now}";
                //    var message = new MailMessage();
                //    message.To.Add(new MailAddress(aClient.Email));  // replace with valid value
                //    message.Subject = subject;
                //    message.Body = string.Format(body);
                //    message.IsBodyHtml = true;
                //    using (var smtp = new SmtpClient())
                //    {
                //        smtp.Send(message);
                //    }
                //    //------------End Send Mail-------------
                //}
                aModel.Message = result ? "<p class='text-green'> Cash Amount Approved Successfully!</p>" : "<p class='text-danger'> Failed to  Approve Cash Amount! </p>";
            }
            catch (Exception exception)
            {
                string message = exception.Message;
                aModel.Message = " <p style='color:red'>" + message + "</p>";
                Log.WriteErrorLog(exception);
            }
            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }
        public JsonResult AddReturnProductToXmalFile(FormCollection collection)
        {
            SuccessErrorModel model = new SuccessErrorModel();

            try
            {
                int _count         = 0;
                var collectionKeys = collection.AllKeys.ToList();
                foreach (string key in collectionKeys)
                {
                    if (collection[key] != "")
                    {
                        var first       = key.IndexOf("_", StringComparison.Ordinal) + 1;
                        var last        = key.LastIndexOf("_", StringComparison.Ordinal) + 1;
                        var quantity    = Convert.ToInt32(collection[key]);
                        var productId   = Convert.ToInt32(key.Substring(first, 3));
                        var product     = _iProductManager.GetProductByProductId(productId);
                        var deliveryRef = key.Substring(0, first - 1);
                        var deliveryId  = key.Substring(last, key.Length - last);
                        //var deliveredOrder = _iDeliveryManager.GetOrderByDeliveryId(Convert.ToInt32(deliveryId));
                        //var requisition = _iProductManager.GetRequsitions().ToList().Find(n => n.RequisitionId == requisitionId);
                        var filePath    = GetTempReturnProductsXmlFilePath();
                        var xmlDocument = XDocument.Load(filePath);
                        if (quantity > 0)
                        {
                            xmlDocument.Element("Products")?.Add(
                                new XElement("Product", new XAttribute("Id", Guid.NewGuid()),
                                             new XElement("DeliveryId", deliveryId),
                                             new XElement("DeliveryRef", deliveryRef),
                                             new XElement("ProuctId", productId),
                                             new XElement("Quantity", quantity),
                                             new XElement("ProductName", product.ProductName)
                                             //new XElement("DeliveryDate", deliveredOrder.DeliveryDate)
                                             ));
                            xmlDocument.Save(filePath);
                            _count++;
                        }
                    }
                }
                if (_count > 0)
                {
                    model.Message = "<p style='color:green'>Added Successfully</p>";
                }

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Log.WriteErrorLog(e);

                model.Message = "<p style='color:red'> Failed to add" + e.Message + "</p>";
                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 19
0
        public JsonResult Confirm(FormCollection collection)
        {
            SuccessErrorModel aModel = new SuccessErrorModel();
            var companyId            = Convert.ToInt32(Session["CompanyId"]);
            var branchId             = Convert.ToInt32(Session["BranchId"]);

            try
            {
                var            user          = (ViewUser)Session["user"];
                var            filePath      = GetTempSalesOrderXmlFilePath();
                int            clientId      = Convert.ToInt32(collection["ClientId"]);
                int            orderByUserId = user.UserId;
                decimal        amount        = Convert.ToDecimal(collection["Total"]);
                DateTime       orderDate     = Convert.ToDateTime(collection["OrderDate"]);
                List <Product> productList   = GetTempOrderedProducts(filePath).ToList();
                var            vat           = productList.Sum(n => n.Vat * n.Quantity);
                var            order         = new Order
                {
                    BranchId        = branchId,
                    ClientId        = clientId,
                    UserId          = orderByUserId,
                    OrderDate       = orderDate,
                    CompanyId       = companyId,
                    Discount        = productList.Sum(n => n.Quantity * n.DiscountAmount),
                    Products        = productList,
                    SpecialDiscount = Convert.ToDecimal(collection["SD"]),
                    Vat             = vat
                };
                order.Amounts = amount + order.Discount;
                var result = _iOrderManager.Save(order);
                if (result > 0)
                {
                    Session["Orders"] = null;
                    RemoveAll();
                    aModel.Message = "<p class='text-green'>Order Submitted Successfully!!</p>";
                }

                else
                {
                    aModel.Message = "<p class='text-danger'>Failed to Submit!!</p>";
                }
            }
            catch (Exception e)
            {
                if (e.InnerException != null)
                {
                    aModel.Message = "<p style='color:red'>" + e.InnerException.Message + "</p>";
                }
            }

            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 20
0
        public JsonResult SaveCreditVoucher(FormCollection collection)
        {
            SuccessErrorModel aModel = new SuccessErrorModel();

            try
            {
                List <Purpose> purposeList       = (List <Purpose>)Session["PurposeList"];
                Voucher        voucher           = new Voucher();
                var            transacitonTypeId = Convert.ToInt32(collection["TransactionTypeId"]);
                var            amount            = purposeList.Sum(n => n.Amounts);
                string         accontCode        = collection["AccountCode"];
                var            aPurpose          = new Purpose
                {
                    PurposeCode   = accontCode,
                    Amounts       = amount,
                    DebitOrCredit = "Cr"
                };

                var anUser = (ViewUser)Session["user"];
                purposeList.Add(aPurpose);
                voucher.PurposeList       = purposeList;
                voucher.Remarks           = collection["Remarks"];
                voucher.VoucherType       = 1;
                voucher.VoucherName       = "Credit Voucher";
                voucher.VoucherDate       = Convert.ToDateTime(collection["Date"]);
                voucher.Amounts           = amount;
                voucher.VoucherByUserId   = anUser.UserId;
                voucher.BranchId          = Convert.ToInt32(Session["BranchId"]);
                voucher.CompanyId         = Convert.ToInt32(Session["CompanyId"]);
                voucher.TransactionTypeId = transacitonTypeId;
                voucher.AccountCode       = accontCode;
                int rowAffected = _iAccountsManager.SaveVoucher(voucher);
                if (rowAffected > 0)
                {
                    Session["PurposeList"] = null;
                    aModel.Message         = "<p class='text-green'>Saved credit voucher successfully!</p>";
                }
                else
                {
                    aModel.Message = "<p class='text-danger'>Failed to save credit voucher info !</p>";
                }
            }
            catch (Exception exception)
            {
                var ex = exception?.Message;
                aModel.Message = "<p style='color:red'>" + ex + "</p>";
            }
            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }
        public JsonResult CancelDiscount(int id)
        {
            SuccessErrorModel aModel = new SuccessErrorModel();
            bool result = _iAccountsManager.CancelDiscount(id);

            if (result)
            {
                aModel.Message = "Product Discount Amount canclled Successfully!";
            }
            else
            {
                aModel.Message = "Failed to Cancel Product Discount Amount";
            }
            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }
        public void BlockUser(int userId)
        {
            SuccessErrorModel model = new SuccessErrorModel();
            var  anUser             = (ViewUser)Session["user"];
            bool result             = _userManager.BlockUser(userId, anUser);

            if (result)
            {
                model.Message = "User Blocked Successfully!!";
            }
            else
            {
                model.Message = "User Blocked Falied!!";
            }
        }
Exemplo n.º 23
0
        public JsonResult UpdateCreditLimitConsideationStatus(int id, int status)
        {
            SuccessErrorModel aModel = new SuccessErrorModel();
            bool result = _iClientManager.UpdateCreditLimitConsideationStatus(id, status);

            if (result)
            {
                aModel.Message = "Set CreditLimit Consideration updated Successfully!";
            }
            else
            {
                aModel.Message = "Failed to update CreditLimit Consideration";
            }
            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 24
0
        public JsonResult UpdateProductActivationStatus(int id, string status)
        {
            SuccessErrorModel aModel = new SuccessErrorModel();
            bool result = _iProductManager.UpdateProductActivationStatus(id, status);

            if (result)
            {
                aModel.Message = "Product Activation Status updated Successfully!";
            }
            else
            {
                aModel.Message = "Failed to Update Product Activation Status";
            }
            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }
        public void AddProductToTempFile(string barcode)
        {
            SuccessErrorModel successErrorModel = new SuccessErrorModel();

            try
            {
                var    user           = (ViewUser)Session["user"];
                string fileName       = "Production_In_" + user.UserId + "_" + DateTime.Now.ToString("ddMMMyyyy");
                string filePath       = Server.MapPath("~/Files/" + fileName);
                var    scannedBarcode = barcode.ToUpper();
                bool   isValid        = Validator.ValidateProductBarCode(scannedBarcode);
                if (isValid)
                {
                    bool isExists = _iInventoryManager.IsThisProductAlreadyInFactoryInventory(scannedBarcode);

                    //------------If this barcode dose not exits...............
                    if (!isExists)
                    {
                        var result = _iProductManager.AddProductToTextFile(scannedBarcode, filePath);
                        if (!result.Contains("Added"))
                        {
                            successErrorModel.Message = result;
                        }
                    }
                    else
                    {
                        successErrorModel.Message = "<p style='color:red'>This Product already exists!!</p>";
                        // return Json(successErrorModel, JsonRequestBehavior.AllowGet);
                    }
                }
                else
                {
                    successErrorModel.Message = "<p style='color:red'>Invalid Barcode..</p>";
                    //return Json(successErrorModel, JsonRequestBehavior.AllowGet);
                }
            }
            catch (FormatException exception)
            {
                successErrorModel.Message = "<p style='color:red'>" + exception.GetType() + "</p>";
                // return Json(successErrorModel, JsonRequestBehavior.AllowGet);
            }
            catch (Exception exception)
            {
                successErrorModel.Message = "<p style='color:red'>" + exception.Message + "</p>";
                // return Json(successErrorModel, JsonRequestBehavior.AllowGet);
            }
            //return Json(successErrorModel, JsonRequestBehavior.AllowGet);
        }
        public JsonResult AddRequistionToTripXmlFile(FormCollection collection)
        {
            SuccessErrorModel model = new SuccessErrorModel();

            try
            {
                int requisitionId  = Convert.ToInt32(collection["RIdNo"]);
                var collectionKeys = collection.AllKeys.ToList().FindAll(n => n.StartsWith("Qty_Of_"));
                foreach (string key in collectionKeys)
                {
                    if (collection[key] != "")
                    {
                        var start          = key.LastIndexOf("_", StringComparison.Ordinal) + 1;
                        var productId      = Convert.ToInt32(key.Substring(10, 3));
                        var product        = _iProductManager.GetProductByProductId(productId);
                        var branchId       = Convert.ToInt32(key.Substring(7, 2));
                        var requisitionQty = key.Substring(start);
                        var deliveryQty    = Convert.ToInt32(collection[key]);
                        var requisition    = _iProductManager.GetRequsitions().ToList().Find(n => n.RequisitionId == requisitionId);
                        var filePath       = Server.MapPath("~/Files/" + "Create_Trip_File.xml");
                        var xmlDocument    = XDocument.Load(filePath);
                        xmlDocument.Element("Requisitions")?.Add(
                            new XElement("Requisition", new XAttribute("Id", Guid.NewGuid()),
                                         new XElement("RequisitionId", requisitionId),
                                         new XElement("RequisitionRef", requisition.RequisitionRef),
                                         new XElement("ProuctId", productId),
                                         new XElement("RequisitionQty", requisitionQty),
                                         new XElement("DeliveryQuantity", deliveryQty),
                                         new XElement("ToBranchId", branchId),
                                         new XElement("ProductName", product.ProductName)
                                         ));
                        xmlDocument.Save(filePath);
                        _count++;
                    }
                }
                if (_count > 0)
                {
                    model.Message = "<p style='color:green'>Added Successfully</p>";
                }

                return(Json(model, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                model.Message = "<p style='color:red'> Failed to add requisition ref to List" + e.Message + "</p>";
                return(Json(model, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 27
0
        public JsonResult AddVerificationNotes(long rejectionId, string notes, int passfailedStatus)
        {
            var user = (ViewUser)Session["user"];
            var verificationModel = new ProductVerificationModel
            {
                Notes = notes,
                QcPassorFailedStatus = passfailedStatus,
                RejectionId          = rejectionId,
                VerifiedByUserId     = user.UserId
            };
            SuccessErrorModel model = new SuccessErrorModel();
            bool result             = _iProductionQcManager.AddVerificationNotesToRejectedProduct(verificationModel);

            model.Message = result ? "Added Successfully" : "Failed to Add qc notes";
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 28
0
        public JsonResult AddVerificationNotes(long returnRcvDetailsId, string notes)
        {
            var user = (ViewUser)Session["user"];
            SuccessErrorModel model = new SuccessErrorModel();
            bool result             = _iProductReturnManager.AddVerificationNoteToReturnsProduct(returnRcvDetailsId, notes, user.UserId);

            if (result)
            {
                model.Message = "Added Successfully";
            }
            else
            {
                model.Message = "Failed to save";
            }
            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 29
0
        public ActionResult ApproveClient(FormCollection collection)
        {
            SuccessErrorModel aModel = new SuccessErrorModel();

            try
            {
                var  anUser   = (ViewUser)Session["user"];
                int  clientId = Convert.ToInt32(collection["ClientId"]);
                var  aClient  = _iClientManager.GetById(clientId);
                bool result   = _iClientManager.ApproveClient(aClient, anUser);
                aModel.Message = result ? "<p class='text-green'> Client Approved Successfully!</p>" : "<p class='text-danger'> Failed to  Approve Client ! </p>";
            }
            catch (Exception exception)
            {
                string message = exception.Message;
                aModel.Message = " <p style='color:red'>" + message + "</p>";
            }
            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 30
0
        public JsonResult UnAssignUpazilla(FormCollection collection)
        {
            SuccessErrorModel aModel = new SuccessErrorModel();

            try
            {
                int    territoryDetailsId = Convert.ToInt32(collection["TerritoryDetailsId"]);
                string reason             = collection["Reason"];
                var    anUser             = (ViewUser)Session["user"];
                int    result             = _iTerritoryManager.UnAssignUpazillaFromTerritory(territoryDetailsId, reason, anUser);
                aModel.Message = result > 0 ? "<p style='color:green'>UnAssigned Successfull! </p>" : "<p style='color:red'>Failed to Un Assign</p>";
            }
            catch (Exception e)
            {
                aModel.Message = "<p style='color:red'>" + e.InnerException?.Message + "</p>";
            }

            return(Json(aModel, JsonRequestBehavior.AllowGet));
        }