Ejemplo n.º 1
0
    // Handler grvwObj_RowUpdating handling GridView RowUpdating  Event
    protected void grvwObj_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //Declare local variables of name,id and stateid
        string name, id;
        int    stateid, count = 0;

        // Assign state name to local variable name
        name = ((TextBox)grvwObj.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
        // Assign State id to local variable id
        id = Convert.ToString(grvwObj.Rows[e.RowIndex].Cells[0].Text);
        DropDownList Countrydrp = ((DropDownList)grvwObj.Rows[e.RowIndex].Cells[3].FindControl("dropCountry"));
        // Declare local variable countryid and assign from drop down selected value
        int countryid = Convert.ToInt32(Countrydrp.SelectedValue);

        stateid  = Convert.ToInt32(id);
        count    = objState.Get_By_StateName(name);
        objState = objState.Get_By_Stateid(stateid);

        if ((count == 0) && (name != ""))
        {
            objState.Stateid   = stateid;
            objState.Countryid = countryid;
            objState.Statename = name;
            objState.Update();
            grvwObj.EditIndex = -1;
            BindGrid();
            lblerrmsg.Text = Resources.MessageResource.errupdate.ToString();
        }
        else if (objState.Statename == name)
        {
            objState.Stateid   = stateid;
            objState.Countryid = countryid;
            objState.Statename = name;
            objState.Update();
            grvwObj.EditIndex = -1;
            BindGrid();
            lblerrmsg.Text = Resources.MessageResource.errupdate.ToString();
        }
        else if (name == "")
        {
            lblerrmsg.Text = Resources.MessageResource.errnotempty.ToString();
        }
        else
        {
            lblerrmsg.Text = Resources.MessageResource.erralready.ToString();
        }
    }
    // Handler grvwObj_RowUpdating handling GridView RowUpdating  Event
    protected void grvwObj_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        //Declare local variables of name,id and stateid
        string name,  id;
        int stateid, count=0;
        // Assign state name to local variable name
        name = ((TextBox)grvwObj.Rows[e.RowIndex].Cells[1].Controls[0]).Text;
        // Assign State id to local variable id
        id = Convert.ToString(grvwObj.Rows[e.RowIndex].Cells[0].Text);
        DropDownList Countrydrp = ((DropDownList)grvwObj.Rows[e.RowIndex].Cells[3].FindControl("dropCountry"));
        // Declare local variable countryid and assign from drop down selected value
        int countryid = Convert.ToInt16(Countrydrp.SelectedValue);
        stateid = Convert.ToInt16(id);
        count = objState.Get_By_StateName(name);
        objState = objState.Get_By_Stateid(stateid);

        if ((count == 0) && (name != ""))
        {
            objState.Stateid = stateid;
            objState.Countryid = countryid;
            objState.Statename = name;
            objState.Update();
            grvwObj.EditIndex = -1;
            BindGrid();
            lblerrmsg.Text = Resources.MessageResource.errupdate.ToString();
        }
        else if (objState.Statename == name)
        {
            objState.Stateid = stateid;
            objState.Countryid = countryid;
            objState.Statename = name;
            objState.Update();
            grvwObj.EditIndex = -1;
            BindGrid();
            lblerrmsg.Text = Resources.MessageResource.errupdate.ToString();
        }
        else if (name == "")
        {
            lblerrmsg.Text = Resources.MessageResource.errnotempty.ToString();
        }
        else
        {
            lblerrmsg.Text = Resources.MessageResource.erralready.ToString();
        }
    }
 public int Update_State_mst_By_id(State_mst objState)
 {
     return (int)ExecuteNonQuery(Sp_State_Update, new object[] { objState.Statename, objState.Stateid, objState.Countryid });
 }
 public int Insert_State_mst(State_mst objState)
 {
     return (int)ExecuteNonQuery(Sp_State_Insert, new object[] { objState.Statename, objState.Countryid });
 }
    public object GenerateState_mstObject(ref IDataReader returnData)
    {
        State_mst obj = new State_mst();
        while (returnData.Read())
        {
            obj.Countryid = (int)returnData["countryid"];
            obj.Stateid = (int)returnData["stateid"];
            obj.Statename = (string)returnData["statename"];

        }
        returnData.Close();
        returnData.Dispose();
        return obj;
    }
 public CollectionBase GenerateState_mstCollection(ref IDataReader returnData)
 {
     BLLCollection<State_mst> col = new BLLCollection<State_mst>();
     while (returnData.Read())
     {
         State_mst obj = new State_mst();
         obj.Stateid = (int)returnData["Stateid"];
         obj.Statename = (string)returnData["Statename"];
         obj.Countryid = (int)returnData["Countryid"];
         col.Add(obj);
     }
     returnData.Close();
     returnData.Dispose();
     return col;
 }