Beispiel #1
0
        }//END OF CREATE BRAND

        public Boolean updateBrands(VehicleBrand passedData)
        {
            bool reqStatus = false;

            passedData.brandName     = passedData.brandName;
            passedData.brandCategory = passedData.brandCategory;
            passedData.brandStatus   = Sanitize(passedData.brandStatus);

            try
            {
                openConnection();
                sql = @"UPDATE tblvehiclebrand SET brandName='" + passedData.brandName +
                      "', brandCategory='" + passedData.brandCategory +
                      "', brandStatus='" + passedData.brandStatus +
                      "' WHERE brandID='" + passedData.brandID + "'";

                cmd = new MySqlCommand(sql, con);
                cmd.ExecuteNonQuery();

                reqStatus = true;
            }
            catch
            {
                reqStatus = false;
            }
            finally
            {
                con.Close();
            }

            return(reqStatus);
        }//END OF UPDATE BRAND
Beispiel #2
0
        }//END OF READ ALL BRAND ACTIVE

        public List <VehicleBrand> searchBrands_all(string searchText)
        {
            searchText = Sanitize(searchText);

            try
            {
                openConnection();
                sql = @"SELECT * FROM tblvehiclebrand WHERE brandName LIKE '%" + searchText +
                      "%' OR brandStatus LIKE '%" + searchText +
                      "%'";
                cmd = new MySqlCommand(sql, con);
                rd  = cmd.ExecuteReader();

                if (rd.HasRows)
                {
                    var listOfBrand = new List <VehicleBrand>();

                    while (rd.Read())
                    {
                        var brand = new VehicleBrand();

                        brand.brandID       = rd["brandID"].ToString();
                        brand.brandName     = rd["brandName"].ToString();
                        brand.brandCategory = rd["brandCategory"].ToString();
                        brand.brandStatus   = rd["brandStatus"].ToString();

                        brand.created_at = rd["created_at"].ToString();
                        brand.updated_at = rd["updated_at"].ToString();

                        listOfBrand.Add(brand);
                    }

                    return(listOfBrand);
                }
                else
                {
                    Console.WriteLine("No data");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                con.Close();
            }

            return(null);
        }//END OF SEARCH FROM ALL BRAND
Beispiel #3
0
        }//END OF READ ALL BRAND

        public List <VehicleBrand> readBrands_active()
        {
            try
            {
                openConnection();
                sql = "SELECT * FROM tblvehiclebrand WHERE brandStatus='ACTIVE'";
                cmd = new MySqlCommand(sql, con);
                rd  = cmd.ExecuteReader();

                if (rd.HasRows)
                {
                    var listOfBrand = new List <VehicleBrand>();

                    while (rd.Read())
                    {
                        var brand = new VehicleBrand();

                        brand.brandID       = rd["brandID"].ToString();
                        brand.brandName     = rd["brandName"].ToString();
                        brand.brandCategory = rd["brandCategory"].ToString();
                        brand.brandStatus   = rd["brandStatus"].ToString();

                        brand.created_at = rd["created_at"].ToString();
                        brand.updated_at = rd["updated_at"].ToString();

                        listOfBrand.Add(brand);
                    }

                    return(listOfBrand);
                }
                else
                {
                    Console.WriteLine("No data");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                con.Close();
            }

            return(null);
        }//END OF READ ALL BRAND ACTIVE
Beispiel #4
0
        }//END OF SEARCH FROM ALL TYPE

        public Boolean createBrands(VehicleBrand passedData)
        {
            bool reqStatus = false;

            passedData.brandName     = passedData.brandName;
            passedData.brandCategory = passedData.brandCategory;
            passedData.brandStatus   = Sanitize(passedData.brandStatus);

            DateTime dateTimeVariable = DateTime.Now;
            string   date             = dateTimeVariable.ToString("yyyy-MM-dd H:mm:ss");

            passedData.created_at = date;


            try
            {
                openConnection();
                sql = @"INSERT INTO tblvehiclebrand SET brandName='" + passedData.brandName +
                      "', brandCategory='" + passedData.brandCategory +
                      "', brandStatus='" + passedData.brandStatus +
                      "', created_at='" + passedData.created_at + "'";

                cmd = new MySqlCommand(sql, con);
                cmd.ExecuteNonQuery();

                reqStatus = true;
            }
            catch
            {
                reqStatus = false;
            }
            finally
            {
                con.Close();
            }

            return(reqStatus);
        }//END OF CREATE BRAND
Beispiel #5
0
        private void btnBrandSave_Click(object sender, EventArgs e)
        {
            if (this.brandActionIdentifier == "ADD")
            {
                if (txtBrandID.Text != "" && txtBrandName.Text != "" && cboBrandCategory.Text != "" && cboBrandStatus.Text != "")
                {
                    VehicleBrand data = new VehicleBrand();
                    data.brandName   = txtBrandName.Text;
                    data.brandStatus = cboBrandStatus.Text;

                    foreach (var type in currentDataType)
                    {
                        //Find Same Type Name
                        if (cboBrandCategory.Text == type.typeName)
                        {
                            data.brandCategory = type.typeID;
                            break;
                        }
                    }


                    if (connect.createBrands(data))
                    {
                        MessageBox.Show("Saved Successfully!");
                        clearBrandFields();
                        LoadBrands();
                    }
                    else
                    {
                        MessageBox.Show("Error Saving!");
                    }
                }
                else
                {
                    MessageBox.Show("Please Complete All Required Fields!");
                }
            }
            else if (this.brandActionIdentifier == "EDIT")
            {
                if (txtBrandID.Text != "" && txtBrandName.Text != "" && cboBrandCategory.Text != "" && cboBrandStatus.Text != "")
                {
                    VehicleBrand data = new VehicleBrand();
                    data.brandID     = txtBrandID.Text;
                    data.brandName   = txtBrandName.Text;
                    data.brandStatus = cboBrandStatus.Text;

                    foreach (var type in currentDataType)
                    {
                        //Find Same Type Name
                        if (cboBrandCategory.Text == type.typeName)
                        {
                            data.brandCategory = type.typeID;
                            break;
                        }
                    }

                    if (connect.updateBrands(data))
                    {
                        MessageBox.Show("Updated Successfully!");
                        clearBrandFields();
                        LoadBrands();
                    }
                    else
                    {
                        MessageBox.Show("Error Saving!");
                    }
                }
                else
                {
                    MessageBox.Show("Please Complete All Required Fields!");
                }
            }
        }