private void Window_Closed(object sender, EventArgs e) { if (componentObj != null) { componentObj = null; } }
public void SaveComp2(CS_CustQuotasComponent comp) { try { comp.R1Costvalue = string.IsNullOrEmpty(comp.R1Costvalue.ToString()) ? 0 : comp.R1Costvalue; string sql = @"INSERT INTO CS_CustQuotasComponent ( Id, Line, BOM, Item, Component, Description, UoM, Qty, Obs, Drawing, R1CostValue, PathFile1, PathFile2, PathFile3, TBCreated, TBModified, TBCreatedID, TecConclusion2, DrawingComponent, CostValue, IsItemNew, IsItemRetired )" + $" VALUES ( {comp.Id}, {comp.Line}, '{comp.BOM}', '{comp.Item}', '{comp.Component}'," + $"'{comp.Description}', '{comp.UoM}', {comp.Qty.ToString().Replace(",", ".")}, '{comp.Obs}'," + $"'{comp.Drawing}', {comp.R1Costvalue.ToString().Replace(",", ".")}, '{comp.PathFile1}'," + $"'{comp.PathFile2}', '{comp.PathFile3}', '{comp.TBCreated}', '{comp.TBModified}', {comp.TBCreatedID}," + $"'{comp.TecConclusion2}', '{comp.DrawingComponent}', {comp.Costvalue.ToString().Replace(",", ".")}, '{ comp.IsItemNew }', '{ comp.IsItemRetired }')"; conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.ExecuteNonQuery(); conn.Close(); } catch (Exception ex) { conn.Close(); throw ex; } }
public ItemsView(SimulationEDP window) { InitializeComponent(); componentObj = new CS_CustQuotasComponent(); _mainWindow = window; itemsService = new ItemsService(); opService = new OperationService(); bomService = new BOMService(); LoadGrid(); NotVisibleIsSpecific(); }
public List <CS_CustQuotasComponent> GetSimulationComponents2_2(int id, string item) { //return _context.CS_CustQuotasComponent.Where(x => x.Id == id && x.BOM == item).ToList(); ; List <CS_CustQuotasComponent> list = new List <CS_CustQuotasComponent>(); try { conn.Open(); string sql = $"SELECT *, ISNULL((SELECT ISNULL(StandardCost, 0) FROM MA_ItemsFiscalYearData WHERE Item = CQ.Component AND CQ.Component NOT LIKE '%OUTROS%' AND FiscalYear = DATEPART(YEAR, GETDATE())) * CQ.Qty, 0) AS Cost FROM CS_CustQuotasComponent CQ WHERE Id = { id } AND BOM = '{ item }'"; SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { CS_CustQuotasComponent comp = new CS_CustQuotasComponent(); comp.Id = Convert.ToInt32(reader["Id"]); comp.Line = Convert.ToInt32(reader["Line"]); comp.Item = reader["Item"].ToString(); comp.Obs = reader["Obs"].ToString(); comp.Component = reader["Component"].ToString(); if (reader["Component"].ToString().Equals("OUTROS", StringComparison.OrdinalIgnoreCase)) { comp.Costvalue = string.IsNullOrEmpty(reader["CostValue"].ToString()) ? 0 : Convert.ToDouble(reader["CostValue"]); } else { comp.Costvalue = string.IsNullOrEmpty(reader["Cost"].ToString()) ? 0 : Convert.ToDouble(reader["Cost"]); } comp.BOM = reader["BOM"].ToString(); comp.Description = reader["Description"].ToString(); comp.Drawing = reader["Drawing"].ToString(); comp.DrawingComponent = reader["DrawingComponent"].ToString(); comp.PathFile1 = reader["PathFile1"].ToString(); comp.PathFile2 = reader["PathFile2"].ToString(); comp.PathFile3 = reader["PathFile2"].ToString(); comp.Qty = string.IsNullOrEmpty(reader["Qty"].ToString()) ? 0 : Convert.ToDouble(reader["Qty"]); comp.R1Costvalue = string.IsNullOrEmpty(reader["R1Costvalue"].ToString()) ? 0 : Convert.ToDouble(reader["R1Costvalue"]); comp.TecConclusion = reader["TecConclusion"].ToString(); comp.TecConclusion2 = reader["TecConclusion2"].ToString(); comp.UoM = reader["UoM"].ToString(); list.Add(comp); } conn.Close(); reader.Close(); return(list); } catch (Exception ex) { conn.Close(); throw ex; } }
public List <CS_CustQuotasComponent> GetAllSimulations() { //return _context.CS_CustQuotasComponent.Where(x => x.Id == id && x.Item == item).ToList(); List <CS_CustQuotasComponent> list = new List <CS_CustQuotasComponent>(); try { conn.Open(); string sql = $"SELECT * FROM CS_CustQuotasComponent"; SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { CS_CustQuotasComponent comp = new CS_CustQuotasComponent(); comp.Id = Convert.ToInt32(reader["Id"]); comp.Line = Convert.ToInt32(reader["Line"]); comp.Item = reader["Item"].ToString(); comp.Obs = reader["Obs"].ToString(); comp.Component = reader["Component"].ToString(); comp.Costvalue = string.IsNullOrEmpty(reader["Costvalue"].ToString()) ? 0 : Convert.ToDouble(reader["Costvalue"]); comp.BOM = reader["BOM"].ToString(); comp.Description = reader["Description"].ToString(); comp.Drawing = reader["Drawing"].ToString(); comp.DrawingComponent = reader["DrawingComponent"].ToString(); comp.PathFile1 = reader["PathFile1"].ToString(); comp.PathFile2 = reader["PathFile2"].ToString(); comp.PathFile3 = reader["PathFile2"].ToString(); comp.Qty = string.IsNullOrEmpty(reader["Qty"].ToString()) ? 0 : Convert.ToDouble(reader["Qty"]); comp.R1Costvalue = string.IsNullOrEmpty(reader["R1Costvalue"].ToString()) ? 0 : Convert.ToDouble(reader["R1Costvalue"]); comp.TecConclusion = reader["TecConclusion"].ToString(); comp.TecConclusion2 = reader["TecConclusion2"].ToString(); comp.UoM = reader["UoM"].ToString(); list.Add(comp); } conn.Close(); reader.Close(); return(list); } catch (Exception ex) { conn.Close(); throw ex; } }
public void SaveComp(CS_CustQuotasComponent comp) { _context.CS_CustQuotasComponent.Add(comp); _context.SaveChanges(); }