コード例 #1
0
        public static StockCard FindStockCard(MySql.Data.MySqlClient.MySqlCommand cmd, long partId, long locationId, long periodId)
        {
            cmd.CommandText = String.Format("select * from table_stockcard where part_id = {0} and warehouse_id = {1} and period_id = {2}", partId, locationId, periodId);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            StockCard sc = StockCard.TransformReader(r);

            r.Close();
            if (sc != null)
            {
                sc.PERIOD       = PeriodRepository.FindPeriod(cmd, sc.PERIOD.ID);
                cmd.CommandText = StockCardEntry.FindByStockCard(sc.ID);
                MySql.Data.MySqlClient.MySqlDataReader rx = cmd.ExecuteReader();
                sc.STOCK_CARD_ENTRIES = StockCardEntry.TransformReaderList(rx);
                rx.Close();
            }
            return(sc);
        }
コード例 #2
0
        public static StockCard FindStockCardHeader(MySql.Data.MySqlClient.MySqlCommand cmd, long partId,
                                                    long locationId, Period periodId, DateTime trDate)
        {
            cmd.CommandText = String.Format("select * from table_stockcard where part_id = {0} and warehouse_id = {1} and period_id = {2}", partId, locationId, periodId.ID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            StockCard sc = StockCard.TransformReader(r);

            r.Close();
            if (sc != null)
            {
                sc.PERIOD    = PeriodRepository.FindPeriod(cmd, sc.PERIOD.ID);
                sc.WAREHOUSE = StockCardRepository.FindWarehouse(cmd, sc.WAREHOUSE.ID);

                cmd.CommandText = StockCardEntry.FindByStockCard(sc.ID, periodId.START_DATE, trDate);
                MySql.Data.MySqlClient.MySqlDataReader rx = cmd.ExecuteReader();
                sc.STOCK_CARD_ENTRIES = StockCardEntry.TransformReaderList(rx);
                rx.Close();
                foreach (StockCardEntry e in sc.STOCK_CARD_ENTRIES)
                {
                    if (e.STOCK_CARD_ENTRY_TYPE == StockCardEntryType.SupplierInvoice)
                    {
                        cmd.CommandText = SupplierInvoiceItem.GetByIDSQL(e.EVENT_ITEM.ID);
                        rx           = cmd.ExecuteReader();
                        e.EVENT_ITEM = SupplierInvoiceItem.TransformReader(rx);
                        rx.Close();
                    }
                    if (e.STOCK_CARD_ENTRY_TYPE == StockCardEntryType.CustomerInvoice)
                    {
                        cmd.CommandText = CustomerInvoiceItem.GetByIDSQL(e.EVENT_ITEM.ID);
                        rx           = cmd.ExecuteReader();
                        e.EVENT_ITEM = CustomerInvoiceItem.TransformReader(rx);
                        rx.Close();
                    }
                }
            }
            return(sc);
        }
コード例 #3
0
        public static void Update(MySql.Data.MySqlClient.MySqlCommand cmd, StockCard sc)
        {
            cmd.CommandText = sc.GetUpdateSQL();
            cmd.ExecuteNonQuery();
            foreach (StockCardEntry sce in sc.STOCK_CARD_ENTRIES)
            {
                if (sce.ID == 0)
                {
                    cmd.CommandText = sce.GetInsertSQL();
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = StockCardEntry.SelectMaxIDSQL();
                    sce.ID          = Convert.ToInt32(cmd.ExecuteScalar());
                }
                else
                {
                    cmd.CommandText = sce.GetUpdateSQL();
                    cmd.ExecuteNonQuery();
                }
            }
            cmd.CommandText = StockCardEntry.FindByStockCard(sc.ID);
            MySql.Data.MySqlClient.MySqlDataReader r = cmd.ExecuteReader();
            IList sces = StockCardEntry.TransformReaderList(r);

            r.Close();
            foreach (StockCardEntry sce in sces)
            {
                sce.UPDATED = sc.STOCK_CARD_ENTRIES.Contains(sce);
            }
            foreach (StockCardEntry sce in sces)
            {
                if (!sce.UPDATED)
                {
                    cmd.CommandText = StockCardEntry.DeleteSQL(sce.ID);
                    cmd.ExecuteNonQuery();
                }
            }
        }
コード例 #4
0
        public DataSet GetStockReport(bool allPart, string partStart, string partEnd, bool allGroup,
                                      string groupStart, string groupEnd, DateTime asOfDate)
        {
            DataSet ds = new DataSet();

            m_cmd.CommandText = "delete from table_temp";
            m_cmd.ExecuteNonQuery();

            m_cmd.CommandText = Part.GetStockReport(allPart, partStart, partEnd, allGroup, groupStart, groupEnd);
            MySql.Data.MySqlClient.MySqlDataReader rdr = m_cmd.ExecuteReader();
            IList result = Part.GetAllStaticForReport(rdr);

            rdr.Close();
            //IList stockcards = new ArrayList();
            foreach (Part p in result)
            {
                p.UNIT       = PartRepository.GetUnitByID(m_cmd, p.UNIT.ID);
                p.PART_GROUP = PartRepository.GetPartGroupByID(m_cmd, p.PART_GROUP.ID);

                StockCard sc = new StockCard(p, null, null);
                m_cmd.CommandText = StockCardEntry.FindByStockCardEntryByPart(p.ID, new DateTime(2000, 1, 1), asOfDate);
                rdr = m_cmd.ExecuteReader();
                sc.STOCK_CARD_ENTRIES = StockCardEntry.TransformReaderList(rdr);
                rdr.Close();
                foreach (StockCardEntry e in sc.STOCK_CARD_ENTRIES)
                {
                    if (e.STOCK_CARD_ENTRY_TYPE == StockCardEntryType.SupplierInvoice)
                    {
                        m_cmd.CommandText = SupplierInvoiceItem.GetByIDSQL(e.EVENT_ITEM.ID);
                        rdr          = m_cmd.ExecuteReader();
                        e.EVENT_ITEM = SupplierInvoiceItem.TransformReader(rdr);
                        rdr.Close();
                    }
                    if (e.STOCK_CARD_ENTRY_TYPE == StockCardEntryType.CustomerInvoice)
                    {
                        m_cmd.CommandText = CustomerInvoiceItem.GetByIDSQL(e.EVENT_ITEM.ID);
                        rdr          = m_cmd.ExecuteReader();
                        e.EVENT_ITEM = CustomerInvoiceItem.TransformReader(rdr);
                        rdr.Close();
                    }
                }
                sc.recalculateAvailable();
                m_cmd.CommandText = string.Format(@"insert into table_temp 
                    (
                        string1,string2,string3,double1,double2
                    )
                    values   
                    (
                        '{0}','{1}','{2}',{3},{4}
                    )",
                                                  p.PART_GROUP.NAME + " ~ " + p.PART_GROUP.CODE,
                                                  p.CODE,
                                                  p.UNIT.NAME,
                                                  sc.BALANCE_AVAILABLE,
                                                  p.MINIMUM_STOCK
                                                  );
                m_cmd.ExecuteNonQuery();
                //stockcards.Add(sc);
            }
            return(ds);
        }