Exemple #1
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;
            }
        }
Exemple #2
0
        private void assertInvoiceAlreadyGenerated(GoodReceiveNoteItem item)
        {
            m_command.CommandText = SupplierInvoiceItem.GetGRNUseBySupplierInvoice(item.ID);
            MySql.Data.MySqlClient.MySqlDataReader r = m_command.ExecuteReader();
            IList invs = SupplierInvoiceItem.TransformReaderList(r);

            r.Close();
            foreach (SupplierInvoiceItem x in invs)
            {
                m_command.CommandText = SupplierInvoice.GetByIDSQL(x.EVENT.ID);
                r       = m_command.ExecuteReader();
                x.EVENT = SupplierInvoice.TransformReader(r);
                r.Close();
            }
            if (invs.Count > 0)
            {
                throw new Exception("GRN Part [" + item.PART.CODE + "] is used by Supplier Invoice [" + ((SupplierInvoiceItem)invs[0]).EVENT.CODE + "], please delete supplier invoice first.");
            }
        }
Exemple #3
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);
        }