コード例 #1
0
        public System.Collections.Generic.List <Ledger> GetAll()
        {
            System.Data.SqlClient.SqlCommand         cmd     = null;
            System.Data.SqlClient.SqlDataReader      SDR     = null;
            System.Collections.Generic.List <Ledger> ListTmp = new System.Collections.Generic.List <Ledger>();
            Ledger ObjTmp = null;
            DBCon  Obj    = new DBCon();

            try
            {
                string Query = "SELECT * FROM LEDGER WHERE Deleted=0 ORDER BY LID DESC";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp = new Ledger
                    {
                        LID         = SDR.GetInt64(0),
                        CID         = SDR.GetInt64(1),
                        Debit       = SDR.GetDouble(2),
                        Credit      = SDR.GetDouble(3),
                        Description = SDR.GetString(4),
                        Entry_Date  = SDR.GetDateTime(5),
                        LedgerType  = SDR.IsDBNull(7)?"":SDR.GetString(7)
                    };
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
コード例 #2
0
        public List <HG_OrderItem> GetAll(Int64 OID = 0)
        {
            var CurrOrgID = HttpContext.Current.Request.Cookies["UserInfo"];

            System.Data.SqlClient.SqlCommand    cmd = null;
            System.Data.SqlClient.SqlDataReader SDR = null;
            List <HG_OrderItem> ListTmp             = new List <HG_OrderItem>();
            DBCon Obj = new DBCon();

            try
            {
                string Query = "SELECT * FROM HG_ORDERITEM";
                if (OID > 0)
                {
                    Query = "SELECT * FROM HG_ORDERITEM WHERE OID=" + OID.ToString() + " and Deleted=0 ";
                }
                else if (int.Parse(CurrOrgID["OrgId"]) > 0)
                {
                    Query = "SELECT * FROM HG_ORDERITEM WHERE OrgId=" + CurrOrgID["OrgId"] + " and Deleted=0 ";
                }
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    HG_OrderItem ObjTmp = new HG_OrderItem();
                    ObjTmp.OIID         = SDR.GetInt64(0);
                    ObjTmp.FID          = SDR.GetInt64(1);
                    ObjTmp.Price        = SDR.GetDouble(2);
                    ObjTmp.Count        = SDR.GetInt32(3);
                    ObjTmp.IsAddon      = SDR.GetString(4);
                    ObjTmp.OID          = SDR.GetInt64(5);
                    ObjTmp.Status       = SDR.GetInt32(7);
                    ObjTmp.OrderDate    = SDR.GetDateTime(8);
                    ObjTmp.UpdatedBy    = SDR.GetInt32(9);
                    ObjTmp.UpdationDate = SDR.GetDateTime(10);
                    ObjTmp.TickedNo     = SDR.GetInt32(11);
                    ObjTmp.ChefSeenBy   = SDR.GetInt32(12);
                    ObjTmp.OrgId        = SDR.GetInt32(13);
                    ObjTmp.OrdById      = SDR.GetInt64(14);
                    ObjTmp.TaxInItm     = SDR.GetDouble(15);
                    ObjTmp.CostPrice    = SDR.GetDouble(16);
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
コード例 #3
0
        public static DBSizeInfo CreateFromSqlReader(System.Data.SqlClient.SqlDataReader reader)
        {
            DBSizeInfo mi = new DBSizeInfo()
            {
                DBName = reader.GetString(0), RowSize = reader.GetDouble(1), LogSize = reader.GetDouble(2), TotalSize = reader.GetDouble(3)
            };

            return(mi);
        }
コード例 #4
0
        public System.Collections.Generic.List <Food> GetAll()
        {
            System.Data.SqlClient.SqlCommand       cmd     = null;
            System.Data.SqlClient.SqlDataReader    SDR     = null;
            System.Collections.Generic.List <Food> ListTmp = new System.Collections.Generic.List <Food>();
            Food  ObjTmp = null;
            DBCon Obj    = new DBCon();

            try
            {
                string Query = "SELECT * FROM FOOD WHERE Deleted=0 ORDER BY FID DESC";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp = new Food
                    {
                        FID                = SDR.GetInt64(0),
                        Food_Image         = SDR.GetString(1),
                        Food_Name          = SDR.GetString(2),
                        Price              = SDR.GetDouble(3),
                        Qty                = SDR.GetString(4),
                        Description        = SDR.GetString(5),
                        Category_ID        = SDR.GetInt32(6),
                        MID                = SDR.GetInt32(7),
                        Status             = SDR.GetBoolean(8),
                        Rating             = SDR.IsDBNull(9)?"0": SDR.GetString(9),
                        Create_By          = SDR.GetInt32(10),
                        Create_Date        = SDR.GetDateTime(11),
                        Update_By          = SDR.GetInt32(12),
                        Update_Date        = SDR.GetDateTime(13),
                        FoodType           = SDR.IsDBNull(15)?"":SDR.GetString(15),
                        CostPrice          = SDR.IsDBNull(16)?SDR.GetDouble(3):SDR.GetDouble(16),
                        AdminAprovalStatus = SDR.IsDBNull(17)?1:SDR.GetInt32(17),
                        MealsType          = SDR.IsDBNull(18)?"Lunch,":SDR.GetString(18)
                    };
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
コード例 #5
0
        public HG_OrderItem GetOne(Int64 OIID = 0)
        {
            System.Data.SqlClient.SqlCommand    cmd = null;
            System.Data.SqlClient.SqlDataReader SDR = null;
            HG_OrderItem ObjTmp = new HG_OrderItem();
            DBCon        Obj    = new DBCon();

            try
            {
                string Query = "SELECT * FROM HG_ORDERITEM WHERE OIID=" + OIID.ToString() + " and Deleted=0 ";
                //if (TicketNo > 0)
                //{
                //    Query = "SELECT * FROM HG_ORDERITEM WHERE TickedNo=" + TicketNo.ToString() + " and Deleted=0 ";
                //}
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    ObjTmp              = new HG_OrderItem();
                    ObjTmp.OIID         = SDR.GetInt64(0);
                    ObjTmp.FID          = SDR.GetInt64(1);
                    ObjTmp.Price        = SDR.GetDouble(2);
                    ObjTmp.Count        = SDR.GetInt32(3);
                    ObjTmp.IsAddon      = SDR.GetString(4);
                    ObjTmp.OID          = SDR.GetInt64(5);
                    ObjTmp.Status       = SDR.GetInt32(7);
                    ObjTmp.OrderDate    = SDR.GetDateTime(8);
                    ObjTmp.UpdatedBy    = SDR.GetInt32(9);
                    ObjTmp.UpdationDate = SDR.GetDateTime(10);
                    ObjTmp.TickedNo     = SDR.GetInt32(11);
                    ObjTmp.ChefSeenBy   = SDR.GetInt32(12);
                    ObjTmp.OrgId        = SDR.GetInt32(13);
                    ObjTmp.OrdById      = SDR.GetInt64(14);
                    ObjTmp.TaxInItm     = SDR.GetDouble(15);
                    ObjTmp.CostPrice    = SDR.GetDouble(16);
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ObjTmp);
        }
コード例 #6
0
        private Dictionary <Tuple <long, DateTime>, DERMSCommon.SCADACommon.DayItem> ReadFromCollectTable(string connectionString)
        {
            DERMSCommon.SCADACommon.DayItem itemDay = null;
            Dictionary <Tuple <long, DateTime>, DERMSCommon.SCADACommon.DayItem> dayItems = new Dictionary <Tuple <long, DateTime>, DERMSCommon.SCADACommon.DayItem>();
            Tuple <long, DateTime> key = null;
            Dictionary <Tuple <long, DateTime>, DERMSCommon.SCADACommon.CollectItem> collectItemsData = new Dictionary <Tuple <long, DateTime>, DERMSCommon.SCADACommon.CollectItem>();

            using (System.Data.SqlClient.SqlConnection _con = new System.Data.SqlClient.SqlConnection(connectionString))
            {
                using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand("SELECT Timestamp, Gid, Production FROM dbo.Collect", _con))
                {
                    _con.Open();
                    using (System.Data.SqlClient.SqlDataReader reader = cmd.ExecuteReader())
                    {
                        // Check is the reader has any rows at all before starting to read.
                        if (reader.HasRows)
                        {
                            // Read advances to the next row.
                            while (reader.Read())
                            {
                                DERMSCommon.SCADACommon.CollectItem c = new DERMSCommon.SCADACommon.CollectItem();
                                // To avoid unexpected bugs access columns by name.
                                try
                                {
                                    c.Timestamp = reader.GetDateTime(reader.GetOrdinal("Timestamp"));
                                    c.Gid       = reader.GetInt64(reader.GetOrdinal("Gid"));
                                    c.P         = reader.GetDouble(reader.GetOrdinal("Production"));
                                    key         = new Tuple <long, DateTime>(c.Gid, c.Timestamp);

                                    collectItemsData.Add(key, c);
                                }
                                catch (Exception e)
                                { }
                            }
                        }
                    }

                    _con.Close();
                }
            }

            foreach (var d in collectItemsData)
            {
                itemDay = new DERMSCommon.SCADACommon.DayItem(d.Key.Item1, d.Key.Item2.Date.AddHours(d.Key.Item2.Hour), MinProductionPerHour(d.Key.Item2.Hour, d.Key.Item2.DayOfYear, collectItemsData), MaxProductionPerHour(d.Key.Item2.Hour, d.Key.Item2.DayOfYear, collectItemsData), AvgProductionPerHour(d.Key.Item2.Hour, d.Key.Item2.DayOfYear, collectItemsData), 0, 0);
                key     = new Tuple <long, DateTime>(itemDay.Gid, itemDay.Timestamp);
                if (!dayItems.ContainsKey(key))
                {
                    dayItems.Add(key, itemDay);
                }
            }

            return(dayItems);
        }
コード例 #7
0
ファイル: HelperDataReader.cs プロジェクト: renatomatos/prova
        public static double GetDouble(System.Data.SqlClient.SqlDataReader rd, string field)
        {
            var index = rd.GetOrdinal(field);

            if (index < 0)
            {
                return(0);
            }
            else
            {
                if (rd.IsDBNull(index))
                {
                    return(0);
                }
                else
                {
                    return(rd.GetDouble(index));
                }
            }
        }
コード例 #8
0
ファイル: OrderItem.cs プロジェクト: NKsahu/NWFOODDO
        public System.Collections.Generic.List <OrderItem> GetAll()
        {
            System.Data.SqlClient.SqlCommand            cmd     = null;
            System.Data.SqlClient.SqlDataReader         SDR     = null;
            System.Collections.Generic.List <OrderItem> ListTmp = new System.Collections.Generic.List <OrderItem>();

            DBCon Obj = new DBCon();

            try
            {
                string Query = "SELECT * FROM ORDERITEM WHERE Deleted=0 ORDER BY OIID DESC";
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    OrderItem ObjTmp = new OrderItem();
                    ObjTmp.OIID           = SDR.GetInt64(0);
                    ObjTmp.FID            = SDR.GetInt64(1);
                    ObjTmp.Price          = SDR.GetDouble(2);
                    ObjTmp.Count          = SDR.GetInt32(3);
                    ObjTmp.Qty            = SDR.GetString(4);
                    ObjTmp.OID            = SDR.GetInt64(5);
                    ObjTmp.MessID         = SDR.IsDBNull(7) ? 0 : SDR.GetInt64(7);
                    ObjTmp.Status         = SDR.IsDBNull(8) ? 0 : SDR.GetInt32(8);
                    ObjTmp.OrderDate      = SDR.IsDBNull(9) ? System.DateTime.Now : SDR.GetDateTime(9);
                    ObjTmp.TifinRackIds   = SDR.IsDBNull(10) ? "" : SDR.GetString(10);
                    ObjTmp.UpdatedBy      = SDR.IsDBNull(11) ? 0 : SDR.GetInt32(11);
                    ObjTmp.UpdationDate   = SDR.IsDBNull(12) ? System.DateTime.Now : SDR.GetDateTime(12);
                    ObjTmp.TifinID        = SDR.IsDBNull(13) ? 0 : SDR.GetInt64(13);
                    ObjTmp.ItemCollectBy  = SDR.IsDBNull(14) ? 0 : SDR.GetInt32(14);
                    ObjTmp.ItemAssembleBy = SDR.IsDBNull(15) ? 0 : SDR.GetInt32(15);
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (System.Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: Lyelt/Budget
        public static ScheduledTask Create(System.Data.SqlClient.SqlDataReader reader)
        {
            ScheduledTask t = new ScheduledTask();

            t.Id                  = reader.GetInt("Id");
            t.ExpenseName         = reader.GetString("ExpenseName");
            t.ExpenseCategoryName = reader.GetString("ExpenseCategoryName");
            t.BudgetId            = reader.GetInt("BudgetId");
            t.DayOfMonth          = reader.GetInt("DayOfMonth");
            t.Amount              = reader.GetDouble("Amount");
            t.Description         = reader.GetString("Description");

            if (reader.IsDBNull(reader.GetOrdinal("Completed")))
            {
                t.Completed = null;
            }
            else
            {
                t.Completed = reader.GetBoolean(reader.GetOrdinal("Completed"));
            }

            return(t);
        }
コード例 #10
0
        public List <HG_OrderItem> GetAllByOrg(int OrgId, int ChefId = 0, int ItemStatus = 0, bool TodayOnly = false, string Status = null)
        {
            System.Data.SqlClient.SqlCommand    cmd = null;
            System.Data.SqlClient.SqlDataReader SDR = null;
            List <HG_OrderItem> ListTmp             = new List <HG_OrderItem>();
            DBCon Obj = new DBCon();

            try
            {
                string Query = "";
                if (OrgId > 0)
                {
                    Query = "SELECT * FROM HG_ORDERITEM WHERE OrgId=" + OrgId.ToString() + "";
                }
                else if (OrgId <= 0)//super admin && postpaid-admin
                {
                    Query = "SELECT * FROM HG_ORDERITEM WHERE OrgId>0";
                }
                if (ChefId > 0)
                {
                    Query += " and (ChefSeenBy=" + ChefId.ToString() + " or ChefSeenBy=0)";
                }
                if (ItemStatus > 0)
                {
                    Query += " and Status=" + ItemStatus.ToString();
                }
                if (TodayOnly)
                {
                    var Formdate = DateTime.Now;
                    var theDate  = new DateTime(Formdate.Year, Formdate.Month, Formdate.Day, 23, 59, 00);
                    Query = "SELECT * FROM HG_ORDERITEM WHERE OrderDate between '" + Formdate.ToString("MM/dd/yyyy") + "' and '" + theDate.ToString("MM/dd/yyyy HH:mm:ss") + "' and OrgId=" + OrgId.ToString() + "";
                }
                if (Status != null && ItemStatus == 0)
                {
                    Query += " and " + Status;
                }
                cmd = new System.Data.SqlClient.SqlCommand(Query, Obj.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    HG_OrderItem ObjTmp = new HG_OrderItem();
                    ObjTmp.OIID         = SDR.GetInt64(0);
                    ObjTmp.FID          = SDR.GetInt64(1);
                    ObjTmp.Price        = SDR.GetDouble(2);
                    ObjTmp.Count        = SDR.GetInt32(3);
                    ObjTmp.IsAddon      = SDR.GetString(4);
                    ObjTmp.OID          = SDR.GetInt64(5);
                    ObjTmp.Status       = SDR.GetInt32(7);
                    ObjTmp.OrderDate    = SDR.GetDateTime(8);
                    ObjTmp.UpdatedBy    = SDR.GetInt32(9);
                    ObjTmp.UpdationDate = SDR.GetDateTime(10);
                    ObjTmp.TickedNo     = SDR.GetInt32(11);
                    ObjTmp.ChefSeenBy   = SDR.GetInt32(12);
                    ObjTmp.OrgId        = SDR.GetInt32(13);
                    ObjTmp.OrdById      = SDR.GetInt64(14);
                    ObjTmp.TaxInItm     = SDR.GetDouble(15);
                    ObjTmp.CostPrice    = SDR.GetDouble(16);
                    ListTmp.Add(ObjTmp);
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); Obj.Con.Close(); Obj.Con.Dispose(); Obj.Con = null; }
            return(ListTmp);
        }