예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                OleDbConnection dbConn = new OleDbConnection();
                OleDbCommand dbCommand = new OleDbCommand();

                String sql = "INSERT INTO [User_tbl] values('" + textBox1.Text + "','" + textBox2.Text + "')";

                bool isSave = new clsDB().ADO().ExecuteSql(sql);

                if (!isSave) { return; }

                DialogResult dr = MessageBox.Show("Successfully Saved! \n Do you want to add another data?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                dbConn.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
예제 #2
0
        private void saveData()
        {
            string sql = "Insert Into Shippers(CompanyName,Phone) values('" +
                         textBox2.Text + "','" +
                         textBox3.Text + "')";

            bool isSave = new clsDB().ADO().ExecuteSql(sql);

            if (!isSave) { return; }

            //invoke the delegate to execute the function(RefreshData)
            modRefreshData("Activated!!");

            DialogResult dr = MessageBox.Show("Successfully Saved! \n Do you want to add another data?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                textBox1.Clear();
                textBox2.Clear();
                textBox3.Clear();

            }

            //set to exit the form
            isClosing = true;
        }
예제 #3
0
        private void updateData()
        {
            string sql = "Update Shippers " +
                         "Set  CompanyName='" + textBox2.Text + "'," +
                         "Phone='" + textBox3.Text + "'," +
                         "Where ShipperID = " + textBox1.Text;

            bool isSave = new clsDB().ADO().ExecuteSql(sql);

            if (!isSave) { return; }

            //invoke the delegate to execute the function(RefreshData)
            modRefreshData("Activated!!");

            MessageBox.Show("Successfully Updated!", "Update", MessageBoxButtons.OK, MessageBoxIcon.Question);

            isClosing = true;
        }
예제 #4
0
        private void updateData()
        {
            string sql = "Update Suppliers " +
                         "Set  CompanyName='" + textBox2.Text + "'," +
                         "ContactName='" + textBox3.Text + "'," +
                         "ContactTitle='" + textBox4.Text + "'," +
                         "Address='" + textBox5.Text + "'," +
                         "City='" + textBox6.Text + "'," +
                         "Region='" + textBox7.Text + "'," +
                         "PostalCode='" + textBox8.Text + "'," +
                         "Country='" + textBox9.Text + "'," +
                         "Phone='" + textBox10.Text + "'," +
                         "Fax='" + textBox11.Text + "'," +
                         "HomePage='" + textBox12.Text + "' " +
                         "Where SupplierID = " + textBox1.Text;

            bool isSave = new clsDB().ADO().ExecuteSql(sql);

            if (!isSave) { return; }

            //invoke the delegate to execute the function(RefreshData)
            modRefreshData("Activated!!");

            MessageBox.Show("Successfully Updated!", "Update", MessageBoxButtons.OK, MessageBoxIcon.Question);

            isClosing = true;
        }
예제 #5
0
        private void saveData()
        {
            string sql = "Insert Into Suppliers(CompanyName,ContactName,ContactTitle,Address,City,Region,PostalCode,Country,Phone,Fax,HomePage) values('" +
                         textBox2.Text + "','" +
                         textBox3.Text + "','" +
                         textBox4.Text + "','" +
                         textBox5.Text + "','" +
                         textBox6.Text + "','" +
                         textBox7.Text + "','" +
                         textBox8.Text + "','" +
                         textBox9.Text + "','" +
                         textBox10.Text + "','" +
                         textBox11.Text + "','" +
                         textBox12.Text + "')";

            bool isSave = new clsDB().ADO().ExecuteSql(sql);

            if (!isSave) { return; }

            //invoke the delegate to execute the function(RefreshData)
            modRefreshData("Activated!!");

            DialogResult dr = MessageBox.Show("Successfully Saved! \n Do you want to add another data?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                textBox1.Clear();
                textBox2.Clear();
                textBox3.Clear();
                textBox4.Clear();
                textBox5.Clear();
                textBox6.Clear();
                textBox7.Clear();
                textBox8.Clear();
                textBox9.Clear();
                textBox10.Clear();
                textBox11.Clear();
                textBox12.Clear();
            }

            //set to exit the form
            isClosing = true;
        }
예제 #6
0
        private void updateData()
        {
            string[] reportTo = new string[1];
            string[] fname = textBox14.Text.Split(',');

            new clsDB().ADO().SelectData("Select EmployeeID from Employees Where LastName='" + fname[0] + "' And FirstName='" + fname[1].Trim() + "'", reportTo);

            string sql = "Update Employees " +
                         "Set  LastName='" + textBox2.Text + "'," +
                         "FirstName='" + textBox3.Text + "'," +
                         "Title='" + textBox4.Text + "'," +
                         "TitleOfCourtesy='" + textBox5.Text + "'," +
                         "BirthDate=#" + textBox6.Text + "#," +
                         "HireDate=#" + textBox7.Text + "#," +
                         "Address='" + textBox8.Text + "'," +
                         "City='" + textBox9.Text + "'," +
                         "Region='" + textBox10.Text + "'," +
                         "PostalCode='" + textBox11.Text + "'," +
                         "Country='" + textBox12.Text + "'," +
                         "HomePhone='" + textBox13.Text + "'," +
                         "ReportsTo=" + reportTo[0] + " " +
                         "Where EmployeeID = " + textBox1.Text;

            bool isSave = new clsDB().ADO().ExecuteSql(sql);

            if (!isSave) { return; }

            //invoke the delegate to execute the function(RefreshData)
            modRefreshData("Activated!!");

            MessageBox.Show("Successfully Updated!", "Update", MessageBoxButtons.OK, MessageBoxIcon.Question);

            isClosing = true;
        }
예제 #7
0
        private void saveData()
        {
            string[] reportTo = new string[1];
            string[] fname = textBox14.Text.Split(',');

            new clsDB().ADO().SelectData("Select EmployeeID from Employees Where LastName='" + fname[0] + "' And FirstName='" + fname[1].Trim() + "'", reportTo);

            string sql = "Insert Into Employees(LastName,FirstName,Title,TitleOfCourtesy,BirthDate,HireDate,Address,City,Region,PostalCode,Country,HomePhone,ReportsTo) values('" +
                         textBox2.Text + "','" +
                         textBox3.Text + "','" +
                         textBox4.Text + "','" +
                         textBox5.Text + "',#" +
                         textBox6.Text + "#,#" +
                         textBox7.Text + "#,'" +
                         textBox8.Text + "','" +
                         textBox9.Text + "','" +
                         textBox10.Text + "','" +
                         textBox11.Text + "','" +
                         textBox12.Text + "','" +
                         textBox13.Text + "'," +
                         reportTo[0] + ")";

            bool isSave = new clsDB().ADO().ExecuteSql(sql);

            if (!isSave) { return; }

            //invoke the delegate to execute the function(RefreshData)
            modRefreshData("Activated!!");

            DialogResult dr = MessageBox.Show("Successfully Saved! \n Do you want to add another data?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                textBox1.Clear();
                textBox2.Clear();
                textBox3.Clear();
                textBox4.Clear();
                textBox5.Clear();
                textBox6.Clear();
                textBox7.Clear();
                textBox8.Clear();
                textBox9.Clear();
                textBox10.Clear();
                textBox11.Clear();
                textBox12.Clear();
                textBox13.Clear();
                textBox12.Text = "";
            }

            //set to exit the form
            isClosing = true;
        }
예제 #8
0
        private void updateData()
        {
            //NOTE: BE CAREFUL WITH SINGLE QOUTES QUERY AS SOMETIMES WILL CAUSE
            //UNWANTED BEHAVIOR

            string[] obj = new string[1];
            new clsDB().ADO().SelectData("Select SupplierID from Suppliers Where CompanyName='" + textBox3.Text + "'", obj);
            string suppid = obj[0];

            new clsDB().ADO().SelectData("Select CategoryID from Categories Where CategoryName='" + textBox4.Text + "'", obj);
            string catid = obj[0];

            string sql = "Update Products " +
                         "Set ProductName='" + textBox2.Text + "'" +
                         ",SupplierID=" + suppid +
                         ",CategoryID=" + catid +
                         ",QuantityPerUnit='" + textBox5.Text + "'" +
                         ",UnitPrice=" + textBox6.Text +
                         ",UnitsInStock=" + textBox7.Text +
                         ",UnitsOnOrder=" + textBox8.Text +
                         ",ReorderLevel=" + textBox9.Text +
                         " Where ProductID=" + textBox1.Text;

            bool isSave = new clsDB().ADO().ExecuteSql(sql);

            if (!isSave) { return; }

            //invoke the delegate to execute the function(RefreshData)
            modRefreshData("Activated!!");

            MessageBox.Show("Successfully Updated!", "Update", MessageBoxButtons.OK, MessageBoxIcon.Question);

            isClosing = true;
        }
예제 #9
0
        private void saveData()
        {
            //NOTE: BE CAREFUL WITH SINGLE QOUTES QUERY AS SOMETIMES WILL CAUSE
            //UNWANTED BEHAVIOR

            string[] obj = new string[1];
            new clsDB().ADO().SelectData("Select SupplierID from Suppliers Where CompanyName='" + textBox3.Text + "'", obj);
            string suppid = obj[0];

            new clsDB().ADO().SelectData("Select CategoryID from Categories Where CategoryName='" + textBox4.Text + "'", obj);
            string catid = obj[0];

            //MessageBox.Show(suppid + " | " + catid); //This is a checker

            string sql = "Insert Into Products(ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel) Values('" +
                                                textBox2.Text + "'," +
                                                suppid + "," +
                                                catid + ",'" +
                                                textBox5.Text + "'," +
                                                textBox6.Text + "," +
                                                textBox7.Text + "," +
                                                textBox8.Text + "," +
                                                textBox9.Text + ")";

            //MessageBox.Show(sql);    //This is a checker

            bool isSave = new clsDB().ADO().ExecuteSql(sql);

            if (!isSave) { return; }

            //invoke the delegate to execute the function(RefreshData)
            modRefreshData("Activated!!");

            DialogResult dr = MessageBox.Show("Successfully Saved! \n Do you want to add another data?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                textBox1.Clear();
                textBox2.Clear();
                textBox3.Text = "";
                textBox4.Text = "";
                textBox5.Clear();
                textBox6.Clear();
                textBox7.Clear();
                textBox8.Clear();
                textBox9.Clear();
                textBox10.Clear();
            }

            //set to exit the form
            isClosing = true;
        }
예제 #10
0
        //THIS IS AN EXAMPLE OF RECURSION(FUNCTION THAT CALL ITSELF)
        private string generateID(string str,int itr)
        {
            string[] obj = new string[1];
            string res="";
            bool b = new clsDB().ADO().SelectData("Select CompanyName from Customers Where CustomerID='" + str + "'", obj);

            if (b)
            {
                res = generateID(obj[0].Substring(0, 4).ToUpper() + Convert.ToString(itr + 1), itr + 1);
            }
            else
            {
                res = str;
            }

            return res;
        }