protected void BindApis() { try { objBAL = new ClsBAL(); ObjDataset = (DataSet)objBAL.GetCommissionApis(); if (ObjDataset != null) { ViewState["CommissionApis"] = ObjDataset.Tables[0]; GvCommissions.DataSource = ObjDataset.Tables[0]; GvCommissions.DataBind(); if (ObjDataset.Tables[0].Rows.Count > 0) { lbtnXport2Xcel.Visible = true; } else { lbtnXport2Xcel.Visible = false; } } } catch (Exception ex) { objBAL.Logerror(this.Page.ToString(), "BindApis", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw ex; } finally { if (ObjDataset != null) { ObjDataset = null; } if (ObjDataset1 != null) { ObjDataset1 = null; } if (ObjDatatable != null) { ObjDatatable = null; } if (ObjDataview != null) { ObjDataview = null; } } }
protected void GetBusHireDetails() { try { tdmsg.Visible = false; lblMainMsg.Text = ""; objManabusBAL = new ClsBAL(); ObjDataset = objManabusBAL.GetBusHireDetails(); if (ObjDataset != null) { if (ObjDataset.Tables[0].Rows.Count > 0) { ViewState["BusHires"] = ObjDataset.Tables[0]; lbtnXport2Xcel.Enabled = ddlPageSize.Enabled = true; } else { lbtnXport2Xcel.Enabled = ddlPageSize.Enabled = false; } GvBusHires.DataSource = ObjDataset.Tables[0]; GvBusHires.DataBind(); } } catch (Exception ex) { objManabusBAL.Logerror(this.Page.ToString(), "GetBusHireDetails", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw ex; } finally { if (ObjDataset != null) { ObjDataset = null; } } }
protected void btnUpdateUD_Click(object sender, EventArgs e) { try { tdmsg.Visible = false; lblMainMsg.Text = ""; objBAL = new ClsBAL(); objBAL.UpdateAgentByAgent(txtName.Text.Trim(), "", Convert.ToDateTime("1/1/1900"), txtCity.Text.Trim().ToString(), ddlState.SelectedItem.Text.ToString(), txtAddress.Text.Trim().ToString(), txtPinCode.Text.Trim().ToString(), txtMobileNo.Text.Trim().ToString(), "", "", txtEmailId.Text.Trim().ToString(), "", "", "1", txtPassword.Text.Trim().ToString(), Convert.ToInt32(lblID.Text), 0, 0); //if (ViewState["Users"] != null) //{ // ObjDatatable = (DataTable)ViewState["Users"]; // ObjDataview = new DataView(ObjDatatable); // ObjDataview.RowFilter = "UserName='******'"; // if (ObjDataview.Count > 0) // { // tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#E77471;", ""); // lblMainMsg.Text = "Username not Available ..."; // lblMainMsg.ForeColor = System.Drawing.Color.Maroon; // //GvCommissions.DataSource = ViewState["Roles"]; // //GvCommissions.DataBind(); // } // else // { // objBAL = new ClsBAL(); // objBAL.ID = Convert.ToInt32(lblID.Text); // objBAL.userName = txtUsername.Text; // objBAL.password = txtPassword.Text; // objBAL.name = txtName.Text; // objBAL.roleId = Convert.ToInt32(ddlRole.SelectedValue); // objBAL.modifiedBy = Convert.ToInt32(Session["UserID"]); // if (objBAL.UpdateUser()) // { tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#6CC417;", ""); lblMainMsg.Text = "User details updated Successfully...."; lblMainMsg.ForeColor = System.Drawing.Color.Green; BindUsers(); MVUsers.ActiveViewIndex = 0; MVUsers.Visible = true; // } // else // { // tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#E77471;", ""); // lblMainMsg.Text = "OOPS...Failed to update user setails...."; // lblMainMsg.ForeColor = System.Drawing.Color.Maroon; // MVUsers.Visible = true; // } // } // } } catch (Exception ex) { objBAL.Logerror(this.Page.ToString(), "btnUpdateUD_Click", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw ex; } }
protected void btnSaveUD_Click(object sender, EventArgs e) { try { tdmsg.Visible = false; lblMainMsg.Text = ""; tdmsg.Visible = false; lblMainMsg.Text = ""; string message = ""; objBAL = new ClsBAL(); message = objBAL.AddAgent(txtName.Text.Trim(), "", Convert.ToDateTime("1/1/1900"), txtCity.Text.Trim().ToString(), ddlState.SelectedItem.Text.ToString(), txtAddress.Text.Trim().ToString(), txtPinCode.Text.Trim().ToString(), txtMobileNo.Text.Trim().ToString(), "", "", txtEmailId.Text.Trim().ToString(), "", "", "1", txtUsername.Text.Trim().ToString(), txtPassword.Text.Trim().ToString(), 0, 0, Convert.ToInt32("0"), "CSE", ddlcountry.SelectedValue,"","","","","",""); // lblMainMsg.Text = message; if (message == "Agent registration is completed successfully.") { Label1.Text = "CSE Registration is Completed Successfully"; mail(); BindUsers(); Cleardata(); MVUsers.ActiveViewIndex = 0; MVUsers.Visible = true; lblMainMsg.ForeColor = System.Drawing.Color.Green; } else { lblMainMsg.ForeColor = System.Drawing.Color.Red; tdmsg.Visible = true; lblMainMsg.Text = message; } } catch (Exception ex) { objBAL.Logerror(this.Page.ToString(), "btnSaveUD_Click", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw ex; } }
protected void btnSavePermissions_Click(object sender, EventArgs e) { try { tdmsg.Visible = false; lblMainMsg.Text = ""; foreach (GridViewRow row in GvPermissions.Rows) { Label lblScrnID = (Label)row.FindControl("lblScreenID"); Label lblScrnName = (Label)row.FindControl("lblScreenName"); CheckBox ChkAdd1 = (CheckBox)row.FindControl("ChkAdd"); //CheckBox ChkView1 = (CheckBox)row.FindControl("ChkView"); //CheckBox ChkDelete1 = (CheckBox)row.FindControl("ChkDelete"); //CheckBox ChkEdit1 = (CheckBox)row.FindControl("ChkEdit"); //CheckBox ChkPermissions1 = (CheckBox)row.FindControl("ChkPermissions"); objBAL = new ClsBAL(); objBAL.ID = Convert.ToInt32(lblUserID.Text); objBAL.screenID = Convert.ToInt32(lblScrnID.Text); //if (lblScrnName.Text == "Ticket") //{ // if (ChkAdd1.Checked == true) // { // objBAL.book = Convert.ToInt32(1); // } // else if (ChkAdd1.Checked == false) // { // objBAL.book = Convert.ToInt32(0); // } //if (ChkEdit1.Checked) //{ // objBAL.cancel = Convert.ToInt32(1); //} //else if (ChkEdit1.Checked == false) //{ // objBAL.cancel = Convert.ToInt32(0); //} //} //else //{ if (ChkAdd1.Checked == true) { objBAL.book = Convert.ToInt32(1); } else if (ChkAdd1.Checked == false) { objBAL.book = Convert.ToInt32(0); } //if (ChkEdit1.Checked) //{ // objBAL.edit = Convert.ToInt32(1); //} //else if (ChkEdit1.Checked == false) //{ // objBAL.edit = Convert.ToInt32(0); //} // } //if (ChkDelete1.Checked == true) //{ // objBAL.delete = Convert.ToInt32(1); //} //else if (ChkDelete1.Checked == false) //{ // objBAL.delete = Convert.ToInt32(0); //} //if (ChkPermissions1.Checked == true) //{ // objBAL.permissions = Convert.ToInt32(1); //} //else if (true) //{ // objBAL.permissions = Convert.ToInt32(0); //} //if (ChkView1.Checked == true) //{ // objBAL.view = Convert.ToInt32(1); //} //else if (ChkView1.Checked == false) //{ // objBAL.view = Convert.ToInt32(0); //} objBAL.createdBy = Convert.ToInt32(1); objBAL.modifiedBy = Convert.ToInt32(1); if (objBAL.AddPermissions()) { tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#6CC417;", ""); lblMainMsg.Text = "Permissions details saved Successfully...."; lblMainMsg.ForeColor = System.Drawing.Color.Green; MVUsers.ActiveViewIndex = 0; } else { tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#E77471;", ""); lblMainMsg.Text = "OOPS...Failed to set Permissions setails...."; lblMainMsg.ForeColor = System.Drawing.Color.Maroon; break; } } } catch (Exception ex) { objBAL.Logerror(this.Page.ToString(), "btnSavePermissions_Click", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw ex; } finally { MVUsers.ActiveViewIndex = 0; MVUsers.Visible = true; } }
protected void GvUsers_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Change") { tdmsg.Visible = false; lblMainMsg.Text = ""; // int index = Convert.ToInt32(e.CommandArgument); // Retrieve the row that contains the button clicked // by the user from the Rows collection. // GridViewRow row = GvUsers.Rows[index]; try { //if (ViewState["UserPermissions"] != null) //{ //if (ViewState["EditUser"].ToString() == "1") //{ GridViewRow gRow = (GridViewRow)(((Button)e.CommandSource).NamingContainer); // GridViewRow gRow = (GridViewRow)(Label)e.CommandSource; Label lblUserName1 = (Label)gRow.FindControl("lblUserName"); Label lblName1 = (Label)gRow.FindControl("lblName"); LinkButton lblRoleID1 = (LinkButton)gRow.FindControl("lblRoleID"); Label lblID1 = (Label)gRow.FindControl("lblID"); Label lblPassword1 = (Label)gRow.FindControl("lblPassword"); Label lblEmailId = (Label)gRow.FindControl("lblEmailId"); Label lblAddress = (Label)gRow.FindControl("lblAddress"); Label lblCity = (Label)gRow.FindControl("lblCity"); Label lblState = (Label)gRow.FindControl("lblState"); Label lblCountry = (Label)gRow.FindControl("lblCountry"); Label lblPinCode = (Label)gRow.FindControl("lblPinCode"); Label lblMobileNo = (Label)gRow.FindControl("lblMobileNo"); txtUsername.Text = lblUserName1.Text; txtName.Text = lblName1.Text; ddlRole.SelectedValue = lblRoleID1.Text; lblID.Text = lblID1.Text; txtPassword.Text = lblPassword1.Text; txtCnfrmPswd.Text = lblPassword1.Text; txtCnfrmPswd.TextMode = TextBoxMode.SingleLine; txtPassword.TextMode = TextBoxMode.SingleLine; txtUsername.Enabled = false; txtEmailId.Text = lblEmailId.Text; txtAddress.Text = lblAddress.Text; txtCity.Text = lblCity.Text; ddlState.Text = lblState.Text; ddlcountry.Text = lblCountry.Text; txtPinCode.Text = lblPinCode.Text; txtMobileNo.Text = lblMobileNo.Text; btnSaveUD.Visible = false; btnCancel.Visible = true; btnUpdateUD.Visible = true; BindRoles(); MVUsers.ActiveViewIndex = 1; MVUsers.Visible = true; //} //else //{ // tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#E77471;", ""); // lblMainMsg.Text = " No Permission to Edit Users.Please Contact Administrator for further details..."; // lblMainMsg.ForeColor = System.Drawing.Color.Maroon; // MVUsers.ActiveViewIndex = 0; // MVUsers.Visible = true; //} // } } catch (Exception ex) { objBAL.Logerror(this.Page.ToString(), "GvUsers_RowCommand_Change", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw; } #region TEst //System.Text.StringBuilder sb = new System.Text.StringBuilder(); //sb.Append(@"<script language='javascript'>"); //sb.Append(@"$(document).ready(function () {"); //sb.Append(@"$('[id$='txtUsername']').val ="); //sb.Append(lblUserName1.Text); //sb.Append(@";$('[id$='txtName']').val = "); //sb.Append(lblName1.Text); //sb.Append(@";$('[id$='txtPassword']').val ="); //sb.Append(lblPassword1.Text); //sb.Append(@";$('[id$='txtCnfrmPswd']').val ="); //sb.Append(lblPassword1.Text); //sb.Append(@";$('[id$='ddlRole']').val ="); //sb.Append(lblRoleID1.Text); //sb.Append(@"$('.adduser').show('slow');"); //sb.Append(@"$('.abc').hide('slow');"); //sb.Append(@"$('[id$='btnSaveUD']').hide('slow');"); //sb.Append(@"$('[id$='btnUpdateUD']').show('slow');"); //sb.Append(@"});});"); //sb.Append(@"</script>"); //ScriptManager.RegisterStartupScript(GvUsers, GvUsers.GetType(), "JSCR", sb.ToString(), false); #endregion } if (e.CommandName == "Remove") { tdmsg.Visible = false; lblMainMsg.Text = ""; try { //if (ViewState["UserPermissions"] != null) //{ //if (ViewState["DeleteUser"].ToString() == "1") //{ GridViewRow gRow = (GridViewRow)(((Button)e.CommandSource).NamingContainer); // GridViewRow gRow = (GridViewRow)(Label)e.CommandSource; Label lblID1 = (Label)gRow.FindControl("lblID"); objBAL = new ClsBAL(); objBAL.ID = Convert.ToInt32(lblID1.Text); objBAL.modifiedBy = Convert.ToInt32(1); if (objBAL.DeleteUser()) { tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#6CC417;", ""); lblMainMsg.Text = "User details Deleted Successfully...."; lblMainMsg.ForeColor = System.Drawing.Color.Green; BindUsers(); MVUsers.Visible = true; } else { tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#E77471;", ""); lblMainMsg.Text = "OOPS...Failed to Delete user setails...."; lblMainMsg.ForeColor = System.Drawing.Color.Maroon; } //} //else //{ // tdmsg.Visible = true; // tdmsg.Style.Add("background-color:#E77471;", ""); // lblMainMsg.Text = " No Permission to delete Users.Please Contact Administrator for further details..."; // lblMainMsg.ForeColor = System.Drawing.Color.Maroon; // MVUsers.ActiveViewIndex = 0; // MVUsers.Visible = true; //} // } } catch (Exception ex) { objBAL.Logerror(this.Page.ToString(), "GvUsers_RowCommand_Remove", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw; } } if (e.CommandName == "Permissions") { tdmsg.Visible = false; lblMainMsg.Text = ""; try { GridViewRow gRow = (GridViewRow)(((Button)e.CommandSource).NamingContainer); Label lblUserName1 = (Label)gRow.FindControl("lblUserName"); Label lblName1 = (Label)gRow.FindControl("lblName"); Label lblRole1 = (Label)gRow.FindControl("lblRole"); Label lblID1 = (Label)gRow.FindControl("lblID"); Label lblPassword1 = (Label)gRow.FindControl("lblPassword"); lblRolePer.Text = lblRole1.Text; lblUserNamePer.Text = lblUserName1.Text; lblUserID.Text = lblID1.Text; objBAL = new ClsBAL(); objBAL.ID = Convert.ToInt32(lblID1.Text); ObjDataset = (DataSet)objBAL.GetScreens(); if (ObjDataset != null) { if (ObjDataset.Tables[0].Rows.Count > 0) { ViewState["Screens"] = ObjDataset.Tables[0]; ObjDataset1 = (DataSet)objBAL.GetUserPermissions(); if (ObjDataset1 != null) { ViewState["Permissions"] = ObjDataset1.Tables[0]; } GvPermissions.DataSource = ObjDataset.Tables[0]; GvPermissions.DataBind(); MVUsers.ActiveViewIndex = 2; } else { ViewState["Permissions"] = null; objBAL = new ClsBAL(); ObjDataset1 = (DataSet)objBAL.GetScreens(); if (ObjDataset1 != null) { GvPermissions.DataSource = ObjDataset1.Tables[0]; GvPermissions.DataBind(); MVUsers.ActiveViewIndex = 2; } } } else { ViewState["Permissions"] = null; objBAL = new ClsBAL(); ObjDataset1 = (DataSet)objBAL.GetScreens(); if (ObjDataset1 != null) { GvPermissions.DataSource = ObjDataset1.Tables[0]; GvPermissions.DataBind(); MVUsers.ActiveViewIndex = 2; } } } catch (Exception ex) { objBAL.Logerror(this.Page.ToString(), "GvUsers_RowCommand_Permissions", ex.Message.ToString(), Convert.ToString(ex.InnerException), Convert.ToString(Request.UserHostAddress.ToString()), DateTime.Now); throw; } finally { if (ObjDataset != null) { ObjDataset = null; } if (ObjDataset1 != null) { ObjDataset1 = null; } if (ObjDatatable != null) { ObjDatatable = null; } if (ObjDataview != null) { ObjDataview = null; } } } }