public void FillJobCard(int Id)
        {
            CustomerReceiptRepository Repo = new CustomerReceiptRepository();
            var List = Repo.FillJC(Id);

            ViewBag.CJC = new SelectList(List, "Id", "Name");
        }
        public void FillSalesInvoice(int Id)
        {
            CustomerReceiptRepository Repo = new CustomerReceiptRepository();
            var List = Repo.FillSI(Id);

            ViewBag.CSI = new SelectList(List, "Id", "Name");
        }
        public void FillSaleOrder(int Id)
        {
            CustomerReceiptRepository Repo = new CustomerReceiptRepository();
            var List = Repo.FillSO(Id);

            ViewBag.CSO = new SelectList(List, "Id", "Name");
        }
        public ActionResult Delete(CustomerReceipt model)
        {
            int result = new CustomerReceiptRepository().DeleteCustomerReceipt(model);

            if (result == 0)
            {
                TempData["Success"] = "Deleted Successfully!";
                TempData["CustomerReceiptRefNo"] = model.CustomerReceiptRefNo;
                return(RedirectToAction("Index"));
            }
            else
            {
                if (result == 1)
                {
                    TempData["error"] = "Sorry!! You Cannot Delete This Customer Receipt. It Is Already In Use";
                    TempData["CustomerReceiptRefNo"] = null;
                }
                else
                {
                    TempData["error"] = "Oops!!..Something Went Wrong!!";
                    TempData["CustomerReceiptRefNo"] = null;
                }
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Edit(CustomerReceipt model, int Code = 0)
        {
            ViewBag.Title        = "Edit";
            model.OrganizationId = OrganizationId;
            model.CreatedDate    = System.DateTime.Now;
            model.CreatedBy      = UserID.ToString();

            var repo = new CustomerReceiptRepository();
            //bool isexists = repo.IsFieldExists(repo.ConnectionString(), "CustomerReceipt", "CustomerReceiptRefNo", model.CustomerReceiptRefNo, "CustomerReceiptId", model.CustomerReceiptId);
            //if (!isexists)
            {
                var result = new CustomerReceiptRepository().UpdateCustomerReceipt(model);
                if (result.CustomerReceiptId > 0)
                {
                    TempData["Success"] = "Updated Successfully!";
                    TempData["CustomerReceiptRefNo"] = result.CustomerReceiptRefNo;
                    return(RedirectToAction("Index"));
                }

                else
                {
                    FillCustomer();
                    FillSaleOrder(Code);
                    FillJobCard(Code);
                    FillSalesInvoice(Code);
                    //FillSO();
                    //FillJC();
                    //FillSI();
                    TempData["error"] = "Oops!!..Something Went Wrong!!";
                    TempData["CustomerReceiptRefNo"] = null;
                    return(View("Create", model));
                }
            }
        }
        public ActionResult CustomerReceiptList(int?page)
        {
            int itemsPerPage = 10;
            int pageNumber   = page ?? 1;
            var repo         = new CustomerReceiptRepository();
            var List         = repo.GetCustomerReceipt();

            return(PartialView("_CustomerReceiptListView", List));
        }
        public ActionResult Delete(int Id, int Code = 0)
        {
            //int Id = 0;
            FillCustomer();
            FillSaleOrder(Code);
            FillJobCard(Code);
            FillSalesInvoice(Code);
            //FillSO();
            //FillJC();
            //FillSI();
            ViewBag.Title = "Delete";
            CustomerReceipt objCustomerReceipt = new CustomerReceiptRepository().GetCustomerReceipt(Id);

            return(View("Create", objCustomerReceipt));
        }
        public JsonResult GETSIAMOUNT(int Id)
        {
            string SaleOrderAmount = new CustomerReceiptRepository().GetSIAmount(Id);

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