public int SaveUpdateRank(RankPOCO pOCO) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TCCCMSDBConnectionString"].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("stpSaveUpdateRank", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@RankName", pOCO.RankName.ToString()); cmd.Parameters.AddWithValue("@Description", pOCO.Description.ToString()); cmd.Parameters.AddWithValue("@Email", pOCO.Email.ToString());//Added on 30th Jan 2021 @BK //cmd.Parameters.AddWithValue("@IsActive", pOCO.IsActive); if (pOCO.RankId > 0) { cmd.Parameters.AddWithValue("@RankId ", pOCO.RankId); } else { cmd.Parameters.AddWithValue("@RankId ", DBNull.Value); } int recordsAffected = cmd.ExecuteNonQuery(); con.Close(); return(recordsAffected); }
private RankPOCO ConvertDataTableToRankByRankIdList(DataSet ds) { RankPOCO pPOCOPC = new RankPOCO(); //check if there is at all any data if (ds.Tables.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { //RankPOCO pPOCOPC = new RankPOCO(); if (item["RankId"] != null) { pPOCOPC.RankId = Convert.ToInt32(item["RankId"].ToString()); } if (item["RankName"] != System.DBNull.Value) { pPOCOPC.RankName = item["RankName"].ToString(); } if (item["Description"] != System.DBNull.Value) { pPOCOPC.Description = item["Description"].ToString(); } if (item["Email"] != System.DBNull.Value)//Added on 30th Jan 2021 @BK { pPOCOPC.Email = item["Email"].ToString(); } //pcList.Add(pPOCOPC); } } return(pPOCOPC); }
public List <ApproverMaster> GetAllApproverListPageWise(int pageIndex, ref int totalCount, int pageSize) { List <ApproverMaster> approverList = new List <ApproverMaster>(); using (SqlConnection con = new SqlConnection(connectionString)) { using (SqlCommand cmd = new SqlCommand("GetAllApproverListPageWise", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PageIndex", pageIndex); cmd.Parameters.AddWithValue("@PageSize", pageSize); cmd.Parameters.Add("@TotalCount", SqlDbType.Int, 4); cmd.Parameters["@TotalCount"].Direction = ParameterDirection.Output; con.Open(); DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); foreach (DataRow dr in ds.Tables[0].Rows) { ApproverMaster approver = new ApproverMaster(); approver.ID = Convert.ToInt32(dr["ID"]); approver.ShipId = Convert.ToInt32(dr["ShipId"]); approver.RankId = Convert.ToInt32(dr["RankId"]); approver.UserId = Convert.ToInt32(dr["UserId"]); approver.ApproverId = Convert.ToInt32(dr["ApproverId"]); approver.VesselIMONumber = Convert.ToInt32(dr["VesselIMONumber"]); Ship ship = new Ship(); ship.ID = Convert.ToInt32(dr["ID"]); ship.ShipName = Convert.ToString(dr["ShipName"]); approver.Ship = ship; RankPOCO rank = new RankPOCO(); rank.RankId = Convert.ToInt32(dr["RankId"]); rank.RankName = Convert.ToString(dr["RankName"]); approver.Rank = rank; UserMasterPOCO user = new UserMasterPOCO(); user.UserId = Convert.ToInt32(dr["UserId"]); user.UserName = Convert.ToString(dr["UserName"]); approver.User = user; approver.ApproverDescription = Convert.ToString(dr["ApproverDescription"]); approver.RowNumber = Convert.ToInt32(dr["RowNumber"]); approverList.Add(approver); } totalCount = Convert.ToInt32(cmd.Parameters["@TotalCount"].Value); con.Close(); } } return(approverList); }
public JsonResult SaveUpdateRank(RankPOCO pOCO) { RankBL bL = new RankBL(); RankPOCO pC = new RankPOCO(); pC.RankId = pOCO.RankId; pC.RankName = pOCO.RankName; pC.Description = pOCO.Description; pC.Email = pOCO.Email; //Added on 30th Jan 2021 @BK return(Json(bL.SaveUpdateRank(pC /*, int.Parse(Session["VesselID"].ToString())*/), JsonRequestBehavior.AllowGet)); }
public JsonResult LoadData() { int draw, start, length; int pageIndex = 0; if (null != Request.Form.GetValues("draw")) { draw = int.Parse(Request.Form.GetValues("draw").FirstOrDefault().ToString()); start = int.Parse(Request.Form.GetValues("start").FirstOrDefault().ToString()); length = int.Parse(Request.Form.GetValues("length").FirstOrDefault().ToString()); } else { draw = 1; start = 0; length = 500; } if (start == 0) { pageIndex = 1; } else { pageIndex = (start / length) + 1; } RankBL bL = new RankBL(); /////////////////////////////////////////////////////////////////////////// int totalrecords = 0; List <RankPOCO> pocoList = new List <RankPOCO>(); pocoList = bL.GetAllRankPageWise(pageIndex, ref totalrecords, length /*, int.Parse(Session["VesselID"].ToString())*/); List <RankPOCO> pList = new List <RankPOCO>(); foreach (RankPOCO pC in pocoList) { RankPOCO pOCO = new RankPOCO(); pOCO.RankId = pC.RankId; pOCO.RankName = pC.RankName; pOCO.Description = pC.Description; pOCO.Email = pC.Email; //Added on 30th Jan 2021 @BK pList.Add(pOCO); } var data = pList; return(Json(new { draw = draw, recordsFiltered = totalrecords, recordsTotal = totalrecords, data = data }, JsonRequestBehavior.AllowGet)); }
public JsonResult GetRankByRankId(int RankId) { RankBL bL = new RankBL(); RankPOCO pOCOList = new RankPOCO(); pOCOList = bL.GetRankByRankId(RankId); RankPOCO dept = new RankPOCO(); dept.RankId = pOCOList.RankId; dept.RankName = pOCOList.RankName; dept.Description = pOCOList.Description; dept.Email = pOCOList.Email; //Added on 30th Jan 2021 @BK var data = dept; return(Json(data, JsonRequestBehavior.AllowGet)); }
public RankPOCO GetRankByRankId(int RankId) { RankPOCO prodPOList = new RankPOCO(); RankPOCO prodPO = new RankPOCO(); DataSet ds = new DataSet(); using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TCCCMSDBConnectionString"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand("stpGetRankByRankId", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@RankId", RankId); con.Open(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds); con.Close(); } } return(ConvertDataTableToRankByRankIdList(ds)); }
private UserMasterPOCO ConvertDataTableToUserByUserIdList(DataSet ds) { UserMasterPOCO pPOCOPC = new UserMasterPOCO(); //check if there is at all any data if (ds.Tables.Count > 0) { foreach (DataRow item in ds.Tables[0].Rows) { //UserMasterPOCO pPOCOPC = new UserMasterPOCO(); RankPOCO rank = new RankPOCO(); //Ship ship = new Ship(); if (item["UserId"] != null) { pPOCOPC.UserId = Convert.ToInt32(item["UserId"].ToString()); } if (item["UserName"] != System.DBNull.Value) { pPOCOPC.UserName = item["UserName"].ToString(); } if (item["UserCode"] != System.DBNull.Value)//Added on 20th JAN 2021 @BK { pPOCOPC.UserCode = item["UserCode"].ToString(); } if (item["Password"] != System.DBNull.Value) { pPOCOPC.Password = item["Password"].ToString(); } if (item["CreatedOn"] != System.DBNull.Value) { pPOCOPC.CreatedOn1 = item["CreatedOn"].ToString(); } if (item["Email"] != System.DBNull.Value) { pPOCOPC.Email = item["Email"].ToString(); } //if (item["CreatedBy"] != System.DBNull.Value) // pPOCOPC.CreatedBy = item["CreatedBy"].ToString(); //if (item["ModifiedBy"] != System.DBNull.Value) // pPOCOPC.ModifiedBy = item["ModifiedBy"].ToString(); if (item["Gender"] != System.DBNull.Value) { pPOCOPC.Gender = item["Gender"].ToString(); } if (item["VesselIMO"] != System.DBNull.Value) { pPOCOPC.VesselIMO = item["VesselIMO"].ToString(); } if (item["RankId"] != null) { pPOCOPC.RankId = Convert.ToInt32(item["RankId"].ToString()); rank.RankId = Convert.ToInt32(item["RankId"].ToString()); rank.RankName = item["RankName"].ToString(); pPOCOPC.Rank = rank; } if (item["ShipId"] != null) { pPOCOPC.ShipId = Convert.ToInt32(item["ShipId"].ToString()); } if (item["RoleId"] != null) { pPOCOPC.RoleId = Convert.ToInt32(item["RoleId"].ToString()); } //if (item["UserCode"] != System.DBNull.Value) // pPOCOPC.UserCode = item["UserCode"].ToString(); if (item["UserType"] != null) { pPOCOPC.UserType = Convert.ToInt32(item["UserType"].ToString()); } //if (item["IsAdmin"] != null || item["IsAdmin"] != "") // pPOCOPC.IsAdmin = Convert.ToInt32(item["IsAdmin"].ToString()); //pcList.Add(pPOCOPC); } } return(pPOCOPC); }
public int SaveUpdateRank(RankPOCO pOCO /*,int VesselID*/) { RankDAL dAL = new RankDAL(); return(dAL.SaveUpdateRank(pOCO /*, VesselID*/)); }