public void DeleteTcByID(int ID) { TechnologicalCard technologicalCard = dataContext.TechonologicalCards.FirstOrDefault(tc => tc.ID == ID); if (technologicalCard != null) { dataContext.TechonologicalCards.Remove(technologicalCard); dataContext.SaveChanges(); } }
public void DeleteTcByID(string CardNumber) { TechnologicalCard technologicalCard = dataContext.TechonologicalCards.FirstOrDefault(tc => tc.TechCardNumber == CardNumber); if (technologicalCard != null) { dataContext.TechonologicalCards.Remove(technologicalCard); dataContext.SaveChanges(); } }
public void UpdateTcByID(TechnologicalCard card) { TechnologicalCard technologicalCard = dataContext.TechonologicalCards.FirstOrDefault(tc => tc.ID == card.ID || tc.TechCardNumber == card.TechCardNumber); if (technologicalCard != null) { technologicalCard.TechCardNumber = card.TechCardNumber; technologicalCard.Responsible = card.Responsible; technologicalCard.ResponsibleForPrint = card.ResponsibleForPrint; technologicalCard.DateUpdated = DateTime.UtcNow; dataContext.SaveChanges(); } }
private void buttonOK_Click(object sender, EventArgs e) { TechnologicalCard techCard = new TechnologicalCard(); techCard.Title = textBox1.Text; techCard.Date = dateTimePicker1.Value.Date; List <ProductTechCard> productTechCardList = new List <ProductTechCard>(); ObjectComboBox objPr1 = (ObjectComboBox)comboBoxProductsImport.SelectedItem; ProductTechCard product = new ProductTechCard(); product.ProductId = objPr1.Id; int amount = 0; Int32.TryParse(textBoxAmountImport.Text, out amount); product.Amount = amount; product.Type = 1; productTechCardList.Add(product); product = new ProductTechCard(); objPr1 = (ObjectComboBox)comboBoxProductsExport.SelectedItem; product.ProductId = objPr1.Id; amount = 0; Int32.TryParse(textBoxAmountExport.Text, out amount); product.Amount = amount; product.Type = 2; productTechCardList.Add(product); techCard.ProductTechCards = productTechCardList; if (Id == -1) { query.queryAddTechCard(techCard); } else { techCard.Id = Id; query.queryUpdateTechCard(techCard); } instance.refreshGrid(); this.Dispose(); }
public TechnologicalCard GetTcByCardNumber(string CardNumber) { TechnologicalCard technologicalCard = dataContext.TechonologicalCards.Include(tc => tc.Blocks).FirstOrDefault(tc => tc.TechCardNumber == CardNumber); return(technologicalCard != null ? technologicalCard : null); }
public TechnologicalCard GetTcByID(int ID) { TechnologicalCard technologicalCard = dataContext.TechonologicalCards.Include(tc => tc.Blocks).FirstOrDefault(tc => tc.ID == ID); return(technologicalCard != null ? technologicalCard : null); }
public void AddTC(TechnologicalCard TC) { dataContext.TechonologicalCards.Add(TC); dataContext.SaveChangesAsync(); }
public TechnologicalCard ParseTechnoCard() { if (String.IsNullOrEmpty(this.FilePath)) { return(null); } TechnologicalCard technologicalCard = null; Excel.Application xlApp = null; Excel.Workbook xlWorkbook = null; Excel._Worksheet xlWorksheet = null; Excel.Range xlRange = null; try { xlApp = new Excel.Application(); xlWorkbook = xlApp.Workbooks.Open(this.FilePath); xlWorksheet = xlWorkbook.Sheets[1]; xlRange = xlWorksheet.UsedRange; if (!validateFile(xlRange)) { throw new Exception(); } int rowCount = xlRange.Rows.Count; int colCount = xlRange.Columns.Count; technologicalCard = new TechnologicalCard(); technologicalCard.Id = validateCell(xlRange, map.Mapping["Id"].I, map.Mapping["Id"].J) ? xlRange.Cells[map.Mapping["Id"].I, map.Mapping["Id"].J].Value.ToString() : ""; technologicalCard.Brigade = validateCell(xlRange, map.Mapping["Brigade"].I, map.Mapping["Brigade"].J) ? xlRange.Cells[map.Mapping["Brigade"].I, map.Mapping["Brigade"].J].Value.ToString() : ""; technologicalCard.Date = validateCell(xlRange, map.Mapping["Date"].I, map.Mapping["Date"].J) ? xlRange.Cells[map.Mapping["Date"].I, map.Mapping["Date"].J].Value.ToString() : ""; technologicalCard.OfficialPerson = validateCell(xlRange, map.Mapping["OfficialPerson"].I, map.Mapping["OfficialPerson"].J) ? xlRange.Cells[map.Mapping["OfficialPerson"].I, map.Mapping["OfficialPerson"].J].Value.ToString() : ""; technologicalCard.OfficialForPrinting = validateCell(xlRange, map.Mapping["OfficialForPrinting"].I, map.Mapping["OfficialForPrinting"].J) ? xlRange.Cells[map.Mapping["OfficialForPrinting"].I, map.Mapping["OfficialForPrinting"].J].Value.ToString() : ""; for (int i = map.Mapping["BlockId"].I; i <= rowCount; i++) { Entities.Block block = new Entities.Block(); block.BlockId = validateCell(xlRange, i, map.Mapping["BlockId"].J) ? xlRange.Cells[i, map.Mapping["BlockId"].J].Value.ToString() : ""; block.CuttingType = validateCell(xlRange, i, map.Mapping["CuttingType"].J) ? xlRange.Cells[i, map.Mapping["CuttingType"].J].Value.ToString() : ""; block.AdditionalInfo = validateCell(xlRange, i, map.Mapping["AdditionalInfo"].J) ? xlRange.Cells[i, map.Mapping["AdditionalInfo"].J].Value.ToString() : ""; block.Door1 = validateCell(xlRange, i, map.Mapping["Door1"].J) ? xlRange.Cells[i, map.Mapping["Door1"].J].Value.ToString() : ""; block.Door2 = validateCell(xlRange, i, map.Mapping["Door2"].J) ? xlRange.Cells[i, map.Mapping["Door2"].J].Value.ToString() : ""; block.DoorBox = validateCell(xlRange, i, map.Mapping["DoorBox"].J) ? xlRange.Cells[i, map.Mapping["DoorBox"].J].Value.ToString() : ""; block.Hinge1 = validateCell(xlRange, i, map.Mapping["Hinge1"].J) ? xlRange.Cells[i, map.Mapping["Hinge1"].J].Value.ToString() : ""; block.Hinge2 = validateCell(xlRange, i, map.Mapping["Hinge2"].J) ? xlRange.Cells[i, map.Mapping["Hinge2"].J].Value.ToString() : ""; block.HingeCount = validateCell(xlRange, i, map.Mapping["HingeCount"].J) ? xlRange.Cells[i, map.Mapping["HingeCount"].J].Value.ToString() : ""; block.LockType = validateCell(xlRange, i, map.Mapping["LockType"].J) ? xlRange.Cells[i, map.Mapping["LockType"].J].Value.ToString() : ""; block.InsertingSecret = validateCell(xlRange, i, map.Mapping["InsertingSecret"].J) ? xlRange.Cells[i, map.Mapping["InsertingSecret"].J].Value.ToString() : ""; block.DoorStep = validateCell(xlRange, i, map.Mapping["DoorStep"].J) ? xlRange.Cells[i, map.Mapping["DoorStep"].J].Value.ToString() : ""; block.Note = validateCell(xlRange, i, map.Mapping["Note"].J) ? xlRange.Cells[i, map.Mapping["Note"].J].Value.ToString() : ""; block.OrderNumber = validateCell(xlRange, i, map.Mapping["OrderNumber"].J) ? xlRange.Cells[i, map.Mapping["OrderNumber"].J].Value.ToString() : ""; technologicalCard.Blocks.Add(block); } } catch { technologicalCard = null; } finally { GC.Collect(); GC.WaitForPendingFinalizers(); Marshal.ReleaseComObject(xlRange); Marshal.ReleaseComObject(xlWorksheet); xlWorkbook.Close(); Marshal.ReleaseComObject(xlWorkbook); xlApp.Quit(); Marshal.ReleaseComObject(xlApp); } return(technologicalCard); }