public ActionResult JobWorkPayment(MainApplication mainapp, FormCollection frmcol)
        {
            MainApplication model = new MainApplication()
            {
                JobWorkOutwardToClientDetails = new JobWorkOutwardToClient(),
            };

            //CREATE JOB WORK PAYMENT CODE
            string year = FinancialYear;

            string[] yr          = year.Split(' ', '-');
            string   FinYr       = "/" + yr[2].Substring(2) + "-" + yr[6].Substring(2);
            string   paymentcode = string.Empty;

            var jobworkpaymentdata = _JobWorkPaymentService.GetLastPaymentByFinYr(FinYr);
            int PaymentVal         = 0;
            int length             = 0;

            if (jobworkpaymentdata != null)
            {
                paymentcode = jobworkpaymentdata.PaymentCode.Substring(3, 6);
                length      = (Convert.ToInt32(paymentcode) + 1).ToString().Length;
                PaymentVal  = Convert.ToInt32(paymentcode) + 1;
            }
            else
            {
                PaymentVal = 1;
                length     = 1;
            }

            paymentcode = _utilityService.getName("JWP", length, PaymentVal);
            paymentcode = paymentcode + FinYr;
            mainapp.JobWorkPaymentDetails.PaymentCode = paymentcode;

            //update previous job work payment status inactive..
            var jobworkpaymentlist = _JobWorkPaymentService.GetRowsByOutwardNo(mainapp.JobWorkPaymentDetails.OutwardToTailorNo);

            foreach (var row in jobworkpaymentlist)
            {
                row.Status = "InActive";
                _JobWorkPaymentService.Update(row);
            }

            //SAVE CASHIER RECEIVABLES PAYMENT DETAILS
            mainapp.JobWorkPaymentDetails.Cash_1000 = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_1000"]);
            mainapp.JobWorkPaymentDetails.Cash_500  = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_500"]);
            mainapp.JobWorkPaymentDetails.Cash_100  = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_100"]);
            mainapp.JobWorkPaymentDetails.Cash_50   = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_50"]);
            mainapp.JobWorkPaymentDetails.Cash_20   = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_20"]);
            mainapp.JobWorkPaymentDetails.Cash_10   = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_10"]);
            mainapp.JobWorkPaymentDetails.Cash_1    = Convert.ToDouble(frmcol["JobWorkPaymentDetails.Cash_1"]);

            mainapp.JobWorkPaymentDetails.Cash_1000_Amt = Convert.ToDouble(frmcol["Amt1"]);
            mainapp.JobWorkPaymentDetails.Cash_500_Amt  = Convert.ToDouble(frmcol["Amt2"]);
            mainapp.JobWorkPaymentDetails.Cash_100_Amt  = Convert.ToDouble(frmcol["Amt3"]);
            mainapp.JobWorkPaymentDetails.Cash_50_Amt   = Convert.ToDouble(frmcol["Amt4"]);
            mainapp.JobWorkPaymentDetails.Cash_20_Amt   = Convert.ToDouble(frmcol["Amt5"]);
            mainapp.JobWorkPaymentDetails.Cash_10_Amt   = Convert.ToDouble(frmcol["Amt6"]);
            mainapp.JobWorkPaymentDetails.Cash_1_Amt    = Convert.ToDouble(frmcol["Amt7"]);

            mainapp.JobWorkPaymentDetails.TotalCash = Convert.ToDouble(frmcol["JobWorkPaymentDetails.TotalCash"]);

            mainapp.JobWorkPaymentDetails.SelectedCard = frmcol["Card"];

            mainapp.JobWorkPaymentDetails.CreditCardNo = frmcol["JobWorkPaymentDetails.CreditCardNo"];
            if (frmcol["JobWorkPaymentDetails.CreditCardAmount"] == "")
            {
                mainapp.JobWorkPaymentDetails.CreditCardAmount  = 0;
                mainapp.JobWorkPaymentDetails.HandoverCreditAmt = 0;
            }
            else
            {
                mainapp.JobWorkPaymentDetails.CreditCardAmount  = Convert.ToDouble(frmcol["JobWorkPaymentDetails.CreditCardAmount"]);
                mainapp.JobWorkPaymentDetails.HandoverCreditAmt = Convert.ToDouble(frmcol["JobWorkPaymentDetails.CreditCardAmount"]);
            }
            mainapp.JobWorkPaymentDetails.CreditCardType = frmcol["JobWorkPaymentDetails.CreditCardType"];
            mainapp.JobWorkPaymentDetails.CreditCardBank = frmcol["JobWorkPaymentDetails.CreditCardBank"];
            mainapp.JobWorkPaymentDetails.DebitCardNo    = frmcol["JobWorkPaymentDetails.DebitCardNo"];
            mainapp.JobWorkPaymentDetails.DebitCardName  = frmcol["JobWorkPaymentDetails.DebitCardName"];
            mainapp.JobWorkPaymentDetails.DebitCardType  = frmcol["JobWorkPaymentDetails.DebitCardType"];
            mainapp.JobWorkPaymentDetails.DebitCardBank  = frmcol["JobWorkPaymentDetails.DebitCardBank"];
            if (frmcol["JobWorkPaymentDetails.DebitCardAmount"] == "")
            {
                mainapp.JobWorkPaymentDetails.DebitCardAmount  = 0;
                mainapp.JobWorkPaymentDetails.HandoverDebitAmt = 0;
            }
            else
            {
                mainapp.JobWorkPaymentDetails.DebitCardAmount  = Convert.ToDouble(frmcol["JobWorkPaymentDetails.DebitCardAmount"]);
                mainapp.JobWorkPaymentDetails.HandoverDebitAmt = Convert.ToDouble(frmcol["JobWorkPaymentDetails.DebitCardAmount"]);
            }
            mainapp.JobWorkPaymentDetails.ChequeNo    = frmcol["JobWorkPaymentDetails.ChequeNo"];
            mainapp.JobWorkPaymentDetails.ChequeAccNo = frmcol["JobWorkPaymentDetails.ChequeAccNo"];
            if (frmcol["JobWorkPaymentDetails.ChequeAmount"] == "")
            {
                mainapp.JobWorkPaymentDetails.ChequeAmount      = 0;
                mainapp.JobWorkPaymentDetails.HandoverChequeAmt = 0;
            }
            else
            {
                mainapp.JobWorkPaymentDetails.ChequeAmount      = Convert.ToDouble(frmcol["JobWorkPaymentDetails.ChequeAmount"]);
                mainapp.JobWorkPaymentDetails.HandoverChequeAmt = Convert.ToDouble(frmcol["JobWorkPaymentDetails.ChequeAmount"]);
            }
            if (mainapp.JobWorkPaymentDetails.ChequeNo != null && mainapp.JobWorkPaymentDetails.ChequeNo != "")
            {
                mainapp.JobWorkPaymentDetails.ChequeDate = Convert.ToDateTime(frmcol["JobWorkPaymentDetails.ChequeDate"]);
            }
            else
            {
                mainapp.JobWorkPaymentDetails.ChequeDate = null;
            }
            mainapp.JobWorkPaymentDetails.ChequeBank   = frmcol["JobWorkPaymentDetails.ChequeBank"];
            mainapp.JobWorkPaymentDetails.ChequeBranch = frmcol["JobWorkPaymentDetails.ChequeBranch"];


            var outwarddetails = _OutwardToTailorService.GetDetailsByCode(mainapp.JobWorkPaymentDetails.OutwardToTailorNo);

            mainapp.JobWorkPaymentDetails.OutwardToTailorDate  = outwarddetails.Date;
            mainapp.JobWorkPaymentDetails.ClientName           = outwarddetails.ClientName;
            mainapp.JobWorkPaymentDetails.ClientAddress        = outwarddetails.ClientAddress;
            mainapp.JobWorkPaymentDetails.ClientContact        = outwarddetails.ClientContact;
            mainapp.JobWorkPaymentDetails.ClientEmail          = outwarddetails.ClientEmail;
            mainapp.JobWorkPaymentDetails.TailorName           = outwarddetails.TailorName;
            mainapp.JobWorkPaymentDetails.TailorAddress        = outwarddetails.TailorAddress;
            mainapp.JobWorkPaymentDetails.TailorContact        = outwarddetails.TailorContact;
            mainapp.JobWorkPaymentDetails.TailorEmail          = outwarddetails.TailorEmail;
            mainapp.JobWorkPaymentDetails.GrandTotal           = outwarddetails.GrandTotal;
            mainapp.JobWorkPaymentDetails.AdvancePayment       = outwarddetails.AdvancePayment;
            mainapp.JobWorkPaymentDetails.Balance              = Convert.ToDouble(frmcol["BalanceVal"]);
            mainapp.JobWorkPaymentDetails.ItemsDeliveredStatus = frmcol["Delivered"];

            var username = HttpContext.Session["UserName"].ToString();

            //IF EXCEPT SUPERADMIN LOGIN THEN SHOW SHOP OR GODOWN
            if (username != "SuperAdmin")
            {
                mainapp.JobWorkPaymentDetails.ShopCode = Session["LOGINSHOPGODOWNCODE"].ToString();
                mainapp.JobWorkPaymentDetails.ShopName = Session["SHOPGODOWNNAME"].ToString();
            }
            else
            {
                mainapp.JobWorkPaymentDetails.ShopCode = "SuperAdmin";
                mainapp.JobWorkPaymentDetails.ShopName = "SuperAdmin";
            }

            mainapp.JobWorkPaymentDetails.Date       = DateTime.Now;
            mainapp.JobWorkPaymentDetails.Status     = "Active";
            mainapp.JobWorkPaymentDetails.ModifiedOn = DateTime.Now;

            //SAVE HANDOVER STATUS
            if (mainapp.JobWorkPaymentDetails.CreditCardAmount == 0 && mainapp.JobWorkPaymentDetails.DebitCardAmount == 0 && mainapp.JobWorkPaymentDetails.ChequeAmount == 0)
            {
                mainapp.JobWorkPaymentDetails.HandoverStatus = "InActive";
            }
            else
            {
                mainapp.JobWorkPaymentDetails.HandoverStatus = "Active";
            }
            _JobWorkPaymentService.Create(mainapp.JobWorkPaymentDetails);

            //UPDATE OUTWARD TO TAILOR PAYMENT AND BALANCE AFTER CASHIER PAYMENT
            var OutwardToTailorData = _OutwardToTailorService.GetDetailsByCode(mainapp.JobWorkPaymentDetails.OutwardToTailorNo);

            OutwardToTailorData.AdvancePayment = OutwardToTailorData.AdvancePayment + mainapp.JobWorkPaymentDetails.Payment;
            OutwardToTailorData.Balance        = mainapp.JobWorkPaymentDetails.Balance;

            if (OutwardToTailorData.Balance <= 0)
            {
                OutwardToTailorData.Status = "InActive";
            }
            _OutwardToTailorService.Update(OutwardToTailorData);

            //UPDATE OUTWARD TO TAILOR ITEM INACTIVE AFTER CASHIER PAYMENT
            if (OutwardToTailorData.Balance <= 0)
            {
                var OutwardToTailorItemData = _OutwardToTailorItemService.GetRowsByCode(mainapp.JobWorkPaymentDetails.OutwardToTailorNo);
                foreach (var data in OutwardToTailorItemData)
                {
                    data.Status = "InActive";
                    _OutwardToTailorItemService.Update(data);
                }
            }

            if (frmcol["Delivered"] == "Yes")
            {
                //IF DELIVERED STATUS IS YES THEN UPDATE JOB WORK STOCK
                var jobworkstockitems = _JobWorkStockService.GetRowsByOutwardNo(mainapp.JobWorkPaymentDetails.OutwardToTailorNo);
                foreach (var item in jobworkstockitems)
                {
                    item.Status = "InActive";
                    _JobWorkStockService.Update(item);

                    //IF DELIVERED STATUS IS YES THEN ADD THIS STOCK IN JUOB WORK OUTWARD TO CLIENT
                    model.JobWorkOutwardToClientDetails.OutwardToTailorNo = mainapp.JobWorkPaymentDetails.OutwardToTailorNo;
                    model.JobWorkOutwardToClientDetails.PaymentCode       = mainapp.JobWorkPaymentDetails.PaymentCode;
                    model.JobWorkOutwardToClientDetails.ClientName        = mainapp.JobWorkPaymentDetails.ClientName;
                    model.JobWorkOutwardToClientDetails.TailorName        = mainapp.JobWorkPaymentDetails.TailorName;
                    model.JobWorkOutwardToClientDetails.ItemName          = item.ItemName;
                    model.JobWorkOutwardToClientDetails.Quantity          = item.Quantity;
                    model.JobWorkOutwardToClientDetails.Narration         = item.Narration;
                    model.JobWorkOutwardToClientDetails.ShopCode          = mainapp.JobWorkPaymentDetails.ShopCode;
                    model.JobWorkOutwardToClientDetails.ShopName          = mainapp.JobWorkPaymentDetails.ShopName;
                    model.JobWorkOutwardToClientDetails.Status            = "Active";
                    model.JobWorkOutwardToClientDetails.ModifiedOn        = DateTime.Now;
                    _JobWorkOutwardToClientService.Create(model.JobWorkOutwardToClientDetails);
                }
            }

            return(RedirectToAction("JobWorkPayment"));
        }
        public ActionResult Create(MainApplication mainapp, FormCollection frmcol)
        {
            MainApplication model = new MainApplication()
            {
                OutwardToTailorItemDetails = new OutwardToTailorItem(),
                JobWorkPaymentDetails      = new JobWorkPayment(),
            };

            string year = FinancialYear;

            string[] yr    = year.Split(' ', '-');
            string   FinYr = "/" + yr[2].Substring(2) + "-" + yr[6].Substring(2);

            string OutwardCode = string.Empty;

            var details = _OutwardToTailorService.GetLastRowrByFinYr(FinYr);
            int val     = 0;
            int length  = 0;

            if (details != null)
            {
                OutwardCode = details.OutwardCode.Substring(4, 6);
                length      = (Convert.ToInt32(OutwardCode) + 1).ToString().Length;
                val         = Convert.ToInt32(OutwardCode) + 1;

                val    = details.Id;
                val    = val + 1;
                length = val.ToString().Length;
            }
            else
            {
                val    = 1;
                length = 1;
            }
            OutwardCode = _UtilityService.getName("OWTT", length, val);
            OutwardCode = OutwardCode + FinYr;
            mainapp.OutwardToTailorDetails.OutwardCode = OutwardCode;

            //save main outward to tailor..
            mainapp.OutwardToTailorDetails.Date               = DateTime.Now;
            mainapp.OutwardToTailorDetails.RetailBills        = frmcol["RetailBillNoDDL"];
            mainapp.OutwardToTailorDetails.SalesBills         = frmcol["SalesBillNoDDL"];
            mainapp.OutwardToTailorDetails.GrandTotal         = Convert.ToDouble(frmcol["GrandTotalVal"]);
            mainapp.OutwardToTailorDetails.PaidAmountToTailor = 0;
            mainapp.OutwardToTailorDetails.Balance            = Convert.ToDouble(frmcol["BalanceVal"]);
            mainapp.OutwardToTailorDetails.Status             = "Active";
            mainapp.OutwardToTailorDetails.InwardStatus       = "Active";
            mainapp.OutwardToTailorDetails.TailorInwardStatus = "Active";
            mainapp.OutwardToTailorDetails.ModifiedOn         = DateTime.Now;

            var username = HttpContext.Session["UserName"].ToString();

            //IF EXCEPT SUPERADMIN LOGIN THEN SHOW SHOP OR GODOWN
            if (username != "SuperAdmin")
            {
                mainapp.OutwardToTailorDetails.ShopCode = Session["LOGINSHOPGODOWNCODE"].ToString();
                mainapp.OutwardToTailorDetails.ShopName = Session["SHOPGODOWNNAME"].ToString();
            }
            else
            {
                mainapp.OutwardToTailorDetails.ShopCode = "SuperAdmin";
                mainapp.OutwardToTailorDetails.ShopName = "SuperAdmin";
            }
            _OutwardToTailorService.Create(mainapp.OutwardToTailorDetails);

            //save outward to tailor items..
            int itemcount = Convert.ToInt32(frmcol["ItemList"]);

            if (itemcount != 0)
            {
                for (int i = 1; i < itemcount; i++)
                {
                    string checkbox       = "CheckBox" + i;
                    string billno         = "BillNo" + i;
                    string itemcode       = "ItemCode" + i;
                    string itemname       = "ItemName" + i;
                    string narration      = "Narration" + i;
                    string quantity       = "Quantity" + i;
                    string tailoramt      = "TailorAmt" + i;
                    string accessoriesamt = "AccessoriesAmt" + i;
                    string jobworktypeddl = "JobWorkTypeDDL" + i;
                    string itemtype       = "ItemType" + i;
                    string description    = "Description" + i;
                    string barcode        = "Barcode" + i;
                    string unit           = "Unit" + i;
                    string numbertype     = "NumberType" + i;
                    string sellingprice   = "SellingPrice" + i;
                    string mrp            = "MRP" + i;
                    string size           = "Size" + i;
                    string brand          = "Brand" + i;
                    string designcode     = "DesignCode" + i;
                    string designname     = "DesignnName" + i;
                    string color          = "Color" + i;
                    string material       = "Material" + i;

                    if (frmcol[checkbox] == "Yes")
                    {
                        model.OutwardToTailorItemDetails.BillNo             = frmcol[billno];
                        model.OutwardToTailorItemDetails.ItemCode           = frmcol[itemcode];
                        model.OutwardToTailorItemDetails.ItemName           = frmcol[itemname];
                        model.OutwardToTailorItemDetails.NarrationForTailor = frmcol[narration];
                        model.OutwardToTailorItemDetails.Quantity           = frmcol[quantity];
                        model.OutwardToTailorItemDetails.JobWorktype        = frmcol[jobworktypeddl];
                        model.OutwardToTailorItemDetails.TailorAmount       = Convert.ToDouble(frmcol[tailoramt]);
                        model.OutwardToTailorItemDetails.AccessoriesAmount  = Convert.ToDouble(frmcol[accessoriesamt]);
                        model.OutwardToTailorItemDetails.ItemType           = frmcol[itemtype];
                        model.OutwardToTailorItemDetails.Description        = frmcol[description];
                        model.OutwardToTailorItemDetails.Barcode            = frmcol[barcode];
                        model.OutwardToTailorItemDetails.Unit       = frmcol[unit];
                        model.OutwardToTailorItemDetails.NumberType = frmcol[numbertype];
                        if (frmcol[sellingprice] != "")
                        {
                            model.OutwardToTailorItemDetails.SellingPrice = Convert.ToDouble(frmcol[sellingprice]);
                        }
                        else
                        {
                            model.OutwardToTailorItemDetails.SellingPrice = null;
                        }
                        if (frmcol[mrp] != "")
                        {
                            model.OutwardToTailorItemDetails.MRP = Convert.ToDouble(frmcol[mrp]);
                        }
                        else
                        {
                            model.OutwardToTailorItemDetails.MRP = null;
                        }
                        model.OutwardToTailorItemDetails.Size         = frmcol[size];
                        model.OutwardToTailorItemDetails.Brand        = frmcol[brand];
                        model.OutwardToTailorItemDetails.DesignCode   = frmcol[designcode];
                        model.OutwardToTailorItemDetails.DesignName   = frmcol[designname];
                        model.OutwardToTailorItemDetails.Color        = frmcol[color];
                        model.OutwardToTailorItemDetails.Material     = frmcol[material];
                        model.OutwardToTailorItemDetails.OutwardCode  = mainapp.OutwardToTailorDetails.OutwardCode;
                        model.OutwardToTailorItemDetails.Status       = "Active";
                        model.OutwardToTailorItemDetails.InwardStatus = "Active";
                        model.OutwardToTailorItemDetails.ModifiedOn   = DateTime.Now;
                        _OutwardToTailorItemService.Create(model.OutwardToTailorItemDetails);
                    }
                }
            }

            //save job work payment..
            if (mainapp.OutwardToTailorDetails.AdvancePayment != 0)
            {
                //CREATE JOB WORK PAYMENT CODE
                string   year1       = FinancialYear;
                string[] yr1         = year1.Split(' ', '-');
                string   FinYr1      = "/" + yr1[2].Substring(2) + "-" + yr1[6].Substring(2);
                string   paymentcode = string.Empty;

                var jobworkpaymentdata = _JobWorkPaymentService.GetLastPaymentByFinYr(FinYr1);
                int PaymentVal         = 0;
                int length1            = 0;
                if (jobworkpaymentdata != null)
                {
                    paymentcode = jobworkpaymentdata.PaymentCode.Substring(3, 6);
                    length1     = (Convert.ToInt32(paymentcode) + 1).ToString().Length;
                    PaymentVal  = Convert.ToInt32(paymentcode) + 1;
                }
                else
                {
                    PaymentVal = 1;
                    length1    = 1;
                }

                paymentcode = _UtilityService.getName("JWP", length1, PaymentVal);
                paymentcode = paymentcode + FinYr1;
                model.JobWorkPaymentDetails.PaymentCode = paymentcode;


                model.JobWorkPaymentDetails.PaymentType   = frmcol["PaymentType"];
                model.JobWorkPaymentDetails.Cash_1000     = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_1000"]);
                model.JobWorkPaymentDetails.Cash_500      = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_500"]);
                model.JobWorkPaymentDetails.Cash_100      = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_100"]);
                model.JobWorkPaymentDetails.Cash_50       = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_50"]);
                model.JobWorkPaymentDetails.Cash_20       = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_20"]);
                model.JobWorkPaymentDetails.Cash_10       = Convert.ToInt32(frmcol["JobWorkPaymentDetails.Cash_10"]);
                model.JobWorkPaymentDetails.Cash_1        = Convert.ToDouble(frmcol["JobWorkPaymentDetails.Cash_1"]);
                model.JobWorkPaymentDetails.Cash_1000_Amt = Convert.ToDouble(frmcol["Amt1"]);
                model.JobWorkPaymentDetails.Cash_500_Amt  = Convert.ToDouble(frmcol["Amt2"]);
                model.JobWorkPaymentDetails.Cash_100_Amt  = Convert.ToDouble(frmcol["Amt3"]);
                model.JobWorkPaymentDetails.Cash_50_Amt   = Convert.ToDouble(frmcol["Amt4"]);
                model.JobWorkPaymentDetails.Cash_20_Amt   = Convert.ToDouble(frmcol["Amt5"]);
                model.JobWorkPaymentDetails.Cash_10_Amt   = Convert.ToDouble(frmcol["Amt6"]);
                model.JobWorkPaymentDetails.Cash_1_Amt    = Convert.ToDouble(frmcol["Amt7"]);
                model.JobWorkPaymentDetails.TotalCash     = Convert.ToDouble(frmcol["JobWorkPaymentDetails.TotalCash"]);
                model.JobWorkPaymentDetails.SelectedCard  = frmcol["Card"];
                model.JobWorkPaymentDetails.CreditCardNo  = frmcol["JobWorkPaymentDetails.CreditCardNo"];
                if (frmcol["JobWorkPaymentDetails.CreditCardAmount"] == "")
                {
                    model.JobWorkPaymentDetails.CreditCardAmount = 0;
                }
                else
                {
                    model.JobWorkPaymentDetails.CreditCardAmount = Convert.ToDouble(frmcol["JobWorkPaymentDetails.CreditCardAmount"]);
                }
                model.JobWorkPaymentDetails.CreditCardType = frmcol["JobWorkPaymentDetails.CreditCardType"];
                model.JobWorkPaymentDetails.CreditCardBank = frmcol["JobWorkPaymentDetails.CreditCardBank"];
                model.JobWorkPaymentDetails.DebitCardNo    = frmcol["JobWorkPaymentDetails.DebitCardNo"];
                model.JobWorkPaymentDetails.DebitCardName  = frmcol["JobWorkPaymentDetails.DebitCardName"];
                model.JobWorkPaymentDetails.DebitCardType  = frmcol["JobWorkPaymentDetails.DebitCardType"];
                model.JobWorkPaymentDetails.DebitCardBank  = frmcol["JobWorkPaymentDetails.DebitCardBank"];
                if (frmcol["JobWorkPaymentDetails.DebitCardAmount"] == "")
                {
                    model.JobWorkPaymentDetails.DebitCardAmount = 0;
                }
                else
                {
                    model.JobWorkPaymentDetails.DebitCardAmount = Convert.ToDouble(frmcol["JobWorkPaymentDetails.DebitCardAmount"]);
                }
                model.JobWorkPaymentDetails.ChequeNo     = frmcol["JobWorkPaymentDetails.ChequeNo"];
                model.JobWorkPaymentDetails.ChequeAccNo  = frmcol["JobWorkPaymentDetails.ChequeAccNo"];
                model.JobWorkPaymentDetails.ChequeAmount = Convert.ToDouble(frmcol["JobWorkPaymentDetails.ChequeAmount"]);
                if (model.JobWorkPaymentDetails.ChequeNo != null && model.JobWorkPaymentDetails.ChequeNo != "")
                {
                    model.JobWorkPaymentDetails.ChequeDate = Convert.ToDateTime(frmcol["JobWorkPaymentDetails.ChequeDate"]);
                }
                else
                {
                    model.JobWorkPaymentDetails.ChequeDate = null;
                }
                model.JobWorkPaymentDetails.ChequeBank   = frmcol["JobWorkPaymentDetails.ChequeBank"];
                model.JobWorkPaymentDetails.ChequeBranch = frmcol["JobWorkPaymentDetails.ChequeBranch"];

                model.JobWorkPaymentDetails.Date = DateTime.Now;
                model.JobWorkPaymentDetails.OutwardToTailorNo   = mainapp.OutwardToTailorDetails.OutwardCode;
                model.JobWorkPaymentDetails.OutwardToTailorDate = mainapp.OutwardToTailorDetails.Date;
                model.JobWorkPaymentDetails.ClientName          = mainapp.OutwardToTailorDetails.ClientName;
                model.JobWorkPaymentDetails.ClientAddress       = mainapp.OutwardToTailorDetails.ClientAddress;
                model.JobWorkPaymentDetails.ClientContact       = mainapp.OutwardToTailorDetails.ClientContact;
                model.JobWorkPaymentDetails.ClientEmail         = mainapp.OutwardToTailorDetails.ClientEmail;
                model.JobWorkPaymentDetails.TailorName          = mainapp.OutwardToTailorDetails.TailorName;
                model.JobWorkPaymentDetails.TailorContact       = mainapp.OutwardToTailorDetails.TailorContact;
                model.JobWorkPaymentDetails.TailorAddress       = mainapp.OutwardToTailorDetails.TailorAddress;
                model.JobWorkPaymentDetails.TailorEmail         = mainapp.OutwardToTailorDetails.TailorEmail;
                model.JobWorkPaymentDetails.GrandTotal          = mainapp.OutwardToTailorDetails.GrandTotal;
                model.JobWorkPaymentDetails.AdvancePayment      = mainapp.OutwardToTailorDetails.AdvancePayment;
                model.JobWorkPaymentDetails.Payment             = mainapp.OutwardToTailorDetails.AdvancePayment;
                model.JobWorkPaymentDetails.Balance             = mainapp.OutwardToTailorDetails.Balance;
                model.JobWorkPaymentDetails.ShopCode            = mainapp.OutwardToTailorDetails.ShopCode;
                model.JobWorkPaymentDetails.ShopName            = mainapp.OutwardToTailorDetails.ShopName;
                model.JobWorkPaymentDetails.PreparedBy          = mainapp.OutwardToTailorDetails.PreparedBy;
                model.JobWorkPaymentDetails.Status     = "Active";
                model.JobWorkPaymentDetails.ModifiedOn = DateTime.Now;
                _JobWorkPaymentService.Create(model.JobWorkPaymentDetails);
            }

            var OutToTailorId = _OutwardToTailorService.GetLastRow().Id;
            var Outwardid     = Encode(OutToTailorId.ToString());

            return(RedirectToAction("CreateDetails/" + Outwardid, "OutwardToTailor"));
        }