private void assertInvoiceAlreadyGenerated(DeliveryOrderItem item) { m_command.CommandText = CustomerInvoiceItem.GetDOUseByCustomerInvoice(item.ID); MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader(); IList invs = CustomerInvoiceItem.TransformReaderList(r); r.Close(); foreach (CustomerInvoiceItem x in invs) { m_command.CommandText = CustomerInvoice.GetByIDSQL(x.EVENT.ID); r = m_command.ExecuteReader(); x.EVENT = CustomerInvoice.TransformReader(r); r.Close(); } if (invs.Count > 0) { throw new Exception("DO Part [" + item.PART.CODE + "] is used by Customer Invoice [" + ((CustomerInvoiceItem)invs[0]).EVENT.CODE + "], please delete customer invoice first."); } }
public IList FindDOItemlistByCustomerDate(string find, int supID, DateTime trdate, IList doIDS) { m_command.CommandText = CustomerInvoiceItem.GetDOUseByCustomerInvoice(); MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader(); if (r.HasRows) { while (r.Read()) { int id = Convert.ToInt32(r[0]); if (!doIDS.Contains(id)) { doIDS.Add(id); } } } r.Close(); StringBuilder poisSB = new StringBuilder(); foreach (int i in doIDS) { poisSB.Append(i.ToString()); poisSB.Append(','); } string pois = poisSB.ToString(); pois = doIDS.Count > 0 ? pois.Substring(0, pois.Length - 1) : ""; if (find == "") { m_command.CommandText = DeliveryOrderItem.GetDOItemByCusDate(supID, trdate, pois); } else { m_command.CommandText = DeliveryOrderItem.GetSearchByPartAndDONo(find, supID, pois, trdate); } r = m_command.ExecuteReader(); IList result = DeliveryOrderItem.TransformReaderList(r); r.Close(); foreach (DeliveryOrderItem t in result) { m_command.CommandText = DeliveryOrder.GetByIDSQL(t.EVENT.ID); r = m_command.ExecuteReader(); t.EVENT = DeliveryOrder.TransformReader(r); r.Close(); m_command.CommandText = Part.GetByIDSQLStatic(t.PART.ID); r = m_command.ExecuteReader(); t.PART = Part.GetPart(r); r.Close(); m_command.CommandText = Unit.GetByIDSQLstatic(t.UNIT.ID); r = m_command.ExecuteReader(); t.UNIT = Unit.GetUnit(r); r.Close(); m_command.CommandText = Warehouse.GetByIDSQLStatic(t.WAREHOUSE.ID); r = m_command.ExecuteReader(); t.WAREHOUSE = Warehouse.GetWarehouse(r); r.Close(); m_command.CommandText = Unit.GetByIDSQLstatic(t.PART.UNIT.ID); r = m_command.ExecuteReader(); t.PART.UNIT = Unit.GetUnit(r); r.Close(); } return(result); }