Created
June 27, 2014 20:14
-
-
Save niisar/55588e2b9c0f11f4c9ed to your computer and use it in GitHub Desktop.
configure_mail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Web; | |
| using System.Web.UI; | |
| using System.Web.UI.WebControls; | |
| using System.Data; | |
| using System.Data.SqlClient; | |
| using System.Configuration; | |
| public partial class MASTER_configure_mail : System.Web.UI.Page | |
| { | |
| ClassData clsdt = new ClassData(); | |
| #region variable | |
| SqlCommand command; | |
| SqlDataAdapter da; | |
| DataSet ds; | |
| #endregion variable | |
| #region events | |
| protected void Page_Load(object sender, EventArgs e) | |
| { | |
| if (!Page.IsPostBack) | |
| { | |
| BindGrid(); | |
| } | |
| } | |
| protected void grdView_PageIndexChanging(object sender, GridViewPageEventArgs e) | |
| { | |
| grdView.PageIndex = e.NewPageIndex; | |
| BindGrid(); | |
| } | |
| protected void grdView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) | |
| { | |
| grdView.EditIndex = -1; | |
| BindGrid(); | |
| } | |
| protected void grdView_RowCommand(object sender, GridViewCommandEventArgs e) | |
| { | |
| if (e.CommandName.Equals("Add")) | |
| { | |
| TextBox txtname = (TextBox)grdView.FooterRow.FindControl("txtAddname"); | |
| TextBox txtmail = (TextBox)grdView.FooterRow.FindControl("txtaddmail"); | |
| DropDownList drpteam = (DropDownList)grdView.FooterRow.FindControl("drpaddteam"); | |
| TextBox txtpin = (TextBox)grdView.FooterRow.FindControl("txtAddpin"); | |
| TextBox txtmob = (TextBox)grdView.FooterRow.FindControl("txtaddmob"); | |
| CheckBox chkactive = (CheckBox)grdView.FooterRow.FindControl("ckaddactive"); | |
| string name, mail, mob, active; | |
| string team, pin; | |
| name = txtname.Text; | |
| mail = txtmail.Text; | |
| team = drpteam.Text; | |
| pin = txtpin.Text; | |
| mob = txtmob.Text; | |
| active = chkactive.Text; | |
| addmailmst(name, mail, team, pin, mob, active); | |
| grdView.EditIndex = -1; | |
| BindGrid(); | |
| } | |
| } | |
| protected void grdView_RowDeleting(object sender, GridViewDeleteEventArgs e) | |
| { | |
| Label id = (Label)grdView.Rows[e.RowIndex].FindControl("lblID"); | |
| string strid = id.Text; | |
| Delete(strid); | |
| grdView.EditIndex = -1; | |
| BindGrid(); | |
| } | |
| protected void grdView_RowEditing(object sender, GridViewEditEventArgs e) | |
| { | |
| grdView.EditIndex = e.NewEditIndex; | |
| BindGrid(); | |
| // DropDownList uteam = (DropDownList)grdView.Rows[e.RowIndex].FindControl("drpteam"); | |
| //DropDownList drpteam = (DropDownList)grdView.FooterRow.FindControl("drpaddteam"); | |
| //DropDownList dropdownteam = (DropDownList)grdView.Rows[e.NewEditIndex].Cells[2].FindControl("drpaddteam"); | |
| DropDownList dropdownteam = (DropDownList)grdView.Rows[e.NewEditIndex].FindControl("drpteam"); | |
| dropdown("SELECT * FROM COM_MST WHERE COM_CTCD = (SELECT COM_CTCD FROM COM_TYP WHERE COM_CTNM = 'TEAM')", dropdownteam, "COM_CMCD", "COM_CMNM"); | |
| } | |
| protected void grdView_RowUpdating(object sender, GridViewUpdateEventArgs e) | |
| { | |
| Label uid = (Label)grdView.Rows[e.RowIndex].FindControl("lblID"); | |
| TextBox uname = (TextBox)grdView.Rows[e.RowIndex].FindControl("txtName"); | |
| TextBox umail = (TextBox)grdView.Rows[e.RowIndex].FindControl("txtaddmail"); | |
| DropDownList uteam = (DropDownList)grdView.Rows[e.RowIndex].FindControl("drpteam"); | |
| TextBox upin = (TextBox)grdView.Rows[e.RowIndex].FindControl("txtpin"); | |
| TextBox umobile = (TextBox)grdView.Rows[e.RowIndex].FindControl("txtmob"); | |
| CheckBox uck = (CheckBox)grdView.Rows[e.RowIndex].FindControl("ckActive"); | |
| string updid = uid.Text; | |
| string updname = uname.Text; | |
| string updmail = uname.Text; | |
| string updteam = uteam.Text; | |
| if (upin.Text == "") | |
| { | |
| upin.Text = "0"; | |
| } | |
| else | |
| { | |
| } | |
| string updpin = upin.Text; | |
| string updmobile = umobile.Text; | |
| string updck = uck.Checked.ToString(); | |
| updatemail(updid, updname, updmail, updpin, updteam, updmobile, updck); | |
| grdView.EditIndex = -1; | |
| BindGrid(); | |
| } | |
| protected void grdView_RowCreated(object sender, GridViewRowEventArgs e) | |
| { | |
| if (e.Row.RowType == DataControlRowType.Footer) | |
| { | |
| var team = e.Row.FindControl("drpaddteam") as DropDownList; | |
| if (null != team) | |
| { | |
| dropdown("SELECT * FROM COM_MST WHERE COM_CTCD = (SELECT COM_CTCD FROM COM_TYP WHERE COM_CTNM = 'TEAM')", team, "COM_CMCD", "COM_CMNM"); | |
| } | |
| } | |
| } | |
| #endregion events | |
| #region function | |
| protected void BindGrid() | |
| { | |
| command = new SqlCommand(); | |
| clsdt.sqlCnn.Open(); | |
| command.Connection = clsdt.sqlCnn; | |
| command.CommandType = CommandType.StoredProcedure; | |
| command.CommandText = "USP_CRUD_MAIL_MST"; | |
| command.Parameters.Add(new SqlParameter("@status", SqlDbType.VarChar, 50)); | |
| command.Parameters["@status"].Value = "Display"; | |
| da = new SqlDataAdapter(command); | |
| ds = new DataSet(); | |
| da.Fill(ds); | |
| grdView.DataSource = ds; | |
| grdView.DataBind(); | |
| clsdt.sqlCnn.Close(); | |
| } | |
| protected void addmailmst(string name, string mail, string team, string pin, string mob, string active) | |
| { | |
| clsdt.sqlCnn.Open(); | |
| command = new SqlCommand(); | |
| command.Connection = clsdt.sqlCnn; | |
| command.CommandType = CommandType.StoredProcedure; | |
| command.CommandText = "USP_CRUD_MAIL_MST"; | |
| command.Parameters.Add(new SqlParameter("@Status", SqlDbType.VarChar, 50)); | |
| command.Parameters.Add(new SqlParameter("@mlmName", SqlDbType.VarChar, 60)); | |
| command.Parameters.Add(new SqlParameter("@mlmAddress", SqlDbType.VarChar, 60)); | |
| command.Parameters.Add(new SqlParameter("@mlmTeam", SqlDbType.Int, 4)); | |
| command.Parameters.Add(new SqlParameter("@mlmPin", SqlDbType.Int, 4)); | |
| command.Parameters.Add(new SqlParameter("@mlmMobile", SqlDbType.VarChar, 12)); | |
| command.Parameters.Add(new SqlParameter("@mlmActive", SqlDbType.VarChar, 12)); | |
| command.Parameters["@Status"].Value = "ADD"; | |
| command.Parameters["@mlmName"].Value = name; | |
| command.Parameters["@mlmAddress"].Value = mail; | |
| command.Parameters["@mlmTeam"].Value = team; | |
| command.Parameters["@mlmPin"].Value = pin; | |
| command.Parameters["@mlmMobile"].Value = mob; | |
| command.Parameters["@mlmActive"].Value = active; | |
| da = new SqlDataAdapter(command); | |
| ds = new DataSet(); | |
| da.Fill(ds); | |
| clsdt.sqlCnn.Close(); | |
| } | |
| public void dropdown(string qry, DropDownList drp, string value_field, string text_field) | |
| { | |
| DataTable dt = new DataTable(); | |
| dt = clsdt.getDataTable(qry); | |
| drp.DataSource = dt; | |
| drp.DataTextField = text_field; | |
| drp.DataValueField = value_field; | |
| drp.DataBind(); | |
| } | |
| protected void Delete(string id) | |
| { | |
| clsdt.sqlCnn.Open(); | |
| command = new SqlCommand(); | |
| command.Connection = clsdt.sqlCnn; | |
| command.CommandType= CommandType.StoredProcedure; | |
| command.CommandText = "USP_CRUD_MAIL_MST"; | |
| command.Parameters.Add(new SqlParameter("@Status", SqlDbType.VarChar, 50)); | |
| command.Parameters.Add(new SqlParameter("@mlmId", SqlDbType.Int)); | |
| command.Parameters["@Status"].Value = "Delete"; | |
| command.Parameters["@mlmId"].Value = id; | |
| da = new SqlDataAdapter(command); | |
| ds = new DataSet(); | |
| da.Fill(ds); | |
| clsdt.sqlCnn.Close(); | |
| } | |
| protected void updatemail(string uid, string uname, string umail, string upin, string uteam, string umob, string uck) | |
| { | |
| clsdt.sqlCnn.Open(); | |
| command = new SqlCommand(); | |
| command.Connection = clsdt.sqlCnn; | |
| command.CommandType = CommandType.StoredProcedure; | |
| command.CommandText = "USP_CRUD_MAIL_MST"; | |
| command.Parameters.Add(new SqlParameter("@Status", SqlDbType.VarChar, 50)); | |
| command.Parameters.Add(new SqlParameter("@mlmId", SqlDbType.Int,4)); | |
| command.Parameters.Add(new SqlParameter("@mlmName", SqlDbType.VarChar, 60)); | |
| command.Parameters.Add(new SqlParameter("@mlmAddress", SqlDbType.VarChar, 60)); | |
| command.Parameters.Add(new SqlParameter("@mlmPin", SqlDbType.Int, 4)); | |
| command.Parameters.Add(new SqlParameter("@mlmTeam",SqlDbType.Int,4)); | |
| command.Parameters.Add(new SqlParameter("@mlmMobile", SqlDbType.VarChar, 12)); | |
| command.Parameters.Add(new SqlParameter("@mlmActive", SqlDbType.VarChar, 12)); | |
| command.Parameters["@Status"].Value = "Update"; | |
| command.Parameters["@mlmId"].Value = Convert.ToInt32(uid.ToString()); | |
| command.Parameters["@mlmName"].Value = uname; | |
| command.Parameters["@mlmAddress"].Value = umail; | |
| command.Parameters["@mlmPin"].Value = upin; | |
| command.Parameters["@mlmTeam"].Value = uteam; | |
| command.Parameters["@mlmMobile"].Value = umob; | |
| command.Parameters["@mlmActive"].Value = uck; | |
| da = new SqlDataAdapter(command); | |
| ds = new DataSet(); | |
| da.Fill(ds); | |
| clsdt.sqlCnn.Close(); | |
| } | |
| #endregion function | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment