public JsonResult AddUpdateCI(LP_CI_ViewModel objpurchase) { try { bool flag = false; _objCIMaster = new LP_CI_PurchaseOrder_Property(); _objCIMaster.poNumber = objpurchase.poNumber; _objCIMaster.PINO = objpurchase.PINO; //_objCIMaster.purchaseDate = objpurchase.purchaseDate; _objCIMaster.purchaseDate = objpurchase.purchaseDate; _objCIMaster.description = objpurchase.description; _objCIMaster.totalAmount = objpurchase.totalAmount; _objCIMaster.netAmount = objpurchase.netAmount; _objCIMaster.paidAmount = objpurchase.paidAmount; _objCIMaster.balanceAmount = objpurchase.balanceAmount; // _objCIMaster.DocumentNumber = objpurchase.DocumentNumber; // _objCIMaster.ContainerNo = objpurchase.ContainerNo; // _objCIMaster.ExchangeRate = objpurchase.ExchangeRate; // _objCIMaster.DepartmentID = objpurchase.DepartmentID; // _objCIMaster.paidDate = ;// objpurchase.paidDate; _objCIMaster.DetailData = Helper.ToDataTable <LP_CI_PurchaseDetails_Property>(objpurchase.CILIST); 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 _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(_objCIMaster); flag = objpurchaseBll.InsertCIPO(); } 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 AddNewCIPO(int?id) { if (Session["LOGGEDIN"] != null) { objCIPOVm = new LP_CI_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()); objCIPOVm.ProductList = Helper.ConvertDataTable <Product_Property>(objProductbll.ViewAll()); objCIPOVm.PerformaLISt = Helper.ConvertDataTable <LP_Performa_Invoice_Property>(objpurchaseBll.SelectAll()); objCIPOVm.purchaseDate = 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("AddNewCIPO", objCIPOVm)); } else { //objPurchaseProperty = new LP_Purchase_Master_Property(); objCIPOVm.createdByUserIdx = Convert.ToInt16(Session["UID"].ToString()); objpurchaseBll = new LP_PI_BLL(); LP_GenerateTransNumber_Property objtrans = new LP_GenerateTransNumber_Property(); objtrans.TableName = "CI_PurchaseOrder"; objtrans.Identityfieldname = "idx"; objtrans.userid = Session["UID"].ToString(); objCIPOVm.poNumber = 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("AddNewCIPO", objCIPOVm)); } } else { return(RedirectToAction("Login", "Account")); } }