public static bool Update(AssemblyIncentiveModel model) { var @Id = new SqlParameter("@Id", model.Id); var @PatternNo = new SqlParameter("@PatternNo", model.PatternNo); var @ShoeName = new SqlParameter("@ShoeName", model.ShoeName); var @Efficiency = new SqlParameter("@Efficiency", model.Efficiency); var @AssemblyOutput = new SqlParameter("@AssemblyOutput", model.AssemblyOutput); var @Incentive = new SqlParameter("@Incentive", model.Incentive); SaovietCheckInEntities db = new SaovietCheckInEntities(); if (db.ExecuteStoreCommand("EXEC spm_UpdateAssemblyIncentive @Id, @PatternNo, @ShoeName, @Efficiency, @AssemblyOutput, @Incentive", @Id, @PatternNo, @ShoeName, @Efficiency, @AssemblyOutput, @Incentive) >= 1) { return(true); } return(false); }
private void bwLoadExcelData_DoWork(object sender, DoWorkEventArgs e) { Excel.Application excelApplication = new Excel.Application(); Excel.Workbook excelWorkbook = excelApplication.Workbooks.Open(filePath); //excelApplication.Visible = true; Excel.Worksheet excelWorksheet; Excel.Range excelRange; try { excelWorksheet = (Excel.Worksheet)excelWorkbook.Worksheets[1]; excelRange = excelWorksheet.UsedRange; string patternNo = ""; patternNo = GetString.GetPatternNoFromFilePath(filePath); if (patternNo == "") { MessageBox.Show("Có Lỗi Xảy Ra Khi Lấy PM. Kiểm Tra Tên ExcelFile !!", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning); return; } string shoeName = ""; shoeName = GetString.GetShoeNameFromFilePath(filePath); if (shoeName == "") { MessageBox.Show("Có Lỗi Xảy Ra Khi Lấy ShoeName. Kiểm Tra Tên ExcelFile !!", "Thông Báo", MessageBoxButton.OK, MessageBoxImage.Warning); return; } for (int i = 2; i <= excelRange.Rows.Count; i++) { AssemblyIncentiveModel assemblyIncentive = new AssemblyIncentiveModel(); assemblyIncentive.ShoeName = shoeName; assemblyIncentive.PatternNo = patternNo; var efficiencyValue = (excelRange.Cells[i, 1] as Excel.Range).Value2; string efficiencyString = ""; double efficiency = 0; if (efficiencyValue != null) { efficiencyString = efficiencyValue.ToString(); double.TryParse(efficiencyString, out efficiency); } assemblyIncentive.Efficiency = efficiency; var outputValue = (excelRange.Cells[i, 2] as Excel.Range).Value2; string outputString = ""; double output = 0; if (outputValue != null) { outputString = outputValue.ToString(); Double.TryParse(outputString, out output); } assemblyIncentive.AssemblyOutput = (int)Math.Round(output, MidpointRounding.AwayFromZero); var incentiveValue = (excelRange.Cells[i, 3] as Excel.Range).Value2; string incentiveString = ""; int incentive = 0; if (incentiveValue != null) { incentiveString = incentiveValue.ToString(); Int32.TryParse(incentiveString, out incentive); } assemblyIncentive.Incentive = incentive; var workerValue = (excelRange.Cells[i, 4] as Excel.Range).Value2; string workerString = ""; int worker = 0; if (workerValue != null) { workerString = workerValue.ToString(); Int32.TryParse(workerString, out worker); } assemblyIncentive.Worker = worker; assemblyIncentiveViewList.Add(assemblyIncentive); } } catch { assemblyIncentiveViewList.Clear(); } finally { excelWorkbook.Close(false, Missing.Value, Missing.Value); excelApplication.Quit(); } }