private void BindGrid() { PositionMastDAL objPosition = new PositionMastDAL(); var lstGridData = objPosition.SelectForSearch(Convert.ToString(txtPositionName.Text.Trim())); objPosition = null; if (lstGridData != null && lstGridData.Count > 0) { grdMain.DataSource = lstGridData; grdMain.DataBind(); lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count; prints.Visible = false; imgBtnExcel.Visible = false; int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1; int lastRowOnPage = startRowOnPage + grdMain.Rows.Count - 1; lblcontant.Text = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + lstGridData.Count.ToString(); lblcontant.Visible = true; divpaging.Visible = true; } else { grdMain.DataSource = null; grdMain.DataBind(); lblTotalRecord.Text = "T. Record (s): 0 "; imgBtnExcel.Visible = false; lblcontant.Visible = false; divpaging.Visible = false; } }
protected void lnkbtnSave_OnClick(object sender, EventArgs e) { string strMsg = string.Empty; PositionMastDAL objTolMast = new PositionMastDAL(); Int64 intCityIdno = 0; using (TransactionScope Tran = new TransactionScope(TransactionScopeOption.Required)) { if (string.IsNullOrEmpty(hidPositionidno.Value) == true) { intCityIdno = objTolMast.Insert(txtPostionName.Text.Trim(), Convert.ToBoolean(chkStatus.Checked)); } else { intCityIdno = objTolMast.Update(Convert.ToInt64(hidPositionidno.Value), txtPostionName.Text.Trim(), Convert.ToBoolean(chkStatus.Checked)); } objTolMast = null; if (intCityIdno > 0) { ClearControls(); lnkbtnNew.Visible = false; if (string.IsNullOrEmpty(hidPositionidno.Value) == false) { strMsg = "Record updated successfully."; Tran.Complete(); } else { strMsg = "Record saved successfully."; Tran.Complete(); } } else if (intCityIdno < 0) { strMsg = "Record already exists."; Tran.Dispose(); } else { if (string.IsNullOrEmpty(hidPositionidno.Value) == false) { strMsg = "Record not updated."; Tran.Dispose(); } else { strMsg = "Record not saved."; Tran.Dispose(); } } ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); txtPostionName.Focus(); } }
private void Populate(Int64 PositionIdno) { PositionMastDAL objPosit = new PositionMastDAL(); tblPositionMast objPositMast = objPosit.SelectById(PositionIdno); objPosit = null; if (objPositMast != null) { txtPostionName.Text = Convert.ToString(objPositMast.Position_name); chkStatus.Checked = Convert.ToBoolean(objPositMast.IsActive); hidPositionidno.Value = Convert.ToString(objPositMast.Position_id); txtPostionName.Focus(); } }
protected void grdMain_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ImageButton imgBtnStatus = (ImageButton)e.Row.FindControl("imgBtnStatus"); bool status = Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "Status")); LinkButton lnkbtnEdit = (LinkButton)e.Row.FindControl("lnkbtnEdit"); LinkButton lnkbtnDelete = (LinkButton)e.Row.FindControl("lnkbtnDelete"); int postionidno = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "PositIdno")); base.CheckUserRights(intFormId); if (base.Edit == false) { imgBtnStatus.Visible = true; lnkbtnEdit.Visible = false; grdMain.Columns[3].Visible = false; } if (base.Delete == false) { lnkbtnDelete.Visible = false; } if ((base.Edit == false) && (base.Delete == false)) { grdMain.Columns[4].Visible = false; } PositionMastDAL objPosition = new PositionMastDAL(); var ItemExist = objPosition.existOrnot(Convert.ToInt32(postionidno)); if (ItemExist != null && ItemExist > 0) { lnkbtnDelete.Visible = false; } else { lnkbtnDelete.Visible = true; } if (status == false) { imgBtnStatus.ImageUrl = "~/Images/inactive.png"; } else { imgBtnStatus.ImageUrl = "~/Images/active.png"; } } }
protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e) { string strMsg = string.Empty; if (e.CommandName == "cmdedit") { Response.Redirect("TyrePositionMast.aspx?PostionId=" + e.CommandArgument, true); } if (e.CommandName == "cmddelete") { PositionMastDAL objTollMast = new PositionMastDAL(); Int32 intValue = objTollMast.Delete(Convert.ToInt64(e.CommandArgument)); objTollMast = null; if (intValue > 0) { this.BindGrid(); strMsg = "Record deleted successfully."; txtPositionName.Focus(); } else { if (intValue == -1) { strMsg = "Record can not be deleted. It is in use."; } else { strMsg = "Record not deleted."; } } ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); } else if (e.CommandName == "cmdstatus") { int intPositIdno = 0; bool bStatus = false; string[] strStatus = Convert.ToString(e.CommandArgument).Split(new char[] { '_' }); if (strStatus.Length > 1) { intPositIdno = Convert.ToInt32(strStatus[0]); if (Convert.ToBoolean(strStatus[1]) == true) { bStatus = false; } else { bStatus = true; } PositionMastDAL objDrivMast = new PositionMastDAL(); int value = objDrivMast.UpdateStatus(intPositIdno, bStatus); objDrivMast = null; if (value > 0) { this.BindGrid(); strMsg = "Status updated successfully."; txtPositionName.Focus(); } else { strMsg = "Status not updated."; } ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true); } } txtPositionName.Focus(); }