public Int32 Insert(ProductSubAttributeDetails Details) { try { string SQL = "INSERT INTO tblProductSubAttribute (ProductAttributeCode, ProductAttributeName) VALUES (@ProductAttributeCode, @ProductAttributeName);"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmProductAttributeCode = new MySqlParameter("@ProductAttributeCode",MySqlDbType.String); prmProductAttributeCode.Value = Details.ProductAttributeCode; cmd.Parameters.Add(prmProductAttributeCode); MySqlParameter prmProductAttributeName = new MySqlParameter("@ProductAttributeName",MySqlDbType.String); prmProductAttributeName.Value = Details.ProductAttributeName; cmd.Parameters.Add(prmProductAttributeName); base.ExecuteNonQuery(cmd); SQL = "SELECT LAST_INSERT_ID();"; cmd.Parameters.Clear(); cmd.CommandText = SQL; System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID"); base.MySqlDataAdapterFill(cmd, dt); Int32 iID = 0; foreach (System.Data.DataRow dr in dt.Rows) { iID = Int32.Parse(dr[0].ToString()); } return iID; } catch (Exception ex) { throw base.ThrowException(ex); } }
public Int32 Insert(ProductSubAttributeDetails Details) { try { string SQL = "INSERT INTO tblProductSubAttribute (ProductAttributeCode, ProductAttributeName) VALUES (@ProductAttributeCode, @ProductAttributeName);"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmProductAttributeCode = new MySqlParameter("@ProductAttributeCode", MySqlDbType.String); prmProductAttributeCode.Value = Details.ProductAttributeCode; cmd.Parameters.Add(prmProductAttributeCode); MySqlParameter prmProductAttributeName = new MySqlParameter("@ProductAttributeName", MySqlDbType.String); prmProductAttributeName.Value = Details.ProductAttributeName; cmd.Parameters.Add(prmProductAttributeName); base.ExecuteNonQuery(cmd); SQL = "SELECT LAST_INSERT_ID();"; cmd.Parameters.Clear(); cmd.CommandText = SQL; System.Data.DataTable dt = new System.Data.DataTable("LAST_INSERT_ID"); base.MySqlDataAdapterFill(cmd, dt); Int32 iID = 0; foreach (System.Data.DataRow dr in dt.Rows) { iID = Int32.Parse(dr[0].ToString()); } return(iID); } catch (Exception ex) { throw base.ThrowException(ex); } }
public ProductSubAttributeDetails Details(Int32 ProductAttributeID) { try { string SQL = "SELECT * FROM tblProductSubAttribute " + "WHERE ProductAttributeID = @ProductAttributeID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmProductAttributeID = new MySqlParameter("@ProductAttributeID", MySqlDbType.Int16); prmProductAttributeID.Value = ProductAttributeID; cmd.Parameters.Add(prmProductAttributeID); MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult); ProductSubAttributeDetails Details = new ProductSubAttributeDetails(); while (myReader.Read()) { Details.ProductAttributeID = ProductAttributeID; Details.ProductAttributeCode = myReader.GetString(1); Details.ProductAttributeName = myReader.GetString(2); } myReader.Close(); return(Details); } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(ProductSubAttributeDetails Details) { try { string SQL = "UPDATE tblProductSubAttribute SET " + "ProductAttributeCode = @ProductAttributeCode, " + "ProductAttributeName = @ProductAttributeName " + "WHERE ProductAttributeID = @ProductAttributeID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmProductAttributeCode = new MySqlParameter("@ProductAttributeCode", MySqlDbType.String); prmProductAttributeCode.Value = Details.ProductAttributeCode; cmd.Parameters.Add(prmProductAttributeCode); MySqlParameter prmProductAttributeName = new MySqlParameter("@ProductAttributeName", MySqlDbType.String); prmProductAttributeName.Value = Details.ProductAttributeName; cmd.Parameters.Add(prmProductAttributeName); MySqlParameter prmProductAttributeID = new MySqlParameter("@ProductAttributeID", MySqlDbType.Int16); prmProductAttributeID.Value = Details.ProductAttributeID; cmd.Parameters.Add(prmProductAttributeID); base.ExecuteNonQuery(cmd); } catch (Exception ex) { throw base.ThrowException(ex); } }
public ProductSubAttributeDetails Details(Int32 ProductAttributeID) { try { string SQL= "SELECT * FROM tblProductSubAttribute " + "WHERE ProductAttributeID = @ProductAttributeID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmProductAttributeID = new MySqlParameter("@ProductAttributeID",MySqlDbType.Int16); prmProductAttributeID.Value = ProductAttributeID; cmd.Parameters.Add(prmProductAttributeID); MySqlDataReader myReader = base.ExecuteReader(cmd, System.Data.CommandBehavior.SingleResult); ProductSubAttributeDetails Details = new ProductSubAttributeDetails(); while (myReader.Read()) { Details.ProductAttributeID = ProductAttributeID; Details.ProductAttributeCode = myReader.GetString(1); Details.ProductAttributeName = myReader.GetString(2); } myReader.Close(); return Details; } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(ProductSubAttributeDetails Details) { try { string SQL= "UPDATE tblProductSubAttribute SET " + "ProductAttributeCode = @ProductAttributeCode, " + "ProductAttributeName = @ProductAttributeName " + "WHERE ProductAttributeID = @ProductAttributeID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmProductAttributeCode = new MySqlParameter("@ProductAttributeCode",MySqlDbType.String); prmProductAttributeCode.Value = Details.ProductAttributeCode; cmd.Parameters.Add(prmProductAttributeCode); MySqlParameter prmProductAttributeName = new MySqlParameter("@ProductAttributeName",MySqlDbType.String); prmProductAttributeName.Value = Details.ProductAttributeName; cmd.Parameters.Add(prmProductAttributeName); MySqlParameter prmProductAttributeID = new MySqlParameter("@ProductAttributeID",MySqlDbType.Int16); prmProductAttributeID.Value = Details.ProductAttributeID; cmd.Parameters.Add(prmProductAttributeID); base.ExecuteNonQuery(cmd); } catch (Exception ex) { throw base.ThrowException(ex); } }