public bool SaveUC(eSunSpeedDomain.UnitConversionModel objUC) { string Query = string.Empty; bool isSaved = true; try { DBParameterCollection paramCollection = new DBParameterCollection(); paramCollection.Add(new DBParameter("@MainUnit", objUC.MainUnit)); paramCollection.Add(new DBParameter("@SubUnit", objUC.SubUnit)); paramCollection.Add(new DBParameter("@ConFactor", objUC.ConFactor)); //paramCollection.Add(new DBParameter("@CreatedBy", "Admin")); Query = "INSERT INTO UnitConversion(`MainUnit`,`SubUnit`,`ConFactor`) " + "VALUES(@MainUnit,@SubUnit,@ConFactor)"; if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0) { isSaved = true; } } catch (Exception ex) { isSaved = false; throw ex; } return(isSaved); }
//update public bool UpdateUC(eSunSpeedDomain.UnitConversionModel objUC) { string Query = string.Empty; bool isUpdated = true; DBParameterCollection paramCollection = new DBParameterCollection(); try { paramCollection.Add(new DBParameter("@MainUnit", objUC.MainUnit)); paramCollection.Add(new DBParameter("@SubUnit", objUC.SubUnit)); paramCollection.Add(new DBParameter("@ConFactor", objUC.ConFactor)); paramCollection.Add(new DBParameter("@UC_ID", objUC.ID)); Query = "UPDATE UnitConversion SET [MainUnit]=@MainUnit,[SubUnit]=@SubUnit,[ConFactor]=@ConFactor " + "WHERE Id=@UC_Id"; if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0) { isUpdated = true; } } catch (Exception ex) { isUpdated = false; throw ex; } finally { paramCollection = null; } return(isUpdated); }
//Get Unit Conversion By Unit Name public UnitConversionModel GetUnitConversionByUnitname(string Unitname) { UnitConversionModel objUnitCon = new UnitConversionModel(); string Query = string.Empty; Query = "SELECT SubUnit FROM `UnitConversion` WHERE `MainUnit`='" + Unitname + "'"; System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject()); while (dr.Read()) { objUnitCon = new eSunSpeedDomain.UnitConversionModel(); objUnitCon.SubUnit = dr["SubUnit"].ToString(); } return(objUnitCon); }