public PersonProductUid FindPendingToPack(int SaleOrderLineid) { var temp = from p in db.PersonProductUid join PC in db.PackingLine on p.PersonProductUidId equals PC.PersonProductUidId into PCTable from PCTab in PCTable.DefaultIfEmpty() where p.SaleOrderLineId == SaleOrderLineid && PCTab == null select p; if (temp.Count() > 0) { return(temp.ToList().First()); } else { return(null); } }
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); }