bool JobOrderEvents__beforeLineSaveBylkDataValidation(object sender, JobEventArgs EventArgs, ref ApplicationDbContext db) { var JobOrder = (from H in db.JobOrderHeader join D in db.DocumentType on H.DocTypeId equals D.DocumentTypeId into DocumentTypeTable from DocumentTypeTab in DocumentTypeTable.DefaultIfEmpty() where H.JobOrderHeaderId == EventArgs.DocId select new { DocTypeName = DocumentTypeTab.DocumentTypeName, Status = H.Status }).FirstOrDefault(); if (JobOrder.DocTypeName == "Weaving Order" || JobOrder.DocTypeName == "Weaving Finished Order" && JobOrder.Status != 0) { var Temp = (from L in db.JobOrderLine join Pol in db.ProdOrderLine on L.ProdOrderLineId equals Pol.ProdOrderLineId into ProdOrderLineTable from ProdOrderLineTab in ProdOrderLineTable.DefaultIfEmpty() join Poh in db.ProdOrderHeader on ProdOrderLineTab.ProdOrderHeaderId equals Poh.ProdOrderHeaderId into ProdOrderHeaderTable from ProdOrderHeaderTab in ProdOrderHeaderTable.DefaultIfEmpty() join H in db.JobOrderHeader on ProdOrderHeaderTab.ReferenceDocId equals H.JobOrderHeaderId into JobOrderHeaderTable from JobOrderHeaderTab in JobOrderHeaderTable.DefaultIfEmpty() where JobOrderHeaderTab.JobOrderHeaderId == EventArgs.DocId select new { JobOrderHeaderId = JobOrderHeaderTab.JobOrderHeaderId }).FirstOrDefault(); if (Temp != null) { if (Temp.JobOrderHeaderId != null) { throw new Exception("Branch has already issued Weaving Order.You can't add new record."); } } } return(true); }
public IQueryable <ProductUidHeader> GetProductUidHeaderList() { var p = from H in _productUidHeaderRepository.Instance join D in _unitOfWork.Repository <DocumentType>().Instance on H.GenDocTypeId equals D.DocumentTypeId into DocumentTypeTable from DocumentTypeTab in DocumentTypeTable.DefaultIfEmpty() where DocumentTypeTab.DocumentTypeName == MasterDocTypeConstants.ProductUid orderby H.GenDocDate descending, H.ProductUidHeaderId descending select H; return(p); }
public PackingHeaderViewModel GetPackingHeaderViewModel(int id) { PackingHeaderViewModel packingheader = (from H in db.PackingHeader join B in db.Persons on H.BuyerId equals B.PersonID into BuyerTable from BuyerTab in BuyerTable.DefaultIfEmpty() join B in db.Persons on H.JobWorkerId equals B.PersonID into JobWorkerTable from JobWorkerTab in JobWorkerTable.DefaultIfEmpty() join D in db.DocumentType on H.DocTypeId equals D.DocumentTypeId into DocumentTypeTable from DocumentTypeTab in DocumentTypeTable.DefaultIfEmpty() join Div in db.Divisions on H.DivisionId equals Div.DivisionId into DivisionTable from DivisionTab in DivisionTable.DefaultIfEmpty() join S in db.Site on H.SiteId equals S.SiteId into SiteTable from SiteTab in SiteTable.DefaultIfEmpty() join G in db.Godown on H.GodownId equals G.GodownId into GodownTable from GodownTab in GodownTable.DefaultIfEmpty() join Du in db.Units on H.DealUnitId equals Du.UnitId into DeliveryUnitTable from DeliveryUnitTab in DeliveryUnitTable.DefaultIfEmpty() where H.PackingHeaderId == id select new PackingHeaderViewModel { PackingHeaderId = H.PackingHeaderId, DocTypeName = DocumentTypeTab.DocumentTypeName, DocDate = H.DocDate, DocNo = H.DocNo, BuyerId = H.BuyerId, DocTypeId = H.DocTypeId, BuyerName = BuyerTab.Name, JobWorkerId = H.JobWorkerId.Value, JobWorkerName = JobWorkerTab.Name, DivisionId = H.DivisionId, DivisionName = DivisionTab.DivisionName, SiteId = H.SiteId, SiteName = SiteTab.SiteName, GodownId = H.GodownId, GodownName = GodownTab.GodownName, DealUnitId = H.DealUnitId, DealUnitName = DeliveryUnitTab.UnitName, BaleNoPattern = H.BaleNoPattern, ShipMethodId = H.ShipMethodId, Remark = H.Remark, Status = H.Status, CreatedBy = H.CreatedBy, CreatedDate = H.CreatedDate, ModifiedBy = H.ModifiedBy, ModifiedDate = H.ModifiedDate, LockReason = H.LockReason, TotalQty = H.PackingLines.Sum(m => m.Qty), DecimalPlaces = (from o in H.PackingLines join prod in db.Product on o.ProductId equals prod.ProductId join u in db.Units on prod.UnitId equals u.UnitId select u.DecimalPlaces).Max(), }).FirstOrDefault(); return(packingheader); }
void JobOrderEvents__onHeaderSubmit(object sender, JobEventArgs EventArgs, ref ApplicationDbContext db) { int Id = EventArgs.DocId; string ConnectionString = (string)System.Web.HttpContext.Current.Session["DefaultConnectionString"]; try { var JobOrder = (from H in db.JobOrderHeader join D in db.DocumentType on H.DocTypeId equals D.DocumentTypeId into DocumentTypeTable from DocumentTypeTab in DocumentTypeTable.DefaultIfEmpty() where H.JobOrderHeaderId == EventArgs.DocId select new { DocTypeName = DocumentTypeTab.DocumentTypeName, Status = H.Status }).FirstOrDefault(); if (JobOrder.DocTypeName == "Weaving Order" || JobOrder.DocTypeName == "Weaving Finished Order" && JobOrder.Status != 0) { using (SqlConnection sqlConnection = new SqlConnection(ConnectionString)) { sqlConnection.Open(); using (SqlCommand cmd = new SqlCommand("Web.SpUpdate_CostCenterStatusExtendedFromOrder")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = sqlConnection; cmd.Parameters.AddWithValue("@JobOrderHeaderId", Id); cmd.CommandTimeout = 1000; //cmd.Connection.Open(); cmd.ExecuteNonQuery(); //cmd.Connection.Close(); } } } } catch (Exception ex) { //Header.Status = (int)StatusConstants.Drafted; //new JobReceiveHeaderService(_unitOfWork).Update(Header); //_unitOfWork.Save(); throw ex; } try { var JobOrder = (from H in db.JobOrderHeader join D in db.DocumentType on H.DocTypeId equals D.DocumentTypeId into DocumentTypeTable from DocumentTypeTab in DocumentTypeTable.DefaultIfEmpty() join JOL in db.JobOrderLine on H.JobOrderHeaderId equals JOL.JobOrderHeaderId into JOLTable from JOLTab in JOLTable.DefaultIfEmpty() join P in db.Product on JOLTab.ProductId equals P.ProductId into PTable from PTab in PTable.DefaultIfEmpty() join PC in db.ProductCategory on PTab.ProductCategoryId equals PC.ProductCategoryId into PCTable from PCTab in PCTable.DefaultIfEmpty() where H.JobOrderHeaderId == EventArgs.DocId && PCTab.ProductCategoryName == "OVER TUFT" select new { DocTypeName = DocumentTypeTab.DocumentTypeName, Status = H.Status }).FirstOrDefault(); if (JobOrder != null) { using (SqlConnection sqlConnection = new SqlConnection(ConnectionString)) { sqlConnection.Open(); using (SqlCommand cmd = new SqlCommand("Web.sp_CreateCostcenterForOverTuftMain")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = sqlConnection; cmd.Parameters.AddWithValue("@JobOrderHeaderId", Id); cmd.CommandTimeout = 1000; cmd.ExecuteNonQuery(); } } } } catch (Exception ex) { throw ex; } // return Redirect(ReturnUrl); }
public IQueryable <ProductUidHeader> GetProductUidHeaderList() { //var p = _unitOfWork.Repository<ProductUidHeader>().Query().Get().OrderBy(m => m.ProductUidHeaderId) ; var p = from H in db.ProductUidHeader join D in db.DocumentType on H.GenDocTypeId equals D.DocumentTypeId into DocumentTypeTable from DocumentTypeTab in DocumentTypeTable.DefaultIfEmpty() where DocumentTypeTab.DocumentTypeName == MasterDocTypeConstants.ProductUid orderby H.GenDocDate descending, H.ProductUidHeaderId descending select H; return(p); }
public IQueryable <CustomDetailViewModel> GetCustomDetailViewModelForIndex() { IQueryable <CustomDetailViewModel> CustomDetail = from H in db.CustomDetail join s in db.SaleInvoiceHeader on H.SaleInvoiceHeaderId equals s.SaleInvoiceHeaderId into SaleInvoiceHeaderTable from SaleInvoiceHeaderTab in SaleInvoiceHeaderTable.DefaultIfEmpty() join d in db.DocumentType on H.DocTypeId equals d.DocumentTypeId into DocumentTypeTable from DocumentTypeTab in DocumentTypeTable.DefaultIfEmpty() orderby H.CustomDetailId select new CustomDetailViewModel { CustomDetailId = H.CustomDetailId, DocDate = H.DocDate, DocNo = H.DocNo, DocTypeName = DocumentTypeTab.DocumentTypeName, SaleInvoiceHeaderDocNo = SaleInvoiceHeaderTab.DocNo, TRNo = H.TRNo, TRDate = H.TRDate, Remark = H.Remark, }; return(CustomDetail); }
public IQueryable <ComboBoxResult> GetPendingSaleEnquiryHelpList(int Id, string term) { var SaleQuotationHeader = new SaleQuotationHeaderService(_unitOfWork).Find(Id); var settings = new SaleQuotationSettingsService(_unitOfWork).GetSaleQuotationSettingsForDocument(SaleQuotationHeader.DocTypeId, SaleQuotationHeader.DivisionId, SaleQuotationHeader.SiteId); string[] contraDocTypes = null; if (!string.IsNullOrEmpty(settings.filterContraDocTypes)) { contraDocTypes = settings.filterContraDocTypes.Split(",".ToCharArray()); } else { contraDocTypes = new string[] { "NA" }; } string[] contraSites = null; if (!string.IsNullOrEmpty(settings.filterContraSites)) { contraSites = settings.filterContraSites.Split(",".ToCharArray()); } else { contraSites = new string[] { "NA" }; } string[] contraDivisions = null; if (!string.IsNullOrEmpty(settings.filterContraDivisions)) { contraDivisions = settings.filterContraDivisions.Split(",".ToCharArray()); } else { contraDivisions = new string[] { "NA" }; } string[] ProductTypes = null; if (!string.IsNullOrEmpty(settings.filterProductTypes)) { ProductTypes = settings.filterProductTypes.Split(",".ToCharArray()); } else { ProductTypes = new string[] { "NA" }; } int CurrentSiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; int CurrentDivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; var list = (from p in db.ViewSaleEnquiryBalanceForQuotation join t in db.Persons on p.BuyerId equals t.PersonID into table from tab in table.DefaultIfEmpty() join Pt in db.Product on p.ProductId equals Pt.ProductId into ProductTable from ProductTab in ProductTable.DefaultIfEmpty() join Fp in db.FinishedProduct on p.ProductId equals Fp.ProductId into FinishedProductTable from FinishedProductTab in FinishedProductTable.DefaultIfEmpty() join D in db.DocumentType on p.DocTypeId equals D.DocumentTypeId into DocumentTypeTable from DocumentTyoeTab in DocumentTypeTable.DefaultIfEmpty() where (string.IsNullOrEmpty(term) ? 1 == 1 : p.SaleEnquiryNo.ToLower().Contains(term.ToLower())) && p.BalanceQty > 0 && (string.IsNullOrEmpty(settings.filterContraDocTypes) ? 1 == 1 : contraDocTypes.Contains(p.DocTypeId.ToString())) && (string.IsNullOrEmpty(settings.filterContraSites) ? p.SiteId == CurrentSiteId : contraSites.Contains(p.SiteId.ToString())) && (string.IsNullOrEmpty(settings.filterContraDivisions) ? p.DivisionId == CurrentDivisionId : contraDivisions.Contains(p.DivisionId.ToString())) && (string.IsNullOrEmpty(settings.filterProductTypes) ? 1 == 1 : ProductTypes.Contains(ProductTab.ProductGroup.ProductTypeId.ToString())) group new { p, tab.Code, DocumentTyoeTab } by p.SaleEnquiryHeaderId into g orderby g.Max(m => m.p.EnquiryDate) select new ComboBoxResult { text = g.Max(m => m.DocumentTyoeTab.DocumentTypeShortName) + "-" + g.Max(m => m.p.SaleEnquiryNo) + " {" + g.Max(m => m.Code) + "}", id = g.Key.ToString(), }); return(list); }