public Int64 Update(groupmaster objgroupmaster) { Int64 result = 0; try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "groupmaster_Update"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = ConnectionString; SqlParameter param = new SqlParameter(); param.ParameterName = "@id"; param.Value = objgroupmaster.id; param.SqlDbType = SqlDbType.Int; param.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(param); cmd.Parameters.AddWithValue("@groupname", objgroupmaster.groupname); 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); }
public void BindBank(Int64 id) { groupmaster objgroupmaster = (new Cls_groupmaster_b().SelectById(id)); if (objgroupmaster != null) { txtgroupname.Text = objgroupmaster.groupname; } }
public groupmaster SelectById(Int64 id) { SqlDataAdapter da; DataSet ds = new DataSet(); groupmaster objgroupmaster = new groupmaster(); try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = "groupmaster_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) { { objgroupmaster.id = Convert.ToInt32(ds.Tables[0].Rows[0]["id"]); objgroupmaster.groupname = Convert.ToString(ds.Tables[0].Rows[0]["groupname"]); } } } } } } catch (Exception ex) { ErrHandler.writeError(ex.Message, ex.StackTrace); return(null); } finally { ConnectionString.Close(); } return(objgroupmaster); }
protected void btnSave_Click(object sender, EventArgs e) { Int64 Result = 0; groupmaster objgroupmaster = new groupmaster(); objgroupmaster.groupname = txtgroupname.Text.Trim(); if (Request.QueryString["id"] != null) { objgroupmaster.id = Convert.ToInt32(ocommon.Decrypt(Request.QueryString["id"].ToString(), true)); Result = (new Cls_groupmaster_b().Update(objgroupmaster)); if (Result > 0) { Clear(); Response.Redirect(Page.ResolveUrl("~/managegroup.aspx?mode=u")); } else { Clear(); spnMessgae.Style.Add("color", "red"); spnMessgae.InnerText = "Failed To Upadate Group"; BindBank(Convert.ToInt64(ocommon.Decrypt(Request.QueryString["id"].ToString(), true))); } } else { Result = (new Cls_groupmaster_b().Insert(objgroupmaster)); if (Result > 0) { Clear(); Response.Redirect(Page.ResolveUrl("~/managegroup.aspx?mode=i")); } else { Clear(); spnMessgae.Style.Add("color", "red"); spnMessgae.InnerText = "Failed To Create Group"; } } }