public Int64 Update(farmerproducts objfarmerproducts)
        {
            Int64 result = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "farmerproducts_Update";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;

                SqlParameter param = new SqlParameter();
                param.ParameterName = "@id";
                param.Value         = objfarmerproducts.id;
                param.SqlDbType     = SqlDbType.BigInt;
                param.Direction     = ParameterDirection.InputOutput;
                cmd.Parameters.Add(param);
                cmd.Parameters.AddWithValue("name", objfarmerproducts.name);

                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);
        }
Ejemplo n.º 2
0
    public void BindFarmer(Int64 id)
    {
        farmerproducts objproduct = (new Cls_farmerproducts_b().SelectById(id));

        if (objproduct != null)
        {
            txtname.Text = objproduct.name;
        }
    }
        public farmerproducts SelectById(Int64 id)
        {
            SqlDataAdapter da;
            DataSet        ds = new DataSet();
            farmerproducts objfarmerproducts = new farmerproducts();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "farmerproducts_SelectById";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = ConnectionString;
                cmd.Parameters.AddWithValue("@id", id);
                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)
                            {
                                {
                                    //id, name

                                    objfarmerproducts.id   = Convert.ToInt64(ds.Tables[0].Rows[0]["id"]);
                                    objfarmerproducts.name = ds.Tables[0].Rows[0]["name"].ToString();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrHandler.writeError(ex.Message, ex.StackTrace);
                return(null);
            }
            finally
            {
                ConnectionString.Close();
            }
            return(objfarmerproducts);
        }
Ejemplo n.º 4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Int64          Result     = 0;
        farmerproducts objproduct = new farmerproducts();

        objproduct.name = txtname.Text;

        if (Request.QueryString["id"] != null)
        {
            objproduct.id = Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true));
            Result        = (new Cls_farmerproducts_b().Update(objproduct));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/managecollectionproducts.aspx?mode=u"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Product Updation Failed...";
                BindFarmer(Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true)));
            }
        }
        else
        {
            Result = (new Cls_farmerproducts_b().Insert(objproduct));
            if (Result > 0)
            {
                Clear();
                Response.Redirect(Page.ResolveUrl("~/managecollectionproducts.aspx?mode=i"));
            }
            else
            {
                Clear();
                spnMessgae.Style.Add("color", "red");
                spnMessgae.InnerText = "Failed To Save The Information...";
            }
        }
    }