public bool SimpanDataBatch(batchtbl newData, IEnumerable <string> OrderNos) { try { HashSet <string> Orders = new HashSet <string>(); OrderNos.ToList().ForEach(x => Orders.Add(x)); using (var context = new smlpobDB()) { context.batchtbls.Add(newData); var datas = from x in context.ordermastertbls where Orders.Contains(x.orderNo) select x; foreach (var item in datas) { item.batchId = newData.batchId; item.status = "Proses Lab"; } context.SaveChanges(); return(true); } } catch (Exception ex) { LogHelpers.source = this.GetType().Name; LogHelpers.message = ex.Message; LogHelpers.user = ""; LogHelpers.WriteLog(); } return(false); }
void SimpanData() { var LastNum = CounterGen.Increment("BATCHNO"); var NewBatchNo = GenerateNoBatch(LastNum); var curDate = DateTime.Now; var newBatch = new batchtbl() { status = "Proses", batchId = NewBatchNo, creaBy = CommonWeb.GetCurrentUser(), creaDate = curDate, modBy = CommonWeb.GetCurrentUser(), modDate = curDate, pic_analis = Convert.ToInt32(CmbPIC.SelectedValue), pic_penyelia = CommonWeb.GetCurrentEmployeeNo() }; var listOrderNo = new List <string>(); foreach (GridViewRow row in GvData.Rows) { var chk = row.FindControl("ChkPilih") as CheckBox; if (chk != null && chk.Checked) { var orderNo = row.Cells[1].Text; listOrderNo.Add(orderNo); } } if (listOrderNo.Count > 0) { var res = orderControls.SimpanDataBatch(newBatch, listOrderNo); if (res) { Response.Redirect("DaftarPesanan.aspx"); } } else { CommonWeb.Alert(this, "Silakan pilih order terlebih dahulu"); } }