Пример #1
0
        public int RecordCount()
        {
            m_command.CommandText = GoodReceiveNote.RecordCount();
            int result = Convert.ToInt32(m_command.ExecuteScalar());

            return(result);
        }
Пример #2
0
        protected override void doDelete(Event e)
        {
            GoodReceiveNote st = (GoodReceiveNote)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 = SupplierInvoiceItem.GetGRNUseBySupplierInvoice(st.EVENT_ITEMS);
                int count = Convert.ToInt32(m_command.ExecuteScalar());
                if (count > 0)
                {
                    throw new Exception("Can not delete this GRN, this GRN used by Supplier Invoice");
                }

                m_command.CommandText = GoodReceiveNoteItem.DeleteAllByEventSQL(st.ID);
                m_command.ExecuteNonQuery();
                m_command.CommandText = GoodReceiveNote.DeleteSQL(st.ID);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
Пример #3
0
        public static IList TransformReaderList(MySql.Data.MySqlClient.MySqlDataReader aReader)
        {
            IList result = new ArrayList();

            while (aReader.Read())
            {
                GoodReceiveNote transaction = new GoodReceiveNote();
                transaction.ID = Convert.ToInt32(aReader["grn_id"]);
                transaction.TRANSACTION_DATE      = Convert.ToDateTime(aReader["grn_date"]);
                transaction.NOTICE_DATE           = Convert.ToDateTime(aReader["grn_noticedate"]);
                transaction.STOCK_CARD_ENTRY_TYPE = (StockCardEntryType)Enum.Parse(typeof(StockCardEntryType), aReader["grn_scentrytype"].ToString());
                transaction.EMPLOYEE          = new Employee(Convert.ToInt32(aReader["emp_id"]));
                transaction.NOTES             = aReader["grn_notes"].ToString();
                transaction.POSTED            = Convert.ToBoolean(aReader["grn_posted"]);
                transaction.EVENT_STATUS      = (EventStatus)Enum.Parse(typeof(EventStatus), aReader["grn_eventstatus"].ToString());
                transaction.AGAINST_PR_STATUS = (AgainstStatus)Enum.Parse(typeof(AgainstStatus), aReader["grn_againstprstatus"].ToString());
                transaction.CODE                   = aReader["grn_code"].ToString();
                transaction.SUPPLIER               = new Supplier(Convert.ToInt32(aReader["sup_id"]));
                transaction.DOCUMENT_NO            = aReader["grn_docno"].ToString();
                transaction.DOCUMENT_DATE          = Convert.ToDateTime(aReader["grn_docdate"]);
                transaction.VENDOR                 = transaction.SUPPLIER;
                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);
        }
Пример #4
0
        private EventStatus getEventStatus(int id)
        {
            m_command.CommandText = GoodReceiveNote.GetEventStatus(id);
            object      b = m_command.ExecuteScalar();
            EventStatus m = (EventStatus)Enum.Parse(typeof(EventStatus), b.ToString());

            return(m);
        }
Пример #5
0
        public static GoodReceiveNote GetHeaderOnly(MySql.Data.MySqlClient.MySqlCommand cmd, int grnID)
        {
            cmd.CommandText = GoodReceiveNote.GetByIDSQL(grnID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            GoodReceiveNote st = GoodReceiveNote.TransformReader(r);

            r.Close();
            return(st);
        }
Пример #6
0
        public override Event FindLastCodeAndTransactionDate(string codesample)
        {
            m_command.CommandText = GoodReceiveNote.FindLastCodeAndTransactionDate(codesample);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            Event e = GoodReceiveNote.TransformReader(r);

            r.Close();
            return(e);
        }
Пример #7
0
 protected override void doRevise(Event events, Period p)
 {
     foreach (PurchaseReturnItem item in events.EVENT_ITEMS)
     {
         assertUsedByAPDN(item);
         GoodReceiveNote po = (GoodReceiveNote)item.GRN_ITEM.EVENT;
         SetStockCard(item, p);
         item.GRN_ITEM.UnSetOSAgainstPRItem(item);
         GoodReceiveNoteRepository.UpdateAgainstStatus(m_command, po, item.GRN_ITEM);
     }
 }
Пример #8
0
 protected override void doConfirm(Event events, Period p)
 {
     foreach (PurchaseReturnItem item in events.EVENT_ITEMS)
     {
         GoodReceiveNote po = (GoodReceiveNote)item.GRN_ITEM.EVENT;
         assertConfirmedPO(po);
         assertValidDate(po, item.EVENT);
         SetStockCard(item, p);
         item.GRN_ITEM.SetOSAgainstPRItem(item);
         GoodReceiveNoteRepository.UpdateAgainstStatus(m_command, po, item.GRN_ITEM);
     }
 }
Пример #9
0
 protected override bool doIsCodeExist(string code)
 {
     try
     {
         m_command.CommandText = GoodReceiveNote.SelectCountByCode(code);
         int t = Convert.ToInt32(m_command.ExecuteScalar());
         return(t > 0);
     }
     catch (Exception x)
     {
         throw x;
     }
 }
Пример #10
0
 protected override IList doSearch(string find)
 {
     try
     {
         m_command.CommandText = GoodReceiveNote.GetSearch(find);
         MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
         IList rest = GoodReceiveNote.TransformReaderList(r);
         r.Close();
         return(rest);
     }
     catch (Exception x)
     {
         throw x;
     }
 }
Пример #11
0
        public IList FindPObyPartAndGRNNo(string find, IList exceptGRNI, int supplierID, DateTime trDate)
        {
            StringBuilder poisSB = new StringBuilder();

            foreach (int i in exceptGRNI)
            {
                poisSB.Append(i.ToString());
                poisSB.Append(',');
            }
            string pois = poisSB.ToString();

            pois = exceptGRNI.Count > 0 ? pois.Substring(0, pois.Length - 1) : "";

            m_command.CommandText = GoodReceiveNoteItem.GetSearchByPartAndGRNNo(find, supplierID, pois, trDate);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            IList result = GoodReceiveNoteItem.TransformReaderList(r);

            r.Close();
            foreach (GoodReceiveNoteItem t in result)
            {
                m_command.CommandText = GoodReceiveNote.GetByIDSQL(t.EVENT.ID);
                r       = m_command.ExecuteReader();
                t.EVENT = GoodReceiveNote.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);
        }
Пример #12
0
        public static GoodReceiveNoteItem FindPOItem(MySql.Data.MySqlClient.MySqlCommand cmd, int PoIID)
        {
            cmd.CommandText = GoodReceiveNoteItem.FindByPOItemIDSQL(PoIID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            GoodReceiveNoteItem res = GoodReceiveNoteItem.TransformReader(r);

            r.Close();
            if (res == null)
            {
                return(res);
            }
            cmd.CommandText = GoodReceiveNote.GetByIDSQL(res.EVENT.ID);
            r         = cmd.ExecuteReader();
            res.EVENT = GoodReceiveNote.TransformReader(r);
            r.Close();
            return(res);
        }
Пример #13
0
        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, "GoodReceiveNote");
                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, "GoodReceiveNote", e.CODE, lastCode, lastDate, trDate, trCount == 0);

                GoodReceiveNote stk = (GoodReceiveNote)e;
                m_command.CommandText = e.GetInsertSQL();
                m_command.ExecuteNonQuery();
                m_command.CommandText = GoodReceiveNote.SelectMaxIDSQL();
                stk.ID = Convert.ToInt32(m_command.ExecuteScalar());
                foreach (GoodReceiveNoteItem 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 = GoodReceiveNoteItem.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;
            }
        }
Пример #14
0
        protected override Event doGet(int ID)
        {
            m_command.CommandText = GoodReceiveNote.GetByIDSQL(ID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            GoodReceiveNote st = GoodReceiveNote.TransformReader(r);

            r.Close();
            m_command.CommandText = GoodReceiveNoteItem.GetByEventIDSQL(ID);
            r = m_command.ExecuteReader();
            IList stis = GoodReceiveNoteItem.TransformReaderList(r);

            r.Close();
            foreach (GoodReceiveNoteItem 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.PO_ITEM          = PurchaseOrderRepository.FindPurchaseOrderItem(m_command, sti.PO_ITEM.ID);
                sti.PO_ITEM.PART     = PartRepository.GetByID(m_command, sti.PO_ITEM.PART.ID);
                st.EVENT_ITEMS.Add(sti);
            }
            return(st);
        }
Пример #15
0
        protected override void doUpdate(Event en)
        {
            MySql.Data.MySqlClient.MySqlTransaction trc = m_connection.BeginTransaction();
            m_command.Transaction = trc;
            try
            {
                GoodReceiveNote e = (GoodReceiveNote)en;
                m_command.CommandText = e.GetUpdateSQL();
                m_command.ExecuteNonQuery();

                foreach (GoodReceiveNoteItem 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 = GoodReceiveNoteItem.SelectMaxIDSQL();
                        sti.ID = Convert.ToInt32(m_command.ExecuteScalar());
                    }
                }
                m_command.CommandText = GoodReceiveNoteItem.DeleteUpdate(e.ID, e.EVENT_ITEMS);
                m_command.ExecuteNonQuery();
                trc.Commit();
            }
            catch (Exception x)
            {
                trc.Rollback();
                throw x;
            }
        }
Пример #16
0
        public IList GetAllTransactions(int supID)
        {
            ArrayList result = new ArrayList();

            OpenConnection();
            MySql.Data.MySqlClient.MySqlDataReader r;

            m_cmd.CommandText = PurchaseOrder.GetBySupplierSQL(supID);
            r = m_cmd.ExecuteReader();
            IList po = PurchaseOrder.TransformReaderList(r);

            r.Close();
            foreach (Event e in po)
            {
                result.Add(e);
            }

            m_cmd.CommandText = GoodReceiveNote.GetBySupplierSQL(supID);
            r = m_cmd.ExecuteReader();
            IList grn = GoodReceiveNote.TransformReaderList(r);

            r.Close();
            foreach (Event e in grn)
            {
                result.Add(e);
            }

            m_cmd.CommandText = SupplierInvoice.GetBySupplierSQL(supID);
            r = m_cmd.ExecuteReader();
            IList si = SupplierInvoice.TransformReaderList(r);

            r.Close();
            foreach (Event e in si)
            {
                result.Add(e);
            }

            m_cmd.CommandText = PurchaseReturn.GetBySupplierSQL(supID);
            r = m_cmd.ExecuteReader();
            IList pr = PurchaseReturn.TransformReaderList(r);

            r.Close();
            foreach (Event e in pr)
            {
                result.Add(e);
            }

            m_cmd.CommandText = APDebitNote.GetBySupplierSQL(supID);
            r = m_cmd.ExecuteReader();
            IList apdn = APDebitNote.TransformReaderList(r);

            r.Close();
            foreach (EventJournal e in apdn)
            {
                result.Add(e);
            }

            m_cmd.CommandText = Payment.GetBySupplierSQL(supID);
            r = m_cmd.ExecuteReader();
            IList py = Payment.TransformReaderList(r);

            r.Close();
            foreach (EventJournal e in py)
            {
                result.Add(e);
            }

            m_cmd.CommandText = SupplierOutStandingInvoice.GetBySupplierSQL(supID);
            r = m_cmd.ExecuteReader();
            IList soi = SupplierOutStandingInvoice.TransformReaderList(r);

            r.Close();
            foreach (EventJournal e in soi)
            {
                result.Add(e);
            }

            result.Sort(new EventDateComparer());
            return(result);
        }
Пример #17
0
 protected override void doUpdateStatus(Event e, bool posted)
 {
     m_command.CommandText = GoodReceiveNote.GetUpdateStatusSQL(e);
     m_command.ExecuteNonQuery();
 }
Пример #18
0
        public IList FindGRNItemlistBySupplierDate(string find, int supID, DateTime trdate, IList grnIDS)
        {
            m_command.CommandText = SupplierInvoiceItem.GetGRNUseBySupplierInvoice();
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            if (r.HasRows)
            {
                while (r.Read())
                {
                    int id = Convert.ToInt32(r[0]);
                    if (!grnIDS.Contains(id))
                    {
                        grnIDS.Add(id);
                    }
                }
            }
            r.Close();
            StringBuilder poisSB = new StringBuilder();

            foreach (int i in grnIDS)
            {
                poisSB.Append(i.ToString());
                poisSB.Append(',');
            }
            string pois = poisSB.ToString();

            pois = grnIDS.Count > 0 ? pois.Substring(0, pois.Length - 1) : "";
            if (find == "")
            {
                m_command.CommandText = GoodReceiveNoteItem.GetGRNItemBySuppDate(supID, trdate, pois);
            }
            else
            {
                m_command.CommandText = GoodReceiveNoteItem.GetSearchByPartAndGRNNo(find, supID, pois, trdate);
            }
            r = m_command.ExecuteReader();
            IList result = GoodReceiveNoteItem.TransformReaderList(r);

            r.Close();
            foreach (GoodReceiveNoteItem t in result)
            {
                m_command.CommandText = GoodReceiveNote.GetByIDSQL(t.EVENT.ID);
                r       = m_command.ExecuteReader();
                t.EVENT = GoodReceiveNote.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);
        }
Пример #19
0
 public static void UpdateAgainstStatus(MySql.Data.MySqlClient.MySqlCommand cmd, GoodReceiveNote grn, GoodReceiveNoteItem grni)
 {
     cmd.CommandText = grni.UpdateAgainstStatus();
     cmd.ExecuteNonQuery();
     cmd.CommandText = grn.UpdateAgainstStatus();
     cmd.ExecuteNonQuery();
 }