private string GetMenuName(int Menu_ID) { SqlService _service = new SqlService(); try { string str = ""; string strParrent = ""; _service.AddParameter("@Menu_ID", SqlDbType.Int, Menu_ID); SqlDataReader _drMenu = null; _drMenu = _service.ExecuteSPReader("SP_GetTen_chucnangMaster"); if (_drMenu.HasRows) { while (_drMenu.Read()) { str = _drMenu["Ten_chucnang"].ToString(); strParrent = _drMenu["MenuParrent"].ToString(); } } _drMenu.Close(); _service.CloseConnect(); _service.Disconnect(); return(" " + strParrent + " » " + str); } catch (Exception ex) { throw ex; } finally { _service.CloseConnect(); _service.Disconnect(); } }
//End //keyword public void InsertT_Keywords(string Keyword, double NewsID, int UserID) { string _sql = "CMS_InsertT_Keywords_Dynamic"; try { string sql = "Delete T_KeyNews where IDNews = " + NewsID; HPCDataProvider.Instance().ExecSql(sql); string[] _Keyword = Keyword.ToString().Trim().Split(','); for (int i = 0; i < _Keyword.Length; i++) { string _key = _Keyword[i].Trim(); if (_key.Length > 1) { SqlService _sqlservice = new SqlService(); _sqlservice.AddParameter("@Keyword", SqlDbType.NVarChar, _key, true); _sqlservice.AddParameter("@NewsID", SqlDbType.Float, NewsID, true); _sqlservice.AddParameter("@UserID", SqlDbType.Float, UserID, true); _sqlservice.ExecuteSP(_sql); _sqlservice.CloseConnect(); _sqlservice.Disconnect(); } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Adds a Iteration record to the database. /// </summary> /// <param name="info"> The Iteration record that needs adding. </param> /// <param name="transaction"> The SQL transaction object. </param> /// <returns> The DB record ID. </returns> public int Add(Cont.Iteration info, SqlTransaction transaction = null) { SqlService sql = null; try { sql = new SqlService(transaction); sql.AddParameter("@ID", SqlDbType.Int, info.ID, ParameterDirection.InputOutput, true); sql.AddParameter("@RegionID", SqlDbType.Int, info.RegionID, ParameterDirection.Input, true); sql.AddParameter("@ProductID", SqlDbType.Int, info.ProductID, ParameterDirection.Input, true); sql.AddParameter("@ConfigurationID", SqlDbType.Int, info.ConfigurationID, ParameterDirection.Input, true); sql.AddParameter("@SKUID", SqlDbType.Int, info.SKUID, ParameterDirection.Input, true); sql.AddParameter("@MeasureID", SqlDbType.Int, info.MeasureID, ParameterDirection.Input, true); sql.ExecuteSP("AddIteration"); SqlParameter param = sql.ResultParameters["@ID"]; info.ID = Convert.ToInt32(param.Value); // Update cached values CachedValues.Value.Add(info); }//end try catch (Exception exc) { throw exc; }//end catch finally { if (sql != null) { sql.Disconnect(); } }//end finally return(info.ID); } //End Add method
} //End method getByID /// <summary> /// This method gets all Iteration records from DB. /// </summary> /// <returns> A list of Iteration records in Object-Oriented form. </returns> public Cont.Iteration[] GetAll() { Cont.Iteration[] toReturn = new Cont.Iteration[0]; SqlService sql = null; SqlDataReader reader = null; try { sql = new SqlService(); reader = sql.ExecuteSPReader("GetIterationAll"); toReturn = ConvertToContainer(reader); //MARK: Make sure row IDs corresponds to Database fields }//end try catch (Exception exc) { throw exc; }//end catch finally { if (reader != null && !reader.IsClosed) { reader.Close(); } if (sql != null) { sql.Disconnect(); } }//end finally return(toReturn); } //End method getAll
/// <summary> /// Adds a Product record to the database. /// </summary> /// <param name="info"> The Product record that needs adding. </param> /// <param name="transaction"> The SQL transaction object. </param> /// <returns> The DB record ID. </returns> public int Add(Cont.Product info, SqlTransaction transaction = null) { SqlService sql = null; try { sql = new SqlService(transaction); sql.AddParameter("@ID", SqlDbType.Int, info.ID, ParameterDirection.InputOutput, true); sql.AddParameter("@Name", SqlDbType.VarChar, info.Name, 50, ParameterDirection.Input, true); sql.AddParameter("@LOB", SqlDbType.VarChar, info.LOB, 50, ParameterDirection.Input, true); sql.AddParameter("@Model", SqlDbType.VarChar, info.Model, ParameterDirection.Input, true); sql.AddParameter("@Variant", SqlDbType.VarChar, 50, ParameterDirection.Input, true); sql.AddParameter("@Phase", SqlDbType.VarChar, 50, ParameterDirection.Input, true); sql.ExecuteSP("AddProduct"); SqlParameter param = sql.ResultParameters["@ID"]; info.ID = Convert.ToInt32(param.Value); // Update cached values CachedValues.Value.Add(info); }//end try catch (Exception exc) { throw exc; }//end catch finally { if (sql != null) sql.Disconnect(); }//end finally return info.ID; } //End Add method
} //End Add method /// <summary> /// Updates an existing DB record with provided information. /// </summary> /// <param name="info"> The SKU record that needs updating. </param> /// <param name="transaction"> The SQL transaction object. </param> public void Update(Cont.SKU info, SqlTransaction transaction = null) { SqlService sql = null; try { sql = new SqlService(transaction); sql.AddParameter("@ID", SqlDbType.Int, info.ID, ParameterDirection.Input, true); sql.AddParameter("@Name", SqlDbType.VarChar, info.Name, 50, ParameterDirection.Input, true); sql.AddParameter("@Description", SqlDbType.VarChar, info.Description, 50, ParameterDirection.Input, true); sql.AddParameter("@Commodity", SqlDbType.VarChar, info.Commodity, 50, ParameterDirection.Input, true); sql.ExecuteSP("UpdateSKU"); // Update cached values Cont.SKU cacheItemToRemove = CachedValues.Value.FirstOrDefault(x => x.ID == info.ID && !x.Equals(info)); if (cacheItemToRemove != null) { CachedValues.Value.Remove(cacheItemToRemove); //Remove item CachedValues.Value.Add(info); //Add item }//end if }//end try catch (Exception exc) { throw exc; }//end catch finally { if (sql != null) { sql.Disconnect(); } } //end finally } //End update method
/// <summary> /// Adds a SKU record to the database. /// </summary> /// <param name="info"> The SKU record that needs adding. </param> /// <param name="transaction"> The SQL transaction object. </param> /// <returns> The DB record ID. </returns> public int Add(Cont.SKU info, SqlTransaction transaction = null) { SqlService sql = null; try { sql = new SqlService(transaction); sql.AddParameter("@ID", SqlDbType.Int, info.ID, ParameterDirection.InputOutput, true); sql.AddParameter("@Name", SqlDbType.VarChar, info.Name, 50, ParameterDirection.Input, true); sql.AddParameter("@Description", SqlDbType.VarChar, info.Description, 50, ParameterDirection.Input, true); sql.AddParameter("@Commodity", SqlDbType.VarChar, info.Commodity, 50, ParameterDirection.Input, true); sql.ExecuteSP("AddSKU"); SqlParameter param = sql.ResultParameters["@ID"]; info.ID = Convert.ToInt32(param.Value); // Update cached values CachedValues.Value.Add(info); }//end try catch (Exception exc) { throw exc; }//end catch finally { if (sql != null) { sql.Disconnect(); } }//end finally return(info.ID); } //End Add method
} //End Delete method. /// <summary> /// This method gets a Region Record by ID. /// </summary> /// <param name="ID"> The DB ID of the record you want to retrieve. </param> /// <returns> The Region record in Object-Oriented form. </returns> public Cont.Region GetByID(int ID) { Cont.Region toReturn = CachedValues.Value.FirstOrDefault(x => x.ID == ID); if (toReturn == null) { SqlService sql = null; SqlDataReader reader = null; try { sql = new SqlService(); sql.AddParameter("@ID", SqlDbType.Int, ID, ParameterDirection.Input, true); reader = sql.ExecuteSPReader("GetRegion"); toReturn = ConvertToContainer(reader).FirstOrDefault(); //MARK: Make sure row IDs corresponds to Database fields //Append to cached values if (toReturn != null) { CachedValues.Value.Add(toReturn); }//endif }//end try catch (Exception exc) { throw exc; }//end catch finally { if (reader != null && !reader.IsClosed) reader.Close(); if (sql != null) sql.Disconnect(); }//end finally } //end if return toReturn; } //End method getByID
} //End Add method /// <summary> /// Updates an existing DB record with provided information. /// </summary> /// <param name="info"> The Product record that needs updating. </param> /// <param name="transaction"> The SQL transaction object. </param> public void Update(Cont.Product info, SqlTransaction transaction = null) { SqlService sql = null; try { sql = new SqlService(transaction); sql.AddParameter("@ID", SqlDbType.Int, info.ID, ParameterDirection.Input, true); sql.AddParameter("@Name", SqlDbType.VarChar, info.Name, 50, ParameterDirection.Input, true); sql.AddParameter("@LOB", SqlDbType.VarChar, info.LOB, 50, ParameterDirection.Input, true); sql.AddParameter("@Model", SqlDbType.VarChar, info.Model, ParameterDirection.Input, true); sql.AddParameter("@Variant", SqlDbType.VarChar, 50, ParameterDirection.Input, true); sql.AddParameter("@Phase", SqlDbType.VarChar, 50, ParameterDirection.Input, true); sql.ExecuteSP("UpdateProduct"); // Update cached values Cont.Product cacheItemToRemove = CachedValues.Value.FirstOrDefault(x => x.ID == info.ID && !x.Equals(info)); if (cacheItemToRemove != null) { CachedValues.Value.Remove(cacheItemToRemove); //Remove item CachedValues.Value.Add(info); //Add item }//end if }//end try catch (Exception exc) { throw exc; }//end catch finally { if (sql != null) sql.Disconnect(); }//end finally } //End update method
} //End update method /// <summary> /// This method deletes a Iteration DB record. /// </summary> /// <param name="ID"> The record ID you want removed. </param> /// <param name="transaction"> The SQL Transaction object. </param> public void Delete(int ID, SqlTransaction transaction = null) { SqlService sql = null; try { sql = new SqlService(transaction); sql.AddParameter("@ID", SqlDbType.Int, ID, ParameterDirection.Input, true); sql.ExecuteSP("DeleteIteration"); //TODO: Pass in the Stored Procedure Name // Update cached values Cont.Iteration cacheItemToRemove = CachedValues.Value.FirstOrDefault(x => x.ID == ID); if (cacheItemToRemove != null) { CachedValues.Value.Remove(cacheItemToRemove); //Remove item }//end if }//end try catch (Exception exc) { throw exc; }//end catch finally { if (sql != null) { sql.Disconnect(); } } //end finally } //End Delete method
public static byte[] GetImage(int UserID) { SqlService sql = new SqlService(); SqlDataReader reader = sql.ExecuteSqlReader("select dbo.fn_Get_Image(" + UserID + ")"); reader.Read(); byte[] result = (byte[])reader[0]; reader.Close(); sql.Disconnect(); return(result); }
public static DataSet CallSP(string StoreName, string fd, string td, int cate) { DataSet _ds = null; SqlService _sqlservice = new SqlService(); if (fd != "") { _sqlservice.AddParameter("@fromdate", SqlDbType.NVarChar, fd + " 00:00:01", 25); } if (td != "") { _sqlservice.AddParameter("@todate", SqlDbType.NVarChar, td + " 23:59:59", 25); } _sqlservice.AddParameter("@Cate", SqlDbType.Int, cate, 25); _ds = _sqlservice.ExecuteSPDataSet(StoreName, StoreName); _sqlservice.CloseConnect(); _sqlservice.Disconnect(); return(_ds); }
protected void LoadData(double _newsID) { SqlService _service = new SqlService(); System.Data.SqlClient.SqlDataReader _dr = null; try { _service.AddParameter("@News_ID", SqlDbType.Int, _newsID); _dr = _service.ExecuteSPReader(@"CMS_GetNewDetailsPrints"); if (_dr != null) { while (_dr.Read()) { if (_dr["News_DateEdit"] != System.DBNull.Value) { this.litDateTime.Text = Convert.ToDateTime(_dr["News_DateEdit"]).ToString("HH:mm, dd/MM/yyyy"); } if (_dr["News_DatePublished"] != System.DBNull.Value) { this.litDateTime.Text = Convert.ToDateTime(_dr["News_DatePublished"]).ToString("HH:mm, dd/MM/yyyy"); } this.litTittle.Text = _dr["News_Tittle"].ToString(); this.litSapo.Text = _dr["News_Summary"].ToString(); string contents = _dr["News_Body"].ToString(); this.litCategorys.Text = "<a href=\"#\">" + HPCBusinessLogic.UltilFunc.GetCategoryName(_dr["CAT_ID"]) + "</a>"; //this.litContents.Text = SearchImgTag(contents); this.litContents.Text = contents; if (_dr["News_AuthorName"] != null) { this.litAuthor.Text += "<div class=\"author\">"; this.litAuthor.Text += _dr["News_AuthorName"].ToString(); this.litAuthor.Text += "</div>"; } } } } catch { } finally { if (_dr != null) { _dr.Close(); _dr.Dispose(); } _service.CloseConnect(); _service.Disconnect(); } }
} //End Add method /// <summary> /// Updates an existing DB record with provided information. /// </summary> /// <param name="info"> The Cost record that needs updating. </param> /// <param name="transaction"> The SQL transaction object. </param> public void Update(Cont.Cost info, SqlTransaction transaction = null) { SqlService sql = null; try { sql = new SqlService(transaction); sql.AddParameter("@ID", SqlDbType.Int, info.ID, ParameterDirection.Input, true); sql.AddParameter("@IterationID", SqlDbType.Int, info.IterationID, ParameterDirection.Input, true); sql.AddParameter("@Date", SqlDbType.Date, info.Date, ParameterDirection.Input, true); sql.AddParameter("@CurrentCost", SqlDbType.Float, info.CurrentCost, ParameterDirection.Input, true); sql.AddParameter("@CostNext1", SqlDbType.Float, info.CostNext1, ParameterDirection.Input, true); sql.AddParameter("@CostNext2", SqlDbType.Float, info.CostNext2, ParameterDirection.Input, true); sql.AddParameter("@CostNext3", SqlDbType.Float, info.CostNext3, ParameterDirection.Input, true); sql.ExecuteSP("UpdateCost"); // Update cached values Cont.Cost cacheItemToRemove = CachedValues.Value.FirstOrDefault(x => x.ID == info.ID && !x.Equals(info)); if (cacheItemToRemove != null) { CachedValues.Value.Remove(cacheItemToRemove); //Remove item CachedValues.Value.Add(info); //Add item }//end if }//end try catch (Exception exc) { throw exc; }//end catch finally { if (sql != null) { sql.Disconnect(); } } //end finally } //End update method
protected void LoadData() { SqlService _service = new SqlService(); int Catid = 0; if (Request["catps"] != null) { Catid = Convert.ToInt32(Request["catps"]); } DataSet _ds = null; //_service.AddParameter("@Cat_Album_ID", SqlDbType.Int, Catid); try { _ds = _service.ExecuteSqlDataSet("select * from T_Album_Photo where Cat_Album_ID= " + Catid.ToString()); this.rptAlbumActive.DataSource = _ds.Tables[0].DefaultView; this.rptAlbumActive.DataBind(); } catch { _ds.Clear(); _service.CloseConnect(); } finally { _ds.Clear(); _service.CloseConnect(); _service.Disconnect(); } }
/// <summary> /// Adds a Cost record to the database. /// </summary> /// <param name="info"> The Cost record that needs adding. </param> /// <param name="transaction"> The SQL transaction object. </param> /// <returns></returns> public int Add(Cont.Cost info, SqlTransaction transaction = null) { SqlService sql = null; try { sql = new SqlService(transaction); sql.AddParameter("@ID", SqlDbType.Int, info.ID, ParameterDirection.InputOutput, true); sql.AddParameter("@IterationID", SqlDbType.Int, info.IterationID, ParameterDirection.Input, true); sql.AddParameter("@Date", SqlDbType.Date, info.Date, ParameterDirection.Input, true); sql.AddParameter("@CurrentCost", SqlDbType.Float, info.CurrentCost, ParameterDirection.Input, false); sql.AddParameter("@CostNext1", SqlDbType.Float, info.CostNext1, ParameterDirection.Input, false); sql.AddParameter("@CostNext2", SqlDbType.Float, info.CostNext2, ParameterDirection.Input, false); sql.AddParameter("@CostNext3", SqlDbType.Float, info.CostNext3, ParameterDirection.Input, false); sql.ExecuteSP("AddCost"); SqlParameter param = sql.ResultParameters["@ID"]; info.ID = Convert.ToInt32(param.Value); // Update cached values CachedValues.Value.Add(info); }//end try catch (Exception exc) { throw exc; }//end catch finally { if (sql != null) { sql.Disconnect(); } }//end finally return(info.ID); } //End Add method
} //End Add method /// <summary> /// Updates an existing DB record with provided information. /// </summary> /// <param name="info"> The Iteration record that needs updating. </param> /// <param name="transaction"> The SQL transaction object. </param> public void Update(Cont.Iteration info, SqlTransaction transaction = null) { SqlService sql = null; try { sql = new SqlService(transaction); sql.AddParameter("@ID", SqlDbType.Int, info.ID, ParameterDirection.Input, true); sql.AddParameter("@RegionID", SqlDbType.Int, info.RegionID, ParameterDirection.Input, true); sql.AddParameter("@ProductID", SqlDbType.Int, info.ProductID, ParameterDirection.Input, true); sql.AddParameter("@ConfigurationID", SqlDbType.Int, info.ConfigurationID, ParameterDirection.Input, true); sql.AddParameter("@SKUID", SqlDbType.Int, info.SKUID, ParameterDirection.Input, true); sql.AddParameter("@MeasureID", SqlDbType.Int, info.MeasureID, ParameterDirection.Input, true); sql.ExecuteSP("UpdateIteration"); // Update cached values Cont.Iteration cacheItemToRemove = CachedValues.Value.FirstOrDefault(x => x.ID == info.ID && !x.Equals(info)); if (cacheItemToRemove != null) { CachedValues.Value.Remove(cacheItemToRemove); //Remove item CachedValues.Value.Add(info); //Add item }//end if }//end try catch (Exception exc) { throw exc; }//end catch finally { if (sql != null) { sql.Disconnect(); } } //end finally } //End update method