private void Search() { try { dgvOrderSearch.DataSource = null; CO order = new CO(); order.CustomerOrderNo = txtOrderNo.Text.Trim(); order.LogNo = txtLogNo.Text.Trim(); order.InvoiceNo = txtInvoiceNo.Text.ToString(); if (dtpFromDate.Checked) { order.FromDate = dtpFromDate.Value.ToString(); } else { order.FromDate = Common.DATETIME_NULL.ToShortDateString(); } if (dtpTodate.Checked) { order.ToDate = dtpTodate.Value.ToString(); } else { order.ToDate = Common.DATETIME_NULL.ToShortDateString(); } order.Status = Convert.ToInt32(cmbStatus.SelectedValue); order.DistributorId = string.IsNullOrEmpty(txtDistributorNo.Text) == true? -1:Convert.ToInt32(txtDistributorNo.Text.Trim()); order.PCId = Convert.ToInt32(cmbStockPoint.SelectedValue); string errorMessage = string.Empty; m_orderSearchList = order.Search(ref errorMessage); BindGrid(); } catch (Exception ex) { throw ex; } }
public bool ProcessLog(string logNo, int LocationID, int userID, ref String ErrorCode, ref DataTable dtItems) { try { bool isSuccess = false; bool isValid = true; string errorMessage = string.Empty; //Check Batch Qty Not Available for all Items of orders isValid = CI.CheckBatchForLog(logNo, LocationID, ref errorMessage, ref dtItems); if (isValid) { List <CI> CIList = new List <CI>(); CO order = new CO(); order.LogNo = logNo; order.Status = (int)Common.OrderStatus.Confirmed; errorMessage = string.Empty; List <CO> lstCo = order.Search(ref errorMessage); if (errorMessage.Equals(string.Empty) && lstCo != null && lstCo.Count > 0) { DataTaskManager dtManager = null; try { using (dtManager = new DataTaskManager()) { dtManager.BeginTransaction(); try { foreach (CO o in lstCo) { CO m_Order = new CO(); m_Order.GetCOAllDetails(o.CustomerOrderNo, -1); errorMessage = string.Empty; List <CIBatchDetail> ListBatch = CIBatchDetail.GetDefaultBatch(m_Order.CustomerOrderNo, LocationID, ref errorMessage); CI invoice = CreateInvoiceObject(m_Order, ListBatch, userID); if (invoice != null) { string ValidationCode = string.Empty; isValid = invoice.ValidateInvoice(m_Order.CODetailList, ListBatch, ref ValidationCode); if (isValid) { bool isSaved = invoice.Save(ref ValidationCode); if (!isSaved) { isSuccess = false; dtManager.RollbackTransaction(); } } else { if (ValidationCode == "40007") { // Not sufficent Batch Qty present ErrorCode = "40008"; } else { ErrorCode = ValidationCode; } isSuccess = false; dtManager.RollbackTransaction(); break; } } else { ErrorCode = "40029," + m_Order.CustomerOrderNo; isSuccess = false; dtManager.RollbackTransaction(); break; } } dtManager.CommitTransaction(); ErrorCode = string.Empty; isSuccess = true; } catch (Exception ex) { throw ex; } } } catch (Exception ex) { Common.LogException(ex); } } else { //No Order found in confirmed status ErrorCode = "40011"; } } // Error in batch qty check else if (!errorMessage.Trim().Equals(string.Empty)) { if (errorMessage.Trim().IndexOf("30001:") >= 0) { throw new Exception(errorMessage.Trim()); } else { ErrorCode = errorMessage.Trim(); } } return(isSuccess); } catch (Exception ex) { throw ex; } }