protected void imgDelete_Click(object sender, ImageClickEventArgs e) { GridViewRow gvr = (GridViewRow)((ImageButton)sender).NamingContainer; int _iID = Convert.ToInt32(gvCriticalDTC.DataKeys[gvr.RowIndex].Values["crt_DTC_PK"]); string _sQry = "delete from tab_CA_CRITICAL_DTC_ADD where crt_DTC_PK=" + _iID; SqlConnection _objCon = new SqlConnection(ConnectionString.GetDBConnectionString()); try { if (_objCon.State != ConnectionState.Open) { _objCon.Open(); } DBL.executeNonQuery(_objCon, CommandType.Text, _sQry, null); Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "$(function() { funShowMessage('Vehicle DTC Logic Deleted successfully'); });", true); } catch { } finally { BindCriticalDTC(); if (_objCon.State != ConnectionState.Closed) { _objCon.Close(); } _objCon.Dispose(); } }
protected void imgDelete_Click(object sender, ImageClickEventArgs e) { GridViewRow gvr = (GridViewRow)((ImageButton)sender).NamingContainer; int _iID = Convert.ToInt32(gvLogicDTC.DataKeys[gvr.RowIndex].Values["dtc_LOGIC_ADD_PK"]); using (miniSmartDataContext db = new miniSmartDataContext()) { var DTCAdd = from d in db.tab_CA_EMS_DTC_LOGIC_ADDs where d.dtc_LOGIC_ADD_PK == _iID select new { d.dtc_DTC_CODE, d.dtc_LOGIC, d.dtc_LOGIC_THRESHOLD }; if (DTCAdd != null) { foreach (var d in DTCAdd) { var DTCCount = (from c in db.tab_CA_EMS_DTC_LOGIC_BUILDs where c.dtc_DTC_CODE_A + "_" + c.dtc_DTC_LOGIC_A == d.dtc_DTC_CODE + "_" + d.dtc_LOGIC || c.dtc_DTC_CODE_B + "_" + c.dtc_DTC_LOGIC_B == d.dtc_DTC_CODE + "_" + d.dtc_LOGIC || c.dtc_DTC_CODE_C + "_" + c.dtc_DTC_LOGIC_C == d.dtc_DTC_CODE + "_" + d.dtc_LOGIC || c.dtc_DTC_CODE_D + "_" + c.dtc_DTC_LOGIC_D == d.dtc_DTC_CODE + "_" + d.dtc_LOGIC select c.dtc_LOGIC_BUILD_PK).Count(); if (DTCCount > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "$(function() { funShowMessage('DTC Logic Builded Already'); });", true); } else { string _sQry = "delete from tab_CA_EMS_DTC_LOGIC_ADD where dtc_LOGIC_ADD_PK=" + _iID; SqlConnection _objCon = new SqlConnection(ConnectionString.GetDBConnectionString()); try { if (_objCon.State != ConnectionState.Open) { _objCon.Open(); } DBL.executeNonQuery(_objCon, CommandType.Text, _sQry, null); Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "$(function() { funShowMessage('DTC Logic Deleted successfully'); });", true); } catch { } finally { BindLogicDTC(); if (_objCon.State != ConnectionState.Closed) { _objCon.Close(); } _objCon.Dispose(); } } break; } } } }
protected void btnSavePassword_OnClick(object sender, EventArgs e) { lblMsg.Text = ""; if (Page.IsValid) { string _sReadPass = "", _sEncOldPass = "", _sEncNewPass = ""; secureData _objSecure = new secureData(); _sEncOldPass = _objSecure.DESEncrypt(txtOldPwd.Text); _sEncNewPass = _objSecure.DESEncrypt(txtNewPwd.Text); _objSecure = null; string _sCommandText = "select user_PASSWORD from tab_m_ADMIN_USER where user_PASSWORD ='******' and user_ID_PK=" + Convert.ToInt32(Session["AccessCode"]); object _oRes = DBL.executeScalar(Connectionstring, CommandType.Text, _sCommandText); if (_oRes != DBNull.Value) { _sReadPass = Convert.ToString(_oRes); } bool _bValidatePwd = true; if (_bValidatePwd == true) { if (_sReadPass == _sEncOldPass) { string _sQuery = "Update tab_m_ADMIN_USER set user_PASSWORD='******' where user_ID_PK=" + Convert.ToInt32(Session["AccessCode"]); int _iSuccess = 0; SqlConnection _objCon = new SqlConnection(Connectionstring); try { if (_objCon.State != ConnectionState.Open) { _objCon.Open(); } _iSuccess = DBL.executeNonQuery(_objCon, CommandType.Text, _sQuery, null); } catch { } finally { if (_objCon.State != ConnectionState.Closed) { _objCon.Close(); } _objCon.Dispose(); } if (_iSuccess > 0) { Session.Abandon(); Response.Redirect("~/default.aspx?err=SPC"); } else { Response.Redirect("~/default.aspx?err=E00A"); } } else { lblMsg.Text = "Old Password is wrong"; } } } }