private Viewmodel_AddPurchaseQuotation GetXmlPurchaseQtn(PurchaseQuotation model) { Viewmodel_AddPurchaseQuotation Xmlqtn = new Viewmodel_AddPurchaseQuotation(); Xmlqtn.TroyPQtnId = model.Purchase_Quote_Id.ToString(); Xmlqtn.BPCode = model.Vendor.ToString(); Xmlqtn.RefNo = model.Reference_Number; Xmlqtn.TroyPQtnStatus = model.Quotation_Status; Xmlqtn.PostingDate = model.Posting_Date.ToString(); Xmlqtn.ValidDate = model.Valid_Date.ToString(); Xmlqtn.RequiredDate = model.Required_Date.ToString(); Xmlqtn.BranchCode = model.Ship_To.ToString(); Xmlqtn.Freight = model.Freight.ToString(); Xmlqtn.Loading = model.Loading.ToString(); Xmlqtn.TotalBefDocDisc = model.TotalBefDocDisc.ToString(); Xmlqtn.DocDiscAmt = model.DocDiscAmt.ToString(); Xmlqtn.TaxAmt = model.TaxAmt.ToString(); Xmlqtn.TotalQtnAmt = model.TotalQtnAmt.ToString(); Xmlqtn.Remarks = model.Remarks; Xmlqtn.CreatedUser = model.Created_User_Id.ToString(); Xmlqtn.CreatedBranch = model.Creating_Branch.ToString(); Xmlqtn.CreatedDate = model.Created_Date.ToString(); Xmlqtn.ModifiedBranch = model.Modified_Branch_Id.ToString(); Xmlqtn.ModifiedDate = model.Modified_Date.ToString(); return(Xmlqtn); }
public void resetButton() { this.PQCopyFromPR.Active.SetItemValue("Enabled", false); this.PQCopyToPO.Active.SetItemValue("Enabled", false); PurchaseQuotation selectobject = (PurchaseQuotation)View.CurrentObject; SystemUsers user = ObjectSpace.GetObjectByKey <SystemUsers>(SecuritySystem.CurrentUserId); switch (selectobject.DocStatus.CurrDocStatus) { case DocStatus.Cancelled: case DocStatus.Closed: case DocStatus.Posted: case DocStatus.Accepted: case DocStatus.Submited: break; default: this.PQCopyFromPR.Active.SetItemValue("Enabled", true); break; } switch (selectobject.DocStatus.CurrDocStatus) { case DocStatus.Accepted: if (user.Roles.Where(pp => pp.Name == DocTypeCodes.PurchaseOrder).Count() > 0) { this.PQCopyToPO.Active.SetItemValue("Enabled", true); } break; default: break; } }
private void PQCopyFromPR_Execute(object sender, PopupWindowShowActionExecuteEventArgs e) { PurchaseQuotation masterobject = (PurchaseQuotation)View.CurrentObject; IObjectSpace ios = View is DetailView ? ObjectSpace : Application.CreateObjectSpace(); if (copyCon.CopyFromDocument(masterobject, (ListView)e.PopupWindow.View, ios)) { masterobject.IsCopy = true; genCon.showMsg("Operation Done", "Item Copied.", InformationType.Success); return; } }
public bool UpdateQuotation(PurchaseQuotation Quotation, IList <PurchaseQuotationItem> QuotationItemList, ref string ErrorMessage) { ErrorMessage = string.Empty; try { purchaseContext.Entry(Quotation).State = EntityState.Modified; purchaseContext.SaveChanges(); foreach (var model in QuotationItemList) { if (model.IsDummy == 1) { purchaseContext.Entry(model).State = EntityState.Deleted; purchaseContext.SaveChanges(); } else { if (model.Quote_Item_Id == 0) { model.Purchase_Quote_Id = Quotation.Purchase_Quote_Id; purchaseContext.PurchaseQuotationItem.Add(model); purchaseContext.SaveChanges(); } else { purchaseContext.Entry(model).State = EntityState.Modified; purchaseContext.SaveChanges(); } } } return(true); } catch (Exception ex) { ExceptionHandler.LogException(ex); ErrorMessage = ex.Message; return(false); } //catch (DbEntityValidationException dbEx) //{ // var errorList = new List<string>(); // foreach (var validationErrors in dbEx.EntityValidationErrors) // { // foreach (var validationError in validationErrors.ValidationErrors) // { // errorList.Add(String.Format("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage)); // } // } // return false; //} }
public bool AddNewQuotation(PurchaseQuotation Quotation, IList <PurchaseQuotationItem> QuotationItemList, ref string ErrorMessage) { ErrorMessage = string.Empty; try { purchaseContext.PurchaseQuotation.Add(Quotation); purchaseContext.SaveChanges(); int currentId = Quotation.Purchase_Quote_Id; for (int i = 0; i < QuotationItemList.Count; i++) { QuotationItemList[i].Purchase_Quote_Id = currentId; } purchaseContext.PurchaseQuotationItem.AddRange(QuotationItemList); purchaseContext.SaveChanges(); return(true); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } //catch (Exception ex) //{ // ExceptionHandler.LogException(ex); // ErrorMessage = ex.Message; // return false; //} }
private void PQCopyToPO_Execute(object sender, SimpleActionExecuteEventArgs e) { PurchaseQuotation sObject = (PurchaseQuotation)View.CurrentObject; IObjectSpace ios = Application.CreateObjectSpace(); PurchaseOrder tObject = ios.CreateObject <PurchaseOrder>(); if (copyCon.CopyToDocument(sObject, tObject, ios, (DetailView)View)) { if (tObject.CardCode != null) { tObject.IsCopy = true; } genCon.showMsg("Operation Done", "New Purchase Delivery copied. Please save it.", InformationType.Success); genCon.openNewView(ios, tObject, ViewEditMode.Edit); return; } genCon.showMsg("Operation Done", "No Open Item for copied.", InformationType.Info); }
private void PQCopyFromPR_CustomizePopupWindowParams(object sender, CustomizePopupWindowParamsEventArgs e) { PurchaseQuotation masterobject = (PurchaseQuotation)View.CurrentObject; string ObjType = masterobject.DocType.BoCode; string BusinessPartner = masterobject.CardCode == null ? "" : masterobject.CardCode.BoKey; string doccur = masterobject.DocCur == null ? "" : masterobject.DocCur.BoKey; IObjectSpace newObjectSpace = Application.CreateObjectSpace(typeof(PurchaseRequestDetail)); string listViewId = Application.FindLookupListViewId(typeof(PurchaseRequestDetail)); CollectionSourceBase collectionSource = Application.CreateCollectionSource(newObjectSpace, typeof(PurchaseRequestDetail), listViewId); if (BusinessPartner == "") { collectionSource.Criteria["filter01"] = CriteriaOperator.Parse("1=0"); } else { collectionSource.Criteria["Filter01"] = CriteriaOperator.Parse("OpenQty > CopyQty and PurchaseRequest is not null and PurchaseRequest.DocStatus.CurrDocStatus in (?) and LineStatus in (?) and DocCur.BoKey=? and (LineVendor=? or LineVendor is null)", DocStatus.Accepted, LineStatusEnum.Open, doccur, BusinessPartner); } e.View = Application.CreateListView(listViewId, collectionSource, true); //e.View = Application.CreateListView(typeof(PurchaseRequestDetail), true); }
public bool UploadExcelData(string fileExtension, string fileName, ref string returnMessage) { try { ApplicationUser currentUser = ApplicationUserManager.GetApplicationUser(User.Identity.Name, HttpContext.GetOwinContext()); string fileLocation = string.Format("{0}/{1}", Server.MapPath("~/App_Data/ExcelFiles"), fileName); if (System.IO.File.Exists(fileLocation)) { System.IO.File.Delete(fileLocation); } Request.Files["FileUpload"].SaveAs(fileLocation); string excelConnectionString = string.Empty; excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\""; //connection String for xls file format. if (fileExtension == ".xls") { excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\""; } //connection String for xlsx file format. else if (fileExtension == ".xlsx") { excelConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileLocation + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=2\""; } //Create Connection to Excel work book and add oledb namespace OleDbConnection excelConnection = new OleDbConnection(excelConnectionString); excelConnection.Open(); DataTable dt = new DataTable(); string exquery; dt = excelConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if (dt == null) { returnMessage = "Excel file is empty"; return(false); } String[] excelSheets = new String[dt.Rows.Count]; int t = 0; //excel data saves in temp file here. foreach (DataRow row in dt.Rows) { excelSheets[t] = row["TABLE_NAME"].ToString(); t++; } for (int k = 0; k < dt.Rows.Count; k++) { DataSet ds = new DataSet(); int sheets = k + 1; OleDbConnection excelConnection1 = new OleDbConnection(excelConnectionString); exquery = string.Format("Select * from [{0}]", excelSheets[k]); using (OleDbDataAdapter dataAdapter = new OleDbDataAdapter(exquery, excelConnection1)) { dataAdapter.Fill(ds); } if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { if (ExcelDataIsValid(ds, ref returnMessage)) { int row = 0; int vendorId = 0; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { List <PurchaseQuotationItem> pqItemList = new List <PurchaseQuotationItem>(); PurchaseQuotation pItem = new PurchaseQuotation(); PurchaseQuotationItem pqItem = new PurchaseQuotationItem(); if (ds.Tables[0].Rows[i]["Vendor"] != null) { pItem.Vendor = Convert.ToInt32(ds.Tables[0].Rows[i]["Vendor"]); //vendorId = pItem.Vendor; pqItem = GetExcelQuotationItem(ds, i, ref returnMessage); if (pqItem != null) { pqItemList.Add(pqItem); } else { returnMessage = "Vendor name cannot be empty it the excel sheet"; return(false); } for (int j = i + 1; j < ds.Tables[0].Rows.Count; j++) { if (ds.Tables[0].Rows[j]["Vendor"].ToString() == "" || ds.Tables[0].Rows[j]["Vendor"].ToString() == null) { pqItem = GetExcelQuotationItem(ds, j, ref returnMessage); if (pqItem != null) { pqItemList.Add(pqItem); row = j; } else { returnMessage = "Vendor name cannot be empty it the excel sheet"; return(false); } } else { row = j - 1; break; } } } else { } pItem.Reference_Number = ds.Tables[0].Rows[i]["Reference Number"].ToString(); pItem.Quotation_Status = ds.Tables[0].Rows[i]["Quotation Status"].ToString(); pItem.Ship_To = Convert.ToInt32(ds.Tables[0].Rows[i]["Ship To"]); pItem.Freight = Convert.ToInt32(ds.Tables[0].Rows[i]["Freight"]); pItem.Loading = Convert.ToInt32(ds.Tables[0].Rows[i]["Loading"]); pItem.Posting_Date = Convert.ToDateTime(ds.Tables[0].Rows[i]["Posting Date"]); pItem.Valid_Date = Convert.ToDateTime(ds.Tables[0].Rows[i]["Valid Up To"]); pItem.Required_Date = Convert.ToDateTime(ds.Tables[0].Rows[i]["Required Date"]); //pItem.DocDiscAmt = Convert.ToInt32(ds.Tables[0].Rows[i]["DocDiscAmt"]); pItem.Remarks = ds.Tables[0].Rows[i]["Remarks"].ToString(); pItem.Created_User_Id = currentUser.Created_User_Id; pItem.Created_Branc_Id = currentUser.Created_Branch_Id; pItem.Created_Date = DateTime.Now; pItem.Modified_User_Id = currentUser.Modified_User_Id; pItem.Modified_Branch_Id = currentUser.Modified_Branch_Id; pItem.Modified_Date = DateTime.Now; //plist.PurchaseQuotationList.Add(pItem); if (purchaseDb.AddNewQuotation(pItem, pqItemList, ref returnMessage)) { i = row; } else { return(false); } } //return plist; return(true); } else { //returnMessage = "12325"; return(false); } } else { returnMessage = "Excel file is empty"; return(false); } } else { returnMessage = "Excel file is empty"; return(false); } } returnMessage = "Excel file is empty"; return(false); } catch (Exception ex) { returnMessage = ex.Message; return(false); } }
public List <PurchaseQuotation> GetFilterQuotation(string searchColumn, string searchString, Guid userId) { List <PurchaseQuotation> qList = new List <PurchaseQuotation>(); if (searchColumn == null) { searchColumn = ""; searchString = ""; } purchaseContext.Database.Initialize(force: false); var cmd = purchaseContext.Database.Connection.CreateCommand(); cmd.CommandText = "[dbo].[USP_GetPurchaseQuotation]"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@SearchColumn", searchColumn)); cmd.Parameters.Add(new SqlParameter("@SearchString", searchString)); try { purchaseContext.Database.Connection.Open(); // Run the sproc var reader = cmd.ExecuteReader(); var result = ((IObjectContextAdapter)purchaseContext) .ObjectContext .Translate <PurchaseQuotation>(reader, "PurchaseQuotation", MergeOption.AppendOnly); foreach (var item in result) { PurchaseQuotation model = new PurchaseQuotation() { Purchase_Quote_Id = item.Purchase_Quote_Id, Created_Branc_Id = item.Created_Branc_Id, Created_Date = item.Created_Date, Created_User_Id = item.Created_User_Id, Creating_Branch = item.Creating_Branch, DocDiscAmt = item.DocDiscAmt, Freight = item.Freight, Loading = item.Loading, Modified_Branch_Id = item.Modified_Branch_Id, Modified_Date = item.Modified_Date, Modified_User_Id = item.Modified_User_Id, Posting_Date = item.Posting_Date, Quotation_Status = item.Quotation_Status, Reference_Number = item.Reference_Number, Remarks = item.Remarks, Required_Date = item.Required_Date, Ship_To = item.Ship_To, Valid_Date = item.Valid_Date, Vendor = item.Vendor }; qList.Add(model); } } finally { purchaseContext.Database.Connection.Close(); } return(qList); }
public void GetDetailClassVisOrder(ClassDocument tObject, ref int minvalue, ref int maxvisorder) { int comparevalue = 0; int comparevisorder = 0; if (tObject.GetType() == typeof(PurchaseRequest)) { PurchaseRequest masterobject = (PurchaseRequest)tObject; if (masterobject.PurchaseRequestDetail.Count > 0) { comparevalue = masterobject.PurchaseRequestDetail.Min(pp => pp.Oid); comparevisorder = masterobject.PurchaseRequestDetail.Max(pp => pp.VisOrder); } if (comparevalue <= minvalue) { minvalue = comparevalue - 1; } if (comparevisorder >= maxvisorder) { maxvisorder = comparevisorder + 1; } } else if (tObject.GetType() == typeof(PurchaseOrder)) { PurchaseOrder masterobject = (PurchaseOrder)tObject; if (masterobject.PurchaseOrderDetail.Count > 0) { comparevalue = masterobject.PurchaseOrderDetail.Min(pp => pp.Oid); comparevisorder = masterobject.PurchaseOrderDetail.Max(pp => pp.VisOrder); } if (comparevalue <= minvalue) { minvalue = comparevalue - 1; } if (comparevisorder >= maxvisorder) { maxvisorder = comparevisorder + 1; } } else if (tObject.GetType() == typeof(PurchaseDelivery)) { PurchaseDelivery masterobject = (PurchaseDelivery)tObject; if (masterobject.PurchaseDeliveryDetail.Count > 0) { comparevalue = masterobject.PurchaseDeliveryDetail.Min(pp => pp.Oid); comparevisorder = masterobject.PurchaseDeliveryDetail.Max(pp => pp.VisOrder); } if (comparevalue <= minvalue) { minvalue = comparevalue - 1; } if (comparevisorder >= maxvisorder) { maxvisorder = comparevisorder + 1; } } else if (tObject.GetType() == typeof(PurchaseReturn)) { PurchaseReturn masterobject = (PurchaseReturn)tObject; if (masterobject.PurchaseReturnDetail.Count > 0) { comparevalue = masterobject.PurchaseReturnDetail.Min(pp => pp.Oid); comparevisorder = masterobject.PurchaseReturnDetail.Max(pp => pp.VisOrder); } if (comparevalue <= minvalue) { minvalue = comparevalue - 1; } if (comparevisorder >= maxvisorder) { maxvisorder = comparevisorder + 1; } } else if (tObject.GetType() == typeof(PurchaseQuotation)) { PurchaseQuotation masterobject = (PurchaseQuotation)tObject; if (masterobject.PurchaseQuotationDetail.Count > 0) { comparevalue = masterobject.PurchaseQuotationDetail.Min(pp => pp.Oid); comparevisorder = masterobject.PurchaseQuotationDetail.Max(pp => pp.VisOrder); } if (comparevalue <= minvalue) { minvalue = comparevalue - 1; } if (comparevisorder >= maxvisorder) { maxvisorder = comparevisorder + 1; } } }
public ActionResult AddPurchaseQuotation(FormCollection fc) { var currentAnnualBudgetId = new BaseController(_repAnnualBudget).budgetList; ViewBag.Title = Constant.ADD_PURCHASE_QUOTATION; //Common Method to be called for Purchase Quotation Form SubmitPurchaseQuotationViewModel pqvm = PurchaseQuotationCommon(); try { pqvm.AssetListId = fc["AssetList"]; pqvm.Price = fc["Price"]; pqvm.VAT = fc["VAT"]; pqvm.Quantity = fc["Quantity"]; pqvm.PurchaseType = fc["PurchaseType"]; pqvm.QuotedDate = fc["QuotedDate"]; var lstAssetListId = pqvm.AssetListId.Split(',').ToList(); var lstPrice = pqvm.Price.Split(',').ToList(); var lstVAT = pqvm.VAT.Split(',').ToList(); var lstQuantity = pqvm.Quantity.Split(',').ToList(); var lstPurchaseType = pqvm.PurchaseType.Split(',').ToList(); var lstQuotedDate = pqvm.QuotedDate.Split(',').ToList(); var lstPurchaseQuotation = new List <PurchaseQuotation>(); for (int i = 0; i < lstAssetListId.Count; i++) { var pq = new PurchaseQuotation(); pq.AssetId = long.Parse(lstAssetListId[i]); pq.AnnualBudgetId = currentAnnualBudgetId; pq.UserId = SessionHelper.UserId; pq.AssetPrice = decimal.Parse(lstPrice[i]); pq.VAT = decimal.Parse(lstVAT[i]); pq.Quantity = int.Parse(lstQuantity[i]); pq.PurchaseType = lstPurchaseType[i]; pq.QuotedDate = DateTime.Parse(lstQuotedDate[i]); lstPurchaseQuotation.Add(pq); } var lstPqEnryLog = new List <PurchaseQuotationEntryLog>(); for (int i = 0; i < lstAssetListId.Count; i++) { var pqel = new PurchaseQuotationEntryLog(); pqel.AssetId = long.Parse(lstAssetListId[i]); pqel.AnnualBudgetId = currentAnnualBudgetId; pqel.UserId = SessionHelper.UserId; pqel.AssetPrice = decimal.Parse(lstPrice[i]); pqel.VAT = decimal.Parse(lstVAT[i]); pqel.Quantity = int.Parse(lstQuantity[i]); pqel.PurchaseType = lstPurchaseType[i]; pqel.QuotedDate = DateTime.Parse(lstQuotedDate[i]); pqel.IsApproved = 1; pqel.ActionType = "Create"; pqel.Username = SessionHelper.Username; pqel.CreatedDate = DateTime.Now; lstPqEnryLog.Add(pqel); } if (ModelState.IsValid) { _repPurchaseQuotation.AddPurchaseQuotationInfo(lstPurchaseQuotation, lstPqEnryLog); FlashMessage.Confirmation("Purchase quotation has been added successfully."); return(RedirectToAction("QuotationDetails")); } } catch (IOException e) { // Extract some information from this exception, and then // throw it to the parent method. if (e.Source != null) { Console.WriteLine("IOException source: {0}", e.Source); throw; } } return(View(pqvm)); }
private void Controller_ObjectCreated(object sender, ObjectCreatedEventArgs e) { ListView lv = ((ListView)View); if (lv.CollectionSource is PropertyCollectionSource) { PropertyCollectionSource collectionSource = (PropertyCollectionSource)lv.CollectionSource; if (collectionSource.MasterObject != null) { int minvalue = 0; int maxvisorder = 0; if (collectionSource.MasterObjectType == typeof(StockTransferRequest) && e.CreatedObject.GetType() == typeof(StockTransferRequestDetail)) { StockTransferRequest masterobject = (StockTransferRequest)collectionSource.MasterObject; StockTransferRequestDetail currentobject = (StockTransferRequestDetail)e.CreatedObject; copyCon.GetStockDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; if (sDtlS != null) { copyCon.copyClassStockTransferDocumentDetail(sDtlS, currentobject, e.ObjectSpace); } } else if (collectionSource.MasterObjectType == typeof(PurchaseOrder)) { PurchaseOrder masterobject = (PurchaseOrder)collectionSource.MasterObject; PurchaseOrderDetail currentobject = (PurchaseOrderDetail)e.CreatedObject; copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey); if (sDtl != null) { copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace); } } else if (collectionSource.MasterObjectType == typeof(PurchaseRequest)) { PurchaseRequest masterobject = (PurchaseRequest)collectionSource.MasterObject; PurchaseRequestDetail currentobject = (PurchaseRequestDetail)e.CreatedObject; copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; if (masterobject.DocCur != null) { currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey); } if (sDtl != null) { copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace); } } else if (collectionSource.MasterObjectType == typeof(PurchaseDelivery)) { PurchaseDelivery masterobject = (PurchaseDelivery)collectionSource.MasterObject; PurchaseDeliveryDetail currentobject = (PurchaseDeliveryDetail)e.CreatedObject; copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; if (masterobject.DocCur != null) { currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey); } if (sDtl != null) { copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace); } } else if (collectionSource.MasterObjectType == typeof(PurchaseReturn)) { PurchaseReturn masterobject = (PurchaseReturn)collectionSource.MasterObject; PurchaseReturnDetail currentobject = (PurchaseReturnDetail)e.CreatedObject; copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; if (masterobject.DocCur != null) { currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey); } if (sDtl != null) { copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace); } } else if (collectionSource.MasterObjectType == typeof(PurchaseQuotation)) { PurchaseQuotation masterobject = (PurchaseQuotation)collectionSource.MasterObject; PurchaseQuotationDetail currentobject = (PurchaseQuotationDetail)e.CreatedObject; copyCon.GetDetailClassVisOrder(masterobject, ref minvalue, ref maxvisorder); currentobject.Oid = minvalue; currentobject.VisOrder = maxvisorder; if (masterobject.DocCur != null) { currentobject.DocCur = currentobject.Session.GetObjectByKey <vwCurrency>(masterobject.DocCur.BoKey); } if (sDtl != null) { copyCon.copyClassDocumentDetail(sDtl, currentobject, e.ObjectSpace); } } } } sDtl = null; sDtlS = null; }
/// <summary> /// This method is used to convert the Purchase quotation to order /// </summary> /// <param name="quotationData"></param> /// <returns></returns> public int ConvertToPurchaseOrder(PurchaseQuotationForm quotationData) { int autoId = 0; PurchaseOrder obj = new PurchaseOrder(); //obj.ID = quotationData.Quotation.ID; obj.Sup_Id = quotationData.Quotation.SupplierID; obj.PO_Date = quotationData.Quotation.QuotationDate; obj.PO_Del_Date = DateTime.Now; obj.PO_GST_Amt = Convert.ToDecimal(quotationData.Quotation.TotalTax); obj.PO_No = "PO-" + (GetLastOrderNo() + 1); obj.PO_TandC = quotationData.Quotation.TermsAndConditions; obj.PO_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax); obj.PO_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax); obj.PO_Status = Convert.ToByte(PO_Status.unDeposited); obj.Exc_Inc_GST = quotationData.Quotation.ExcIncGST; obj.IsDeleted = false; try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { if (entities.PurchaseOrders.AsNoTracking().FirstOrDefault(x => x.ID == quotationData.Quotation.ID) == null) { //obj.CreatedBy = quotationData.PQModel.CreatedBy; obj.CreatedDate = DateTime.Now; entities.PurchaseOrders.Add(obj); entities.SaveChanges(); autoId = obj.ID; } else { // obj.ModifiedBy = quotationData.PQModel.ModifiedBy; obj.ModifiedDate = DateTime.Now; entities.Entry(obj).State = EntityState.Modified; autoId = entities.SaveChanges(); } if (autoId > 0) { PurchaseOrderDetail PQDetails; if (quotationData.QuotationDetails != null) { foreach (PurchaseQuotationDetailEntity PQDetailEntity in quotationData.QuotationDetails) { PQDetails = new PurchaseOrderDetail(); PQDetails.PO_ID = autoId; PQDetails.PO_No = PQDetailEntity.PQNo; PQDetails.PandS_Code = PQDetailEntity.PandSCode; PQDetails.PandS_Name = PQDetailEntity.PandSName; PQDetails.PO_Amount = PQDetailEntity.PQAmount; PQDetails.PO_Discount = PQDetailEntity.PQDiscount; PQDetails.PO_No = PQDetailEntity.PQNo; PQDetails.PO_Price = Convert.ToDecimal(PQDetailEntity.PQPrice); PQDetails.PO_Qty = PQDetailEntity.PQQty; PQDetails.GST_Code = PQDetailEntity.GSTCode; PQDetails.GST_Rate = PQDetailEntity.GSTRate; if (entities.PurchaseOrderDetails.AsNoTracking().FirstOrDefault(x => x.ID == PQDetailEntity.ID) == null) { entities.PurchaseOrderDetails.Add(PQDetails); entities.SaveChanges(); } else { entities.Entry(PQDetails).State = EntityState.Modified; entities.SaveChanges(); } } } PurchaseQuotation objQ = entities.PurchaseQuotations.Where(e => e.PQ_No == quotationData.Quotation.QuotationNo ).SingleOrDefault(); if (objQ != null) { objQ.PQ_Conv_to_PO = true; objQ.Conv_to_No = obj.PO_No; objQ.ModifiedDate = DateTime.Now; entities.SaveChanges(); } } } return(autoId); } catch (Exception ex) { throw ex; } }
/// <summary> /// This method is used to add or edit purchase quotation /// </summary> /// <param name="quotationData"></param> /// <returns></returns> public int AddUpdateQuotation(PurchaseQuotationForm quotationData) { int autoId = 0; //Add purchase quotation PurchaseQuotation obj = new PurchaseQuotation(); obj.ID = quotationData.Quotation.ID; obj.Sup_Id = quotationData.Quotation.SupplierID; obj.PQ_Conv_to_PO = quotationData.Quotation.PQ_Conv_to_PO; obj.PQ_Conv_to_PI = quotationData.Quotation.PQ_Conv_to_PI; //obj.PQ_Date = quotationData.Quotation.QuotationDate; obj.PQ_Date = quotationData.Quotation.QuotationDate; obj.PQ_GST_Amt = Convert.ToDecimal(quotationData.Quotation.TotalTax); obj.PQ_No = quotationData.Quotation.QuotationNo; obj.PQ_TandC = quotationData.Quotation.TermsAndConditions; obj.PQ_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax); obj.PQ_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax); obj.PQ_Valid_for = quotationData.Quotation.ValidForDays; obj.Exc_Inc_GST = quotationData.Quotation.ExcIncGST; obj.IsDeleted = false; try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { if (entities.PurchaseQuotations.AsNoTracking().FirstOrDefault(x => x.ID == quotationData.Quotation.ID) == null) { //obj.CreatedBy = quotationData.PQModel.CreatedBy; obj.CreatedDate = DateTime.Now; entities.PurchaseQuotations.Add(obj); entities.SaveChanges(); autoId = obj.ID; } else { // obj.ModifiedBy = quotationData.PQModel.ModifiedBy; obj.ModifiedDate = DateTime.Now; entities.Entry(obj).State = EntityState.Modified; autoId = entities.SaveChanges(); } if (autoId > 0) { PurchaseQuotationDetail PQDetails; if (quotationData.QuotationDetails != null) { foreach (PurchaseQuotationDetailEntity PQDetailEntity in quotationData.QuotationDetails) { PQDetails = new PurchaseQuotationDetail(); PQDetails.PQ_ID = autoId; PQDetails.PQ_No = PQDetailEntity.PQNo; PQDetails.PandS_Code = PQDetailEntity.PandSCode; PQDetails.PandS_Name = PQDetailEntity.PandSName; PQDetails.PQ_Amount = PQDetailEntity.PQAmount; PQDetails.PQ_Discount = PQDetailEntity.PQDiscount; PQDetails.PQ_No = PQDetailEntity.PQNo; PQDetails.PQ_Price = Convert.ToDecimal(PQDetailEntity.PQPrice); PQDetails.PQ_Qty = PQDetailEntity.PQQty; PQDetails.GST_Code = PQDetailEntity.GSTCode; PQDetails.GST_Rate = PQDetailEntity.GSTRate; if (entities.PurchaseQuotationDetails.AsNoTracking().FirstOrDefault(x => x.ID == PQDetailEntity.ID) == null) { entities.PurchaseQuotationDetails.Add(PQDetails); entities.SaveChanges(); } else { entities.Entry(PQDetails).State = EntityState.Modified; entities.SaveChanges(); } } } } } return(autoId); } catch (Exception ex) { throw ex; } }
public int UpdationQuotation(PurchaseQuotationForm quotationData) { try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { PurchaseQuotation obj = entities.PurchaseQuotations.Where(e => e.PQ_No == quotationData.Quotation.QuotationNo ).SingleOrDefault(); if (obj != null) { //obj.ID = quotationData.Quotation.ID; obj.Sup_Id = quotationData.Quotation.SupplierID; // obj.PQ_Conv_to_PO = quotationData.Quotation.PQ_Conv_to_PO; // obj.PQ_Conv_to_PI = quotationData.Quotation.PQ_Conv_to_PI; obj.PQ_Date = Convert.ToDateTime(quotationData.Quotation.QuotationDateStr); obj.PQ_GST_Amt = Convert.ToDecimal(quotationData.Quotation.TotalTax); obj.PQ_No = quotationData.Quotation.QuotationNo; obj.PQ_TandC = quotationData.Quotation.TermsAndConditions; obj.PQ_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax); obj.PQ_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax); obj.PQ_Valid_for = quotationData.Quotation.ValidForDays; obj.Exc_Inc_GST = quotationData.Quotation.ExcIncGST; obj.ModifiedDate = DateTime.Now; entities.SaveChanges(); } var objPurchase = entities.PurchaseQuotationDetails.Where (e => e.PQ_ID == obj.ID).ToList(); if (objPurchase != null) { foreach (var item in objPurchase) { entities.PurchaseQuotationDetails.Remove(item); entities.SaveChanges(); } } PurchaseQuotationDetail PQDetails; if (quotationData.QuotationDetails != null) { foreach (PurchaseQuotationDetailEntity PQDetailEntity in quotationData.QuotationDetails) { PQDetails = new PurchaseQuotationDetail(); PQDetails.PQ_ID = obj.ID; PQDetails.PQ_No = PQDetailEntity.PQNo; PQDetails.PandS_Code = PQDetailEntity.PandSCode; PQDetails.PandS_Name = PQDetailEntity.PandSName; PQDetails.PQ_Amount = PQDetailEntity.PQAmount; PQDetails.PQ_Discount = PQDetailEntity.PQDiscount; PQDetails.PQ_No = PQDetailEntity.PQNo; PQDetails.PQ_Price = Convert.ToDecimal(PQDetailEntity.PQPrice); PQDetails.PQ_Qty = PQDetailEntity.PQQty; PQDetails.GST_Code = PQDetailEntity.GSTCode; PQDetails.GST_Rate = PQDetailEntity.GSTRate; entities.PurchaseQuotationDetails.Add(PQDetails); entities.SaveChanges(); } } return(obj.ID); } } catch (Exception ex) { throw ex; } }