public bool AddUnit(clsUnit info) { int st = 0; try { using (SqlConnection conn = new SqlConnection(strConn)) { conn.Open(); { using (SqlCommand cmd = new SqlCommand("TMR_USP_AddUnit")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = conn; cmd.Parameters.AddWithValue("@UnitID", info.strUnitID); cmd.Parameters.AddWithValue("@Prefix", info.strPrefix); cmd.Parameters.AddWithValue("@Number", info.strNumber); cmd.Parameters.AddWithValue("@ProjectID", info.strProjectID); cmd.Parameters.AddWithValue("@BlockNo", info.strBlockNo); cmd.Parameters.AddWithValue("@StreetNo", info.strStreetNo); cmd.Parameters.AddWithValue("@PlotNo", info.strPlotNo); cmd.Parameters.AddWithValue("@SizeCode", info.strSizeCode); cmd.Parameters.AddWithValue("@UnitCategoryID", info.strUnitCategoryID); cmd.Parameters.AddWithValue("@UnitTypeID", info.strUnitTypeID); cmd.Parameters.AddWithValue("@Status", info.strStatus); cmd.Parameters.AddWithValue("@Area", info.decArea); cmd.Parameters.AddWithValue("@UOMID", info.strUOMID); cmd.Parameters.AddWithValue("@Width", info.decWidth); cmd.Parameters.AddWithValue("@Length", info.decLength); cmd.Parameters.AddWithValue("@RegistrationNo", info.strRegistrationNo); cmd.Parameters.AddWithValue("@Price", info.decPrice); cmd.Parameters.AddWithValue("@Statuscode", (int)info.statuscode); cmd.Parameters.AddWithValue("@SquareFeet", (int)info.decSquareFeet); cmd.Parameters.AddWithValue("@ID", info.ID); st = cmd.ExecuteNonQuery(); } } conn.Close(); } } catch (Exception ex) { } if (st > 0) { return(true); } else { return(false); } }
/// <summary> /// Get Units having status AVailable /// </summary> /// <param name="strProject"></param> /// <param name="strBlock"></param> /// <param name="strSizeCode"></param> /// <returns></returns> public List <clsUnit> GetAvailableUnitsByProjectBlockSizeCode(string strProject, string strBlock, string strSizeCode, string strStreet, string strPlot) { List <clsUnit> lst = new List <clsUnit>(); using (SqlConnection conn = new SqlConnection(strConn)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("TMR_USP_GetAvailableUnitsBySizeCode")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = conn; cmd.Parameters.AddWithValue("@ProjectId", strProject); cmd.Parameters.AddWithValue("@BlockNo", strBlock); cmd.Parameters.AddWithValue("@SizeCode", strSizeCode); cmd.Parameters.AddWithValue("@Street", strStreet); cmd.Parameters.AddWithValue("@Plot", strPlot); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { var info = new clsUnit(); info.strUnitID = reader["UnitID"].ToString(); info.strProjectID = reader["ProjectID"].ToString(); info.strBlockNo = reader["BlockNo"].ToString(); info.strStreetNo = reader["StreetNo"].ToString(); info.strPlotNo = reader["PlotNo"].ToString(); info.strSizeCode = reader["SizeCode"].ToString(); info.strUnitCategoryID = reader["UnitCategoryID"].ToString(); info.strUnitTypeID = reader["UnitTypeID"].ToString(); info.strStatus = reader["Status"].ToString(); info.decArea = Convert.ToDecimal(reader["Area"]); info.strUOMID = reader["UOMID"].ToString(); info.decWidth = Convert.ToDecimal(reader["Width"]); info.decLength = Convert.ToDecimal(reader["Length"]); info.decPrice = Convert.ToDecimal(reader["Price"]); info.strRegistrationNo = reader["RegistrationNo"].ToString(); info.ID = Convert.ToInt32(reader["ID"]); lst.Add(info); } conn.Close(); } } return(lst); }
public clsUnit GetUnitByUnitID(string strUnitID) { clsUnit info = new clsUnit(); using (SqlConnection conn = new SqlConnection(strConn)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("TMR_USP_GetUnitByUnitID")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = conn; cmd.Parameters.AddWithValue("@UnitID", strUnitID); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { //var info = new clsUnit(); info.strUnitID = reader["UnitID"].ToString(); info.strProjectID = reader["ProjectID"].ToString(); info.strBlockNo = reader["BlockNo"].ToString(); info.strStreetNo = reader["StreetNo"].ToString(); info.strPlotNo = reader["PlotNo"].ToString(); info.strSizeCode = reader["SizeCode"].ToString(); info.strUnitCategoryID = reader["UnitCategoryID"].ToString(); info.strUnitTypeID = reader["UnitTypeID"].ToString(); info.strStatus = reader["Status"].ToString(); info.decArea = Convert.ToDecimal(reader["Area"]); info.strUOMID = reader["UOMID"].ToString(); info.decWidth = Convert.ToDecimal(reader["Width"]); info.decLength = Convert.ToDecimal(reader["Length"]); info.decSquareFeet = Convert.ToDecimal(reader["SquareFeet"]); info.decPrice = Convert.ToDecimal(reader["Price"]); info.strRegistrationNo = reader["RegistrationNo"].ToString(); info.ID = Convert.ToInt32(reader["ID"]); //lst.Add(info); } conn.Close(); } } return(info); }