public JsonResult AddUpdateConsigment(LP_Consigment_ViewModel objpurchase) { try { bool flag = false; _objconsigment = new LP_Consigment_Property(); _objconsigment.InvoiceNo = objpurchase.InvoiceNo; _objconsigment.ParentDocumentId = objpurchase.ParentDocumentId; //_objCIMaster.purchaseDate = objpurchase.purchaseDate; _objconsigment.Invoicedate = objpurchase.Invoicedate; _objconsigment.Reference = objpurchase.Reference; //_objconsigment. = objpurchase.totalAmount; //_objconsigment.netAmount = objpurchase.netAmount; //_objconsigment.paidAmount = objpurchase.paidAmount; //_objconsigment.balanceAmount = objpurchase.balanceAmount; // _objCIMaster.DocumentNumber = objpurchase.DocumentNumber; // _objCIMaster.ContainerNo = objpurchase.ContainerNo; // _objCIMaster.ExchangeRate = objpurchase.ExchangeRate; // _objCIMaster.DepartmentID = objpurchase.DepartmentID; // _objCIMaster.paidDate = ;// objpurchase.paidDate; _objconsigment.CIPODetails = Helper.ToDataTable <LP_CI_PurchaseDetails_Property>(objpurchase.CIDetailsPO); _objconsigment.DetailData = Helper.ToDataTable <LP_ConsigmentDetails>(objpurchase.ConsigmentDetails); if (objpurchase.idx > 0) { _objCIMaster.idx = objpurchase.idx; _objCIMaster.creationDate = DateTime.Now; _objCIMaster.visible = 1; _objCIMaster.createdByUserIdx = Convert.ToInt16(Session["UID"].ToString()); _objCIMaster.visible = 1; _objCIMaster.status = "0"; _objCIMaster.TableName = "CommercialDetails"; objpurchaseBll = new LP_PI_BLL(); flag = objpurchaseBll.Insert(); //update } else { //add _objconsigment.creationDate = DateTime.Now; //_objconsigment.visible = 1; _objconsigment.createdByUserIdx = Convert.ToInt16(Session["UID"].ToString()); //_objconsigment.visible = 1; _objconsigment.status = 0; _objconsigment.TableName = "consigmentdetails"; objpurchaseBll = new LP_PI_BLL(_objconsigment); flag = objpurchaseBll.InsertConsigment(); } return(Json(new { data = "", success = flag, msg = flag == true ? "Successfull" : "Failed", statuscode = flag == true ? 200 : 401 }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { data = ex.Message, success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddNewConsigment(int?id) { if (Session["LOGGEDIN"] != null) { objConsigmentVm = new LP_Consigment_ViewModel(); Vendors_Property vendor = new Vendors_Property(); Product_Property product = new Product_Property(); Vendors_BLL objvendorbll = new Vendors_BLL(); Product_BLL objProductbll = new Product_BLL(); objpurchaseBll = new LP_PI_BLL(); // objPurchaseVM_Property.VendorLST = Helper.ConvertDataTable<Vendors_Property>(objvendorbll.ViewAll()); // objPurchaseVM_Property.DepartmentList = Helper.ConvertDataTable<Departments_property>(GetAllDepartments()); // objPurchaseVM_Property.PurchaseType_List = Helper.ConvertDataTable<LP_Purchase_Type>(GetAllPurchaseType()); objConsigmentVm.ProductList = Helper.ConvertDataTable <Product_Property>(objProductbll.ViewAll()); objConsigmentVm.CIPO = Helper.ConvertDataTable <LP_CI_PurchaseOrder_Property>(objpurchaseBll.SelectAllCIPO()); objConsigmentVm.Invoicedate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); //objPurchaseVM_Property.poNumber = "Po-001"; if (id > 0) { //LP_Purchase_Detail_Property objmpurchasedetail; //objPurchaseProperty = new LP_Performa_Invoice_Property(); //objPurchaseProperty.idx = Convert.ToInt16(id); //objpurchaseBll = new LP_PI_BLL(); //DataTable dt = objpurchaseBll.SelectOne(); //objPurchaseVM_Property.idx = Convert.ToInt16(dt.Rows[0]["purchaseIdx"].ToString()); //objPurchaseVM_Property.vendorIdx = Convert.ToInt16(dt.Rows[0]["vendorIdx"].ToString()); //objPurchaseVM_Property.poNumber = dt.Rows[0]["poNumber"].ToString(); //objPurchaseVM_Property.description = dt.Rows[0]["description"].ToString(); //objPurchaseVM_Property.DepartmentID = Convert.ToInt16(dt.Rows[0]["DepartmentID"].ToString()); //objPurchaseVM_Property.totalAmount = Convert.ToDecimal(dt.Rows[0]["totalAmount"].ToString()); //string pdate = (dt.Rows[0]["purchaseDate"].ToString()).ToString(); //string ndate = DateTime.Parse(pdate).ToString("yyyy-MM-dd"); //objPurchaseVM_Property.purchaseDate = Convert.ToDateTime(ndate);// DateTime.Parse(dt.Rows[0]["mrnDate"].ToString()).ToString("yyyy-MM-dd"); ////DateTime.Parse(dt.Rows[0]["mrnDate"].ToString()).ToString("yyyy-MM-dd"); ////foreach(DataRow dr in dt.Rows) ////{ //// objmrndetail ////} //ViewBag.DetailData = Helper.ConvertDataTable<PurchaseVM_Property>(dt); //update return(View("AddNewConsigment", objConsigmentVm)); } else { //objPurchaseProperty = new LP_Purchase_Master_Property(); objConsigmentVm.createdByUserIdx = Convert.ToInt16(Session["UID"].ToString()); objpurchaseBll = new LP_PI_BLL(); LP_GenerateTransNumber_Property objtrans = new LP_GenerateTransNumber_Property(); objtrans.TableName = "consigment"; objtrans.Identityfieldname = "idx"; objtrans.userid = Session["UID"].ToString(); objConsigmentVm.InvoiceNo = objpurchaseBll.GenerateCINo(objtrans); //objCIPOVm.CDPercntage = 20; //objCIPOVm.RDPercentage = 20; //objCIPOVm.ACDPercentage = 20; //objCIPOVm.STPercentage = 20; //objCIPOVm.ITPercentage = 20; //objCIPOVm.TDTax = 0.00m; //objCIPOVm.CleaningPrice = 0.00m; //objCIPOVm.TotalPrice = 0.00m; //objCIPOVm.ASTPercentage = 20; //objCIPOVm.CleaningPrice = 20; //objPurchaseProperty.poNumber = ""; //objpurchaseBll = new LP_Purchase_BLL(objPurchaseProperty); //objPurchaseVM_Property.poNumber = objpurchaseBll.GeneratePO();// "PO-001"; // string po = objpurchaseBll.GeneratePO(); return(View("AddNewConsigment", objConsigmentVm)); } } else { return(RedirectToAction("Login", "Account")); } }