public int RecordCount() { m_command.CommandText = DeliveryOrder.RecordCount(); int result = Convert.ToInt32(m_command.ExecuteScalar()); return(result); }
public static IList TransformReaderList(MySql.Data.MySqlClient.MySqlDataReader aReader) { IList result = new ArrayList(); while (aReader.Read()) { DeliveryOrder transaction = new DeliveryOrder(); transaction.ID = Convert.ToInt32(aReader["do_id"]); transaction.TRANSACTION_DATE = Convert.ToDateTime(aReader["do_date"]); transaction.NOTICE_DATE = Convert.ToDateTime(aReader["do_noticedate"]); transaction.STOCK_CARD_ENTRY_TYPE = (StockCardEntryType)Enum.Parse(typeof(StockCardEntryType), aReader["do_scentrytype"].ToString()); transaction.EMPLOYEE = new Employee(Convert.ToInt32(aReader["emp_id"])); transaction.NOTES = aReader["do_notes"].ToString(); transaction.POSTED = Convert.ToBoolean(aReader["do_posted"]); transaction.EVENT_STATUS = (EventStatus)Enum.Parse(typeof(EventStatus), aReader["do_eventstatus"].ToString()); transaction.AGAINST_SR_STATUS = (AgainstStatus)Enum.Parse(typeof(AgainstStatus), aReader["do_againstprstatus"].ToString()); transaction.CODE = aReader["do_code"].ToString(); transaction.CUSTOMER = new Customer(Convert.ToInt32(aReader["cus_id"])); transaction.DOCUMENT_NO = aReader["do_docno"].ToString(); transaction.DOCUMENT_DATE = Convert.ToDateTime(aReader["do_docdate"]); transaction.VENDOR = transaction.CUSTOMER; transaction.MODIFIED_BY = aReader["modified_by"].ToString(); transaction.MODIFIED_DATE = Convert.ToDateTime(aReader["modified_date"].ToString()); transaction.MODIFIED_COMPUTER_NAME = aReader["modified_computer"].ToString(); result.Add(transaction); } return(result); }
private EventStatus getEventStatus(int id) { m_command.CommandText = DeliveryOrder.GetEventStatus(id); object b = m_command.ExecuteScalar(); EventStatus m = (EventStatus)Enum.Parse(typeof(EventStatus), b.ToString()); return(m); }
public static DeliveryOrder GetHeaderOnly(MySql.Data.MySqlClient.MySqlCommand cmd, int doID) { cmd.CommandText = DeliveryOrder.GetByIDSQL(doID); MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader(); DeliveryOrder st = DeliveryOrder.TransformReader(r); r.Close(); return(st); }
public override Event FindLastCodeAndTransactionDate(string codesample) { m_command.CommandText = DeliveryOrder.FindLastCodeAndTransactionDate(codesample); MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader(); Event e = DeliveryOrder.TransformReader(r); r.Close(); return(e); }
protected override void doRevise(Event events, Period p) { foreach (SalesReturnItem item in events.EVENT_ITEMS) { assertUsedByARCR(item); DeliveryOrder po = (DeliveryOrder)item.DO_ITEM.EVENT; SetStockCard(item, p); item.DO_ITEM.UnSetOSAgainstSRItem(item); DeliveryOrderRepository.UpdateAgainstStatus(m_command, po, item.DO_ITEM); } }
protected override void doConfirm(Event events, Period p) { foreach (SalesReturnItem item in events.EVENT_ITEMS) { DeliveryOrder po = (DeliveryOrder)item.DO_ITEM.EVENT; assertConfirmedPO(po); assertValidDate(po, item.EVENT); SetStockCard(item, p); item.DO_ITEM.SetOSAgainstSRItem(item); DeliveryOrderRepository.UpdateAgainstStatus(m_command, po, item.DO_ITEM); } }
protected override bool doIsCodeExist(string code) { try { m_command.CommandText = DeliveryOrder.SelectCountByCode(code); int t = Convert.ToInt32(m_command.ExecuteScalar()); return(t > 0); } catch (Exception x) { throw x; } }
//-------------------- protected override IList doSearch(string find) { try { m_command.CommandText = DeliveryOrder.GetSearch(find); MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader(); IList rest = DeliveryOrder.TransformReaderList(r); r.Close(); return(rest); } catch (Exception x) { throw x; } }
public IList FindSObyPartAndDONo(string find, IList exceptDOI, int customerID, DateTime trDate) { StringBuilder poisSB = new StringBuilder(); foreach (int i in exceptDOI) { poisSB.Append(i.ToString()); poisSB.Append(','); } string pois = poisSB.ToString(); pois = exceptDOI.Count > 0 ? pois.Substring(0, pois.Length - 1) : ""; m_command.CommandText = DeliveryOrderItem.GetSearchByPartAndDONo(find, customerID, pois, trDate); MySql.Data.MySqlClient.MySqlDataReader 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); }
protected override void doSave(Event e) { MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction(); try { m_command.Transaction = trc; DateTime trDate = DateTime.Today; string codesample = AutoNumberSetupRepository.GetCodeSampleByDomainName(m_command, "DeliveryOrder"); Event codeDate = FindLastCodeAndTransactionDate(codesample); string lastCode = codeDate == null ? string.Empty : codeDate.CODE; DateTime lastDate = codeDate == null ? trDate : codeDate.TRANSACTION_DATE; int trCount = RecordCount(); e.CODE = AutoNumberSetupRepository.GetAutoNumberByDomainName(m_command, "DeliveryOrder", e.CODE, lastCode, lastDate, trDate, trCount == 0); DeliveryOrder stk = (DeliveryOrder)e; m_command.CommandText = e.GetInsertSQL(); m_command.ExecuteNonQuery(); m_command.CommandText = DeliveryOrder.SelectMaxIDSQL(); stk.ID = Convert.ToInt32(m_command.ExecuteScalar()); foreach (DeliveryOrderItem item in stk.EVENT_ITEMS) { item.PART.UNIT_CONVERSION_LIST = PartRepository.GetUnitConversionsStatic(m_command, item.PART.ID); m_command.CommandText = item.GetInsertSQL(); m_command.ExecuteNonQuery(); m_command.CommandText = DeliveryOrderItem.SelectMaxIDSQL(); item.ID = Convert.ToInt32(m_command.ExecuteScalar()); } trc.Commit(); } catch (Exception x) { e.ID = 0; foreach (EventItem item in e.EVENT_ITEMS) { item.ID = 0; } trc.Rollback(); throw x; } }
protected override Event doGet(int ID) { m_command.CommandText = DeliveryOrder.GetByIDSQL(ID); MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader(); DeliveryOrder st = DeliveryOrder.TransformReader(r); r.Close(); m_command.CommandText = DeliveryOrderItem.GetByEventIDSQL(ID); r = m_command.ExecuteReader(); IList stis = DeliveryOrderItem.TransformReaderList(r); r.Close(); foreach (DeliveryOrderItem sti in stis) { sti.EVENT = st; sti.PART = PartRepository.GetByID(m_command, sti.PART.ID); sti.STOCK_CARD_ENTRY = StockCardEntryRepository.FindStockCardEntryByEventItem(m_command, sti.ID, sti.STOCK_CARD_ENTRY_TYPE); sti.SO_ITEM = SalesOrderRepository.FindSalesOrderItem(m_command, sti.SO_ITEM.ID); sti.SO_ITEM.PART = PartRepository.GetByID(m_command, sti.SO_ITEM.PART.ID); st.EVENT_ITEMS.Add(sti); } return(st); }
protected override void doUpdate(Event en) { MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction(); m_command.Transaction = trc; try { DeliveryOrder e = (DeliveryOrder)en; m_command.CommandText = e.GetUpdateSQL(); m_command.ExecuteNonQuery(); foreach (DeliveryOrderItem sti in e.EVENT_ITEMS) { sti.PART.UNIT_CONVERSION_LIST = PartRepository.GetUnitConversionsStatic(m_command, sti.PART.ID); if (sti.ID > 0) { m_command.CommandText = sti.GetUpdateSQL(); m_command.ExecuteNonQuery(); } else { m_command.CommandText = sti.GetInsertSQL(); m_command.ExecuteNonQuery(); m_command.CommandText = DeliveryOrderItem.SelectMaxIDSQL(); sti.ID = Convert.ToInt32(m_command.ExecuteScalar()); } } m_command.CommandText = DeliveryOrderItem.DeleteUpdate(e.ID, e.EVENT_ITEMS); m_command.ExecuteNonQuery(); trc.Commit(); } catch (Exception x) { trc.Rollback(); throw x; } }
protected override void doDelete(Event e) { DeliveryOrder st = (DeliveryOrder)e;//this.Get(e.ID); MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction(); m_command.Transaction = trc; try { if (getEventStatus(st.ID) == EventStatus.Confirm) { throw new Exception("Revise before delete"); } m_command.CommandText = DeliveryOrderItem.DeleteAllByEventSQL(st.ID); m_command.ExecuteNonQuery(); m_command.CommandText = DeliveryOrder.DeleteSQL(st.ID); m_command.ExecuteNonQuery(); trc.Commit(); } catch (Exception x) { trc.Rollback(); throw x; } }
public IList GetAllTransactions(int supID) { ArrayList result = new ArrayList(); OpenConnection(); MySql.Data.MySqlClient.MySqlDataReader r; m_cmd.CommandText = SalesOrder.GetByCustomerSQL(supID); r = m_cmd.ExecuteReader(); IList po = SalesOrder.TransformReaderList(r); r.Close(); foreach (Event e in po) { result.Add(e); } m_cmd.CommandText = DeliveryOrder.GetByCustomerSQL(supID); r = m_cmd.ExecuteReader(); IList grn = DeliveryOrder.TransformReaderList(r); r.Close(); foreach (Event e in grn) { result.Add(e); } m_cmd.CommandText = CustomerInvoice.GetByCustomerSQL(supID); r = m_cmd.ExecuteReader(); IList si = CustomerInvoice.TransformReaderList(r); r.Close(); foreach (Event e in si) { result.Add(e); } m_cmd.CommandText = POS.GetByCustomerSQL(supID); r = m_cmd.ExecuteReader(); IList pos = POS.TransformReaderList(r); r.Close(); foreach (Event e in pos) { result.Add(e); } m_cmd.CommandText = SalesReturn.GetByCustomerSQL(supID); r = m_cmd.ExecuteReader(); IList pr = SalesReturn.TransformReaderList(r); r.Close(); foreach (Event e in pr) { result.Add(e); } m_cmd.CommandText = ARCreditNote.GetByCustomerSQL(supID); r = m_cmd.ExecuteReader(); IList apdn = ARCreditNote.TransformReaderList(r); r.Close(); foreach (EventJournal e in apdn) { result.Add(e); } m_cmd.CommandText = Receipt.GetByCustomerSQL(supID); r = m_cmd.ExecuteReader(); IList py = Receipt.TransformReaderList(r); r.Close(); foreach (EventJournal e in py) { result.Add(e); } m_cmd.CommandText = CustomerOutStandingInvoice.GetByCustomerSQL(supID); r = m_cmd.ExecuteReader(); IList soi = CustomerOutStandingInvoice.TransformReaderList(r); r.Close(); foreach (EventJournal e in soi) { result.Add(e); } result.Sort(new EventDateComparer()); return(result); }
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); }
protected override void doUpdateStatus(Event e, bool posted) { m_command.CommandText = DeliveryOrder.GetUpdateStatusSQL(e); m_command.ExecuteNonQuery(); }
public static void UpdateAgainstStatus(MySql.Data.MySqlClient.MySqlCommand cmd, DeliveryOrder dor, DeliveryOrderItem doi) { cmd.CommandText = doi.UpdateAgainstStatus(); cmd.ExecuteNonQuery(); cmd.CommandText = dor.UpdateAgainstStatus(); cmd.ExecuteNonQuery(); }