public void BindBrand(Int64 bid)
    {
        brandMaster objcategory = (new Cls_brand_b().SelectById(bid));

        if (objcategory != null)
        {
            //ddlBank.SelectedValue = objcategory.bankid.ToString();
            txtBrandName.Text = objcategory.brandName;
        }
    }
        public brandMaster SelectById(Int64 cid)
        {
            SqlDataAdapter da;
            DataSet        ds          = new DataSet();
            brandMaster    objcategory = new brandMaster();

            try
            {
                SqlCommand cmd = new SqlCommand
                {
                    CommandText = "brand_SelectById",
                    CommandType = CommandType.StoredProcedure,
                    Connection  = ConnectionString
                };
                cmd.Parameters.AddWithValue("@bid", cid);
                ConnectionString.Open();
                da = new SqlDataAdapter(cmd);
                da.Fill(ds);

                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        if (ds.Tables[0] != null)
                        {
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                {
                                    objcategory.bid       = Convert.ToInt64(ds.Tables[0].Rows[0]["bid"]);
                                    objcategory.brandName = Convert.ToString(ds.Tables[0].Rows[0]["brandName"]);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(null);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(objcategory);
        }
    //protected override void Render(HtmlTextWriter writer)
    //{
    //    string validatorOverrideScripts = "<script src=\"" + Page.ResolveUrl("~") + "js/validators.js\" type=\"text/javascript\"></script>";
    //    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ValidatorOverrideScripts", validatorOverrideScripts, false);
    //    base.Render(writer);
    //}



    protected void btnSave_Click(object sender, EventArgs e)
    {
        Int64       Result      = 0;
        brandMaster objcategory = new brandMaster();

        objcategory.brandName = txtBrandName.Text.Trim();

        if (Request.QueryString["id"] != null)
        {
            objcategory.bid = Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true));
            Result          = (new Cls_brand_b().Update(objcategory));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/manageBrand.aspx?mode=u"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Brand Not Updated";
                BindBrand(Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true)));
            }
        }
        else
        {
            Result = (new Cls_brand_b().Insert(objcategory));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/manageBrand.aspx?mode=i"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Brand Saved";
            }
        }
    }
        public Int64 Insert(brandMaster objcategory)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand
                {
                    CommandText = "brand_Insert",
                    CommandType = CommandType.StoredProcedure,
                    Connection  = ConnectionString
                };

                SqlParameter param = new SqlParameter
                {
                    ParameterName = "@bid",
                    Value         = objcategory.bid,
                    SqlDbType     = SqlDbType.BigInt,
                    Direction     = ParameterDirection.InputOutput
                };
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("@brandName", objcategory.brandName);


                ConnectionString.Open();
                cmd.ExecuteNonQuery();
                result = Convert.ToInt64(param.Value);
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(result);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(result);
        }