Tuesday, July 17, 2012

Using Entities in IList


BL Method which return Collective List objects
///
/// To Fetch the User Name & Code from DB
///

///
public List> GetLOBStationAccountUser(LOBStationAccountMap objLOBStationAccountMap)
{
List> lstCusomterALL = null; List lstSelectedAccount = null; List lstAvailablAccount = null; List lstCustomerAccount = null; SqlParameter[] ObjSqlParam = new SqlParameter[3]; string connString = SqlHelper.GetConnectionString(); //SqlConnection con = null; SqlDataReader dr = null; try { ObjSqlParam[0] = new SqlParameter("@ProductLobID", objLOBStationAccountMap.ProductLobID); ObjSqlParam[1] = new SqlParameter("@StationID", objLOBStationAccountMap.StationID == 0 ? System.Data.SqlTypes.SqlInt32.Null : objLOBStationAccountMap.StationID); ObjSqlParam[2] = new SqlParameter("@CustAccntID", objLOBStationAccountMap.CustAcntIdArray.Trim().Equals(string.Empty)? System.Data.SqlTypes.SqlString.Null: objLOBStationAccountMap.CustAcntIdArray ); //con = new SqlConnection(connString); dr = SqlHelper.ExecuteReader(connString, CommandType.StoredProcedure, "[DBSP_IMP_Get_LOBStatnAccntUsrMap]", ObjSqlParam); lstAvailablAccount = new List(); if (dr.HasRows) { while (dr.Read()) { UserMaster objCustomerAccountMaster = new UserMaster(); objCustomerAccountMaster.UserID = Convert.ToInt32(dr["UserID"]); objCustomerAccountMaster.UserCodeName = Convert.ToString(dr["UserCodeName"]); objCustomerAccountMaster.UserName = Convert.ToString(dr["UserName"]); lstAvailablAccount.Add(objCustomerAccountMaster); } } lstSelectedAccount = new List(); if (dr.NextResult()) { while (dr.Read()) { UserMaster objCustomerAccountMaster = new UserMaster(); objCustomerAccountMaster.UserID = Convert.ToInt32(dr["UserID"]); objCustomerAccountMaster.UserCodeName = Convert.ToString(dr["UserCodeName"]); objCustomerAccountMaster.UserName = Convert.ToString(dr["UserName"]); lstSelectedAccount.Add(objCustomerAccountMaster); } } lstCustomerAccount = new List(); if (dr.NextResult()) { while (dr.Read()) { UserMaster objCustomerAccountMaster = new UserMaster(); objCustomerAccountMaster.UserID = Convert.ToInt32(dr["UserID"]); objCustomerAccountMaster.UsrCustomerAccountID = Convert.ToInt32(dr["CustomerAccountID"]); objCustomerAccountMaster.UsrLobStationAccountID = Convert.ToInt32(dr["LOBStationAccountID"]); lstCustomerAccount.Add(objCustomerAccountMaster); } } lstCusomterALL = new List>(); lstCusomterALL.Add(lstAvailablAccount); lstCusomterALL.Add(lstSelectedAccount); lstCusomterALL.Add(lstCustomerAccount); } catch (Exception ex) { throw ex; } finally { dr.Close(); dr.Dispose(); //con.Close(); }
return lstCusomterALL;
}

IList objects accessed in CS Page
List> lstUserAvail_Selected;
lstUserAvail_Selected = objImportsConfigurationBL.GetLOBStationAccountUser(objLOBStationAccountMap);
if (lstUserAvail_Selected != null) { if (lstUserAvail_Selected.Count > 0) { this.SetAvailExistUsers(lstUserAvail_Selected[0], lstAvailFrame); if (lstUserAvail_Selected[1].Count > 0) this.SetAvailExistUsers(lstUserAvail_Selected[1], lstSelectedFrame); //if ( lstUserAvail_Selected.Count > 1 && lstUserAvail_Selected[2].Count > 1) // this.SetMappedCustomerAccounts(lstUserAvail_Selected[2]); } }

Javascript validation to Find Which Row of GridView


CS PAGE Coding
protected void grdBatchCreation_OnRowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { TextBox txtPageFrom = e.Row.FindControl("txtFrom") as TextBox; TextBox txtPageTo = e.Row.FindControl("txtTo") as TextBox; TextBox txtTotalPageNo = e.Row.FindControl("lblNoofCase") as TextBox; HiddenField txtRefVal = e.Row.FindControl("txtRefDOC") as HiddenField; CheckBox chkbx = e.Row.FindControl("chkgrd") as CheckBox; txtPageTo.Attributes.Add("onblur", "if (CheckValidPageNo('" + txtPageFrom.ClientID + "','" + txtPageTo.ClientID + "','" + txtRefVal.ClientID + "')) {return CalTotalPage('" + txtPageFrom.ClientID + "','" + txtPageTo.ClientID + "','" + txtTotalPageNo.ClientID + "'); }"); } }
JS To Find the Row
function whichRow(obj) { var par = obj.parentNode; while (par.nodeName.toLowerCase() != 'tr') { par = par.parentNode; } return (par.rowIndex); }
JS for GridView validation
function CheckValidPageNo(txtFrom, txtTo, txtRefVal) { //debugger; ///alert(txtFrom); var grdElement = document.getElementById('<%=grdBatchCreation.ClientID%>'); var objFrom = document.getElementById(txtFrom); var objTo = document.getElementById(txtTo); var CurrentRefObj = document.getElementById(txtRefVal); if (objFrom != null && CurrentRefObj != null && objTo != null) { if (trim(objFrom.value) != "" && trim(CurrentRefObj.value) != "" && trim(objTo.value) != "") { var CurrentFrmValue = (objFrom.value * 1); var CurrentToValue = (objTo.value * 1); var FromValue; var ToValue; var IsValid = true; var IsFromValid = true; var IsToValid = true; var CurrentRefValue; var RefValue; var idx = whichRow(objFrom); var rowsLength = grdElement.rows.length; for (var i = 1; i <= rowsLength - 1; i++) { var row = grdElement.rows[i]; //alert(row.cells[i].innerText); //alert(row.cells[i].innerHTML); if (row.cells[1].childNodes[0].checked && i != idx) { CurrentRefValue = trim(CurrentRefObj.value); RefValue = trim(row.cells[6].childNodes[0].value); if (RefValue.toLowerCase() == CurrentRefValue.toLowerCase()) { if (row.cells[4].childNodes[0].value != '') FromValue = (row.cells[4].childNodes[0].value * 1); if (row.cells[5].childNodes[0].value != '') ToValue = (row.cells[5].childNodes[0].value * 1); // 4 5 4 10 if (CurrentFrmValue >= FromValue && CurrentFrmValue <= ToValue) { //alert('From, To page values should be unique for same doc'); IsFromValid = false; } // 9 5 9 10 if (CurrentToValue >= FromValue && CurrentToValue <= ToValue) { //alert('From, To page values should be unique for same doc'); IsToValid = false; } if (CurrentFrmValue <= FromValue && CurrentToValue >= ToValue) { //alert('From, To page values should be unique for same doc'); IsToValid = false; } if (IsFromValid && IsToValid) { } else { showToolTip(2, 'From, To page values should be unique for same batch'); IsValid = false; //CurrentRefObj.value = ""; objTo.value = ""; objFrom.focus(); break; } } } // else if (i != 1) { // showToolTip(2, 'Please select before input From, To page values'); // row.cells[4].childNodes[0].value = ""; // row.cells[5].childNodes[0].value = ""; // row.cells[1].childNodes[0].focus(); // break; // }//SELECT } //for return IsValid; } } }