Exemplo n.º 1
0
        private static Tab_Order ToModel(DataRow row)
        {
            Tab_Order model = new Tab_Order();

            model.Idx         = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.UserIdx_Fx  = row.IsNull("UserIdx_Fx")?null:(System.Int32?)row["UserIdx_Fx"];
            model.CounterNo   = row.IsNull("CounterNo")?null:(System.String)row["CounterNo"];
            model.TotalPoints = row.IsNull("TotalPoints")?null:(System.Int32?)row["TotalPoints"];
            model.OrderStatus = row.IsNull("OrderStatus")?null:(System.String)row["OrderStatus"];
            model.SourcesData = row.IsNull("SourcesData")?null:(System.String)row["SourcesData"];
            model.DateCreated = row.IsNull("DateCreated")?null:(System.DateTime?)row["DateCreated"];
            return(model);
        }
Exemplo n.º 2
0
        public int AddNew(Tab_Order model)
        {
            string sql = "insert into Tab_Order(UserIdx_Fx,CounterNo,TotalPoints,OrderStatus,SourcesData,DateCreated)  values(@UserIdx_Fx,@CounterNo,@TotalPoints,@OrderStatus,@SourcesData,@DateCreated); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@UserIdx_Fx", model.UserIdx_Fx)
                                                                 , new SqlParameter("@CounterNo", model.CounterNo)
                                                                 , new SqlParameter("@TotalPoints", model.TotalPoints)
                                                                 , new SqlParameter("@OrderStatus", model.OrderStatus)
                                                                 , new SqlParameter("@SourcesData", model.SourcesData)
                                                                 , new SqlParameter("@DateCreated", model.DateCreated)
                                                                 ));

            return(Idx);
        }
Exemplo n.º 3
0
        public bool Update(Tab_Order model)
        {
            string sql  = "update Tab_Order set UserIdx_Fx=@UserIdx_Fx,CounterNo=@CounterNo,TotalPoints=@TotalPoints,OrderStatus=@OrderStatus,SourcesData=@SourcesData,DateCreated=@DateCreated where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@UserIdx_Fx", model.UserIdx_Fx)
                                                    , new SqlParameter("@CounterNo", model.CounterNo)
                                                    , new SqlParameter("@TotalPoints", model.TotalPoints)
                                                    , new SqlParameter("@OrderStatus", model.OrderStatus)
                                                    , new SqlParameter("@SourcesData", model.SourcesData)
                                                    , new SqlParameter("@DateCreated", model.DateCreated)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
Exemplo n.º 4
0
        public Tab_Order Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_Order  where Idx=@Idx",
                                                    new SqlParameter("Idx", Idx)).Tables[0];

            if (dt.Rows.Count > 1)
            {
                throw new Exception("more than 1 row was found");
            }

            if (dt.Rows.Count <= 0)
            {
                return(null);
            }

            DataRow   row   = dt.Rows[0];
            Tab_Order model = ToModel(row);

            return(model);
        }