示例#1
0
 protected void Update_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Data.GroupProduct obj = new Data.GroupProduct();
         obj.Id       = Id;
         obj.Name     = txtName.Text;
         obj.Level    = Level + "00000";
         obj.Position = chkPosition.Checked ? "1" : "0";
         obj.Ord      = txtOrd.Text != "" ? txtOrd.Text : "1";
         obj.Active   = chkActive.Checked ? "1" : "0";
         obj.Items    = txtItems.Text.Trim();
         if (Insert == true)
         {
             GroupProductService.GroupProduct_Insert(obj);
         }
         else
         {
             GroupProductService.GroupProduct_Update(obj);
         }
         BindGrid();
         pnView.Visible   = true;
         pnUpdate.Visible = false;
         Level            = "";
         Insert           = false;
     }
 }
示例#2
0
 public GroupProduct GroupProductIDataReader(IDataReader dr)
 {
     Data.GroupProduct obj = new Data.GroupProduct();
     obj.Id     = (dr["Id"] is DBNull) ? string.Empty : dr["Id"].ToString();
     obj.Name   = (dr["Name"] is DBNull) ? string.Empty : dr["Name"].ToString();
     obj.Level  = (dr["Level"] is DBNull) ? string.Empty : dr["Level"].ToString();
     obj.Ord    = (dr["Ord"] is DBNull) ? string.Empty : dr["Ord"].ToString();
     obj.Active = (dr["Active"] is DBNull) ? string.Empty : dr["Active"].ToString();
     return(obj);
 }
        public List <GroupProduct> GroupProduct_GetByTop(string Top, string Where, string Order)
        {
            List <Data.GroupProduct> list = new List <Data.GroupProduct>();

            Data.GroupProduct obj = new Data.GroupProduct();
            SqlDataReader     dr  = null;

            try
            {
                using (SqlCommand dbCmd = new SqlCommand("sp_GroupProduct_GetByTop", GetConnection()))
                {
                    dbCmd.CommandType = CommandType.StoredProcedure;
                    dbCmd.Parameters.Add(new SqlParameter("@Top", Top));
                    dbCmd.Parameters.Add(new SqlParameter("@Where", Where));
                    dbCmd.Parameters.Add(new SqlParameter("@Order", Order));
                    dr = dbCmd.ExecuteReader();
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            list.Add(obj.GroupProductIDataReader(dr));
                        }
                        //conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                obj = null;
            }
            return(list);
        }
        public List <GroupProduct> GroupProduct_GetByAll()
        {
            List <Data.GroupProduct> list = new List <Data.GroupProduct>();

            Data.GroupProduct obj = new Data.GroupProduct();
            SqlDataReader     dr  = null;

            try
            {
                using (SqlCommand dbCmd = new SqlCommand("sp_GroupProduct_GetByAll", GetConnection()))
                {
                    dbCmd.CommandType = CommandType.StoredProcedure;
                    dr = dbCmd.ExecuteReader();
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            list.Add(obj.GroupProductIDataReader(dr));
                        }
                        //conn.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                obj = null;
            }
            return(list);
        }