Example #1
0
		public Int32 Insert(ProductUnitDetails Details)
		{
			try 
			{
				string SQL = "INSERT INTO tblProductUnit (ProductUnitCode, ProductUnitName) VALUES (@ProductUnitCode, @ProductUnitName);";
				  
				
	 			
				MySqlCommand cmd = new MySqlCommand();
				
				
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
				MySqlParameter prmProductUnitCode = new MySqlParameter("@ProductUnitCode",MySqlDbType.String);			
				prmProductUnitCode.Value = Details.ProductUnitCode;
				cmd.Parameters.Add(prmProductUnitCode);

				MySqlParameter prmProductUnitName = new MySqlParameter("@ProductUnitName",MySqlDbType.String);			
				prmProductUnitName.Value = Details.ProductUnitName;
				cmd.Parameters.Add(prmProductUnitName);

				base.ExecuteNonQuery(cmd);

				SQL = "SELECT LAST_INSERT_ID();";
				
				cmd.Parameters.Clear(); 
				cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("ProdUnit");
                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);
			}	
		}
Example #2
0
        public Int32 Insert(ProductUnitDetails Details)
        {
            try
            {
                string SQL = "INSERT INTO tblProductUnit (ProductUnitCode, ProductUnitName) VALUES (@ProductUnitCode, @ProductUnitName);";



                MySqlCommand cmd = new MySqlCommand();


                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                MySqlParameter prmProductUnitCode = new MySqlParameter("@ProductUnitCode", MySqlDbType.String);
                prmProductUnitCode.Value = Details.ProductUnitCode;
                cmd.Parameters.Add(prmProductUnitCode);

                MySqlParameter prmProductUnitName = new MySqlParameter("@ProductUnitName", MySqlDbType.String);
                prmProductUnitName.Value = Details.ProductUnitName;
                cmd.Parameters.Add(prmProductUnitName);

                base.ExecuteNonQuery(cmd);

                SQL = "SELECT LAST_INSERT_ID();";

                cmd.Parameters.Clear();
                cmd.CommandText = SQL;

                System.Data.DataTable dt = new System.Data.DataTable("ProdUnit");
                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);
            }
        }
Example #3
0
        public ProductUnitDetails Details(Int32 ProductUnitID)
        {
            try
            {
                string SQL = "SELECT " +
                             "ProductUnitID, " +
                             "ProductUnitCode, " +
                             "ProductUnitName " +
                             "FROM tblProductUnit " +
                             "WHERE ProductUnitID = @ProductUnitID;";

                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                MySqlParameter prmProductUnitID = new MySqlParameter("@ProductUnitID", MySqlDbType.Int32);
                prmProductUnitID.Value = ProductUnitID;
                cmd.Parameters.Add(prmProductUnitID);

                ProductUnitDetails Details = new ProductUnitDetails();

                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    Details.ProductUnitID   = ProductUnitID;
                    Details.ProductUnitCode = "" + dr["ProductUnitCode"].ToString();
                    Details.ProductUnitName = "" + dr["ProductUnitName"].ToString();
                }

                return(Details);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Example #4
0
        public void Update(ProductUnitDetails Details)
        {
            try
            {
                string SQL = "UPDATE tblProductUnit SET " +
                             "ProductUnitCode = @ProductUnitCode, " +
                             "ProductUnitName = @ProductUnitName " +
                             "WHERE ProductUnitID = @ProductUnitID;";



                MySqlCommand cmd = new MySqlCommand();


                cmd.CommandType = System.Data.CommandType.Text;
                cmd.CommandText = SQL;

                MySqlParameter prmProductUnitCode = new MySqlParameter("@ProductUnitCode", MySqlDbType.String);
                prmProductUnitCode.Value = Details.ProductUnitCode;
                cmd.Parameters.Add(prmProductUnitCode);

                MySqlParameter prmProductUnitName = new MySqlParameter("@ProductUnitName", MySqlDbType.String);
                prmProductUnitName.Value = Details.ProductUnitName;
                cmd.Parameters.Add(prmProductUnitName);

                MySqlParameter prmProductUnitID = new MySqlParameter("@ProductUnitID", MySqlDbType.Int16);
                prmProductUnitID.Value = Details.ProductUnitID;
                cmd.Parameters.Add(prmProductUnitID);

                base.ExecuteNonQuery(cmd);
            }

            catch (Exception ex)
            {
                throw base.ThrowException(ex);
            }
        }
Example #5
0
		public ProductUnitDetails Details(Int32 ProductUnitID)
		{
			try
			{
				string SQL=	"SELECT " +
								"ProductUnitID, " +
								"ProductUnitCode, " +
								"ProductUnitName " +
							"FROM tblProductUnit " +
							"WHERE ProductUnitID = @ProductUnitID;";

				MySqlCommand cmd = new MySqlCommand();
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;

				MySqlParameter prmProductUnitID = new MySqlParameter("@ProductUnitID",MySqlDbType.Int32);
				prmProductUnitID.Value = ProductUnitID;
				cmd.Parameters.Add(prmProductUnitID);

				ProductUnitDetails Details = new ProductUnitDetails();

                string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName);
                base.MySqlDataAdapterFill(cmd, dt);
				foreach(System.Data.DataRow dr in dt.Rows)
				{
					Details.ProductUnitID = ProductUnitID;
					Details.ProductUnitCode = "" + dr["ProductUnitCode"].ToString();
                    Details.ProductUnitName = "" + dr["ProductUnitName"].ToString();
				}
				
                return Details;
			}

			catch (Exception ex)
			{
				throw base.ThrowException(ex);
			}	
		}
Example #6
0
		public void Update(ProductUnitDetails Details)
		{
			try 
			{
				string SQL=	"UPDATE tblProductUnit SET " + 
							"ProductUnitCode = @ProductUnitCode, " +  
							"ProductUnitName = @ProductUnitName " +  
							"WHERE ProductUnitID = @ProductUnitID;";
				  
				
	 			
				MySqlCommand cmd = new MySqlCommand();
				
				
				cmd.CommandType = System.Data.CommandType.Text;
				cmd.CommandText = SQL;
				
				MySqlParameter prmProductUnitCode = new MySqlParameter("@ProductUnitCode",MySqlDbType.String);			
				prmProductUnitCode.Value = Details.ProductUnitCode;
				cmd.Parameters.Add(prmProductUnitCode);

				MySqlParameter prmProductUnitName = new MySqlParameter("@ProductUnitName",MySqlDbType.String);			
				prmProductUnitName.Value = Details.ProductUnitName;
				cmd.Parameters.Add(prmProductUnitName);

				MySqlParameter prmProductUnitID = new MySqlParameter("@ProductUnitID",MySqlDbType.Int16);			
				prmProductUnitID.Value = Details.ProductUnitID;
				cmd.Parameters.Add(prmProductUnitID);

				base.ExecuteNonQuery(cmd);
			}

			catch (Exception ex)
			{
				
				
					

				
				
				

				throw base.ThrowException(ex);
			}	
		}