コード例 #1
0
        private void Rem_Click_1(object sender, EventArgs e)
        {
            if (dataGridView2.SelectedRows.Count > 0)
            {
                DataGridViewRow row = this.dataGridView2.SelectedRows[0];

                emp = row.Cells["EmpId"].Value.ToString();
            }


            String          q2           = "delete from itp.employee where EmpId ='" + emp + "' ";
            MySqlConnection connDatabase = ConnectionOld.getConnection();
            MySqlCommand    cmdDatabase  = new MySqlCommand(q2, connDatabase);
            MySqlDataReader myReader;

            try
            {
                connDatabase.Open();
                myReader = cmdDatabase.ExecuteReader();
                //MessageBox.Show("Record is deleted successfully");
                PanMessage.Show(this.MdiParent, "Record Deleted", "Record is deleted successfully");
                displayDataGridViewSearch();
            }

            catch (MySqlException ex)
            {
                PanException.Show(this.MdiParent, ex);
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do you really want to delete this entry from the table?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try
                {
                    DBConnect connection = new DBConnect();
                    connection.OpenConnection();

                    MySqlConnection returnConn = new MySqlConnection();
                    returnConn = connection.GetConnection();

                    string       query = "DELETE FROM itp.buyer WHERE storeName = '" + listBox1.Text + "'";
                    MySqlCommand cmd   = new MySqlCommand(query, returnConn);
                    cmd.ExecuteNonQuery();
                    connection.CloseConnection();

                    PanMessage.Show(this.MdiParent, "Success", "Entry deleted successfully");
                    this.listBox1.Items.Clear();
                    fillList();
                }
                catch (MySqlException ex)
                {
                    PanException.Show(this.MdiParent, ex);
                }
            }
        }
コード例 #3
0
        private void CalSalary_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                MySqlCommand command = new MySqlCommand("calcSalary", con);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("_month", salMonth);
                command.ExecuteScalar();

                //MessageBox.Show("Salary is calculated for "+salMonth);
                PanMessage.Show(this.MdiParent, "Salary", "Salary is calculated for " + salMonth);
            }
            catch (MySqlException ex)
            {
                PanException.Show(this.MdiParent, ex);
            }
            finally
            {
                con.Close();
            }
        }
コード例 #4
0
        private void button4_Click(object sender, EventArgs e)
        {
            int Annual = Int32.Parse(labRemAnnual.Text);
            int Casual = Int32.Parse(labRemCasual.Text);


            DateTime endDate   = dateTimePicker2.Value;
            DateTime startDate = dateTimePicker3.Value;

            TimeSpan tspan = endDate - startDate;

            int differenceInDays = tspan.Days;

            if ((this.Type_combo.Text == "Annual") && (differenceInDays > Annual))
            {
                PanException.Show(this.MdiParent, "Annual leave", "You are exceeding the number of remaining annual days");
                return;
            }

            if ((this.Type_combo.Text == "Casual") && (differenceInDays > Casual))
            {
                PanException.Show(this.MdiParent, "Casual leave", "You are exceeding the number of remaining casual days");
                return;
            }



            DateTime start = Convert.ToDateTime(dateTimePicker3.Text);
            DateTime end   = Convert.ToDateTime(dateTimePicker2.Text);

            String          query        = "insert into `leave`(Type,Reason,StartDate,EndDate,RequestedDate,Status,EmpId) values('" + this.Type_combo.Text + "','" + this.Reason.Text + "', @date1 , @date2 , CURDATE(),'Pending', '" + Connection.getUserIdFromConnectionString() + "')";
            MySqlConnection connDatabase = ConnectionOld.getConnection();
            MySqlCommand    cmdDatabase  = new MySqlCommand(query, connDatabase);
            MySqlParameter  param        = new MySqlParameter("@date1", MySqlDbType.Date);

            param.Value = dateTimePicker3.Value;
            MySqlParameter param2 = new MySqlParameter("@date2", MySqlDbType.Date);

            param2.Value = dateTimePicker2.Value;
            cmdDatabase.Parameters.Add(param);
            cmdDatabase.Parameters.Add(param2);

            try
            {
                connDatabase.Open();
                cmdDatabase.ExecuteNonQuery();
                //MessageBox.Show("Records are saved successfully\n");
                PanMessage.Show(this.MdiParent, "Success", "Your leave request has been sent");
                refreshEmpLeaveTable();
            }

            catch (MySqlException ex)
            {
                PanException.Show(this.MdiParent, ex);
            }
        }
コード例 #5
0
        public void Insert()
        {
            isEmpty();

            if (!checkMail(this.Email_txt.Text))
            {
                //MessageBox.Show("Not a valid Email address ");
                PanException.Show(this.MdiParent, "Validation Error", "Not a valid Email address");
                return;
            }
            else if (labNationality.Text == "NIC" && (!checkNIC(this.NIC_txt.Text)))
            {
                //MessageBox.Show("Not a valid NIC Number ");
                PanException.Show(this.MdiParent, "Validation Error", "Not a valid NIC Number");
                return;
            }
            else if (Double.Parse(textBox5.Text) < 10000)
            {
                //MessageBox.Show("Basic Salary should be above 10000");
                PanException.Show(this.MdiParent, "Validation Error", "Basic Salary should be above 10000");
                return;
            }

            /*if (!checkMobile())
             * {
             *  MessageBox.Show("Mobile Number should have 10 digits");
             *  return;
             * }*/
            String          us           = assignUserName();
            int             val          = getNewId();
            Double          sal          = Double.Parse(this.textBox5.Text);
            String          query        = "insert into itp.employee(EmpId,FirstName,LastName,Nationality,Email,MobileNo,NIC,Position,DepId,Gender,DOB,Address,UserName,Password,BasicSalary) values('" + this.Emp_txt.Text + "','" + this.First_txt.Text + "','" + this.Last_txt.Text + "','" + nat + "','" + this.Email_txt.Text + "','" + this.Mob_txt.Text + "','" + this.NIC_txt.Text + "','" + this.Posi_combo.Text + "','" + dep + "','" + gender + "','" + this.dateTimePicker1.Text + "','" + this.Add_txt.Text + "','" + us + "','" + pw + "','" + sal + "'); ";
            MySqlConnection connDatabase = ConnectionOld.getConnection();
            MySqlCommand    cmdDatabase  = new MySqlCommand(query, connDatabase);
            MySqlCommand    createUser   = new MySqlCommand("CREATE_USER", connDatabase);

            createUser.CommandType = CommandType.StoredProcedure;
            createUser.Parameters.AddWithValue("user_id_", this.Emp_txt.Text);
            createUser.Parameters.AddWithValue("password_", pw);
            createUser.Parameters.AddWithValue("name_", this.First_txt.Text + " " + this.Last_txt.Text);

            try
            {
                connDatabase.Open();
                cmdDatabase.ExecuteNonQuery();
                createUser.ExecuteNonQuery();
                //MessageBox.Show("Records are saved successfully\n" + this.First_txt.Text +  this.Last_txt.Text +  " 's Username is " + us);
                PanMessage.Show(this.MdiParent, "Success", "Records are saved successfully\n" + this.First_txt.Text + this.Last_txt.Text + " 's Username is " + us);
            }

            catch (MySqlException ex)
            {
                PanException.Show(this.MdiParent, ex);
            }
        }
コード例 #6
0
        private void updateBtn_Click(object sender, EventArgs e)
        {
            if (validate.isEmpty(store.Text) && validate.isContact(officeNo.Text) && validate.isNumber(creditLimit.Text) &&
                validate.isEmpty(address.Text) && validate.isChar(city.Text) && validate.isChar(district.Text) && validate.isChar(contact.Text) &&
                validate.isChar(contactJob.Text) && validate.isContact(contactNum.Text))
            {
                this.x = true;

                if (!String.IsNullOrEmpty(fax.Text))
                {
                    this.x = validate.isContact(fax.Text);
                }

                if (!String.IsNullOrEmpty(email.Text))
                {
                    this.x = validate.isEmail(email.Text);
                }
            }

            if (this.x == true)
            {
                try
                {
                    DBConnect connection = new DBConnect();
                    connection.OpenConnection();

                    MySqlConnection returnConn = new MySqlConnection();
                    returnConn = connection.GetConnection();

                    string query = "UPDATE itp.buyer SET storeName='" + store.Text + "', contactName='" + contact.Text + "', contactJob='" + contactJob.Text + "', officeNo='" + officeNo.Text + "', personalNo='" + contactNum.Text + "', fax='" + fax.Text + "', email='" + email.Text + "', address='" + address.Text + "', city ='" + city.Text + "', district ='" + district.Text + "', creditLimit='" + creditLimit.Text + "' WHERE storeName ='" + listBox1.SelectedItem.ToString() + "'";;

                    MySqlCommand cmd = new MySqlCommand(query, returnConn);
                    cmd.Connection = returnConn;
                    cmd.ExecuteNonQuery();
                    connection.CloseConnection();

                    this.listBox1.Items.Clear();
                    fillList();
                    PanMessage.Show(this.MdiParent, "Success", "Buyer information updated");
                }
                catch (MySqlException ex)
                {
                    PanException.Show(this.MdiParent, ex);
                    //throw;
                }
            }
            else
            {
                PanException.Show(this.MdiParent, "Invalid entries", "Check entered fields");
            }
        }
コード例 #7
0
        public void setDetails()
        {
            String          q2           = "update itp.employee set FirstName ='" + this.First_txt.Text + "', LastName ='" + this.Last_txt.Text + "',Gender ='" + gender + "', Address ='" + this.Add_txt.Text + "', MobileNo ='" + this.Mob_txt.Text + "', Email ='" + this.Email_txt.Text + "' where EmpId = '" + Connection.getUserIdFromConnectionString() + "' ";
            MySqlConnection connDatabase = ConnectionOld.getConnection();
            MySqlCommand    cmdDatabase  = new MySqlCommand(q2, connDatabase);
            MySqlDataReader myReader;

            try
            {
                connDatabase.Open();
                myReader = cmdDatabase.ExecuteReader();
                //MessageBox.Show("Records are edited successfully");
                PanMessage.Show(this.MdiParent, "Success", "Records are edited successfully");
            }

            catch (MySqlException ex)
            {
                PanException.Show(this.MdiParent, ex);
            }
        }
コード例 #8
0
        private void button5_Click(object sender, EventArgs e)
        {
            String          q2           = "update itp.leave set Status ='Denied' where EmpId = '" + emp + "' ";
            MySqlConnection connDatabase = ConnectionOld.getConnection();
            MySqlCommand    cmdDatabase  = new MySqlCommand(q2, connDatabase);
            MySqlDataReader myReader;

            try
            {
                connDatabase.Open();
                myReader = cmdDatabase.ExecuteReader();
                //MessageBox.Show("You have rejected the request");
                PanMessage.Show(this.MdiParent, "Leave Request", "Leave request rejected");
                refreshHRLeaveTable();
            }

            catch (MySqlException ex)
            {
                PanException.Show(this.MdiParent, ex);
            }
        }
コード例 #9
0
        private void Ot_Save_Click(object sender, EventArgs e)
        {
            MySqlCommand ic = new MySqlCommand("INSERT INTO ot (EmpId,OTHours,Month) VALUES (@empid,@ot,'" + mon + "')", con);

            ic.Parameters.Add("@empid", MySqlDbType.Int32, 200, "EmpId");
            ic.Parameters.Add("@ot", MySqlDbType.Float, 200, "OTHours");


            MySqlCommand uc = new MySqlCommand("INSERT INTO ot (EmpId,OTHours,Month) VALUES (@empid,@ot,'" + mon + "')", con);

            uc.Parameters.Add("@empid", MySqlDbType.Int32, 200, "EmpId");
            uc.Parameters.Add("@ot", MySqlDbType.Float, 200, "OTHours");


            sda.InsertCommand = ic;
            sda.UpdateCommand = uc;
            this.Validate();
            bindingSource1.EndEdit();
            sda.Update(datasetOT);
            //MessageBox.Show("OT Hours Added");
            PanMessage.Show(this.MdiParent, "OT Hours", "OT hours have been added");
        }
コード例 #10
0
        //confirm order method
        private void button3_Click(object sender, EventArgs e)
        {
            string query, query2;
            string mailOrder = null;

            try
            {
                DBConnect conn = new DBConnect();
                conn.OpenConnection();
                MySqlConnection returnConn = new MySqlConnection();
                returnConn = conn.GetConnection();


                if (!string.IsNullOrEmpty(textBox1.Text) || !string.IsNullOrEmpty(this.tempBuyerId) || metroGrid1.Rows.Count != 0 || !string.IsNullOrEmpty(this.tempDate) || !string.IsNullOrEmpty(this.tempAgent))
                {
                    for (int i = 0; i < metroGrid1.Rows.Count - 1; i++)
                    {
                        query = "INSERT INTO itp.orders (invoiceNo, buyerId, productId, quantity, unitPrice, total, shippingDate, empId) VALUES ("
                                + "'" + textBox1.Text + "',"
                                + "'" + this.tempBuyerId + "',"
                                + metroGrid1.Rows[i].Cells[0].Value + ","
                                + metroGrid1.Rows[i].Cells[3].Value + ","
                                + metroGrid1.Rows[i].Cells[2].Value + ","
                                + metroGrid1.Rows[i].Cells[4].Value + ","
                                + "'" + this.tempDate + "',"
                                + "'" + this.tempAgent + "');";

                        #region !!!!!!!!
                        query2 = "INSERT INTO itp.payment (invoiceNo, paid, description) VALUES ('" + textBox1.Text + "', 0, 'Order received - Payment yet be received')";

                        MySqlCommand cmd = new MySqlCommand(query, returnConn);
                        cmd.ExecuteNonQuery();
                        MySqlCommand cmd2 = new MySqlCommand(query2, returnConn);
                        cmd2.ExecuteNonQuery();
                        #endregion

                        mailOrder += "" + metroGrid1.Rows[i].Cells[0].Value + " (" + metroGrid1.Rows[i].Cells[3].Value + ") =" + metroGrid1.Rows[i].Cells[4].Value + " \n";
                    }

                    PanMessage.Show(this.MdiParent, "Order has been placed");
                    conn.CloseConnection();

                    if (!String.IsNullOrEmpty(this.tempMail))
                    {
                        try
                        {
                            mailOrder += "------------------------------------------ \n" +
                                         "Grand total = " + this.count + "\n" +
                                         "Delivery Date = " + this.tempDate;

                            emailThis mail = new emailThis();
                            mail.sendMail(this.tempMail, mailOrder);
                        }
                        catch (Exception ex)
                        {
                            PanException.Show(this.MdiParent, "Error", "Mail has not been sent");
                        }
                    }

                    //invoiceViewer a = new invoiceViewer();
                    //a.method1(textBox1.Text);
                    //a.method2(textBox2.Text);
                }

                else
                {
                    PanException.Show(this, "Invalid inputs", "Please recheck your entry");
                }
            }
            catch (MySqlException ex)
            {
                PanException.Show(this.MdiParent, "Error", "Invoice duplicating is not allowed\n" + ex);
            }
        }
コード例 #11
0
ファイル: paymentAdd.cs プロジェクト: tayduivn/ITP
        private void button1_Click(object sender, EventArgs e)
        {
            string amount;
            string desc;
            string cheque;
            string bank;

            string invoice = comboBox1.Text;
            string payee   = textBox1.Text;

            try
            {
                DBConnect connection = new DBConnect();
                connection.OpenConnection();
                MySqlConnection returnConn = new MySqlConnection();
                returnConn = connection.GetConnection();

                string       query = "INSERT INTO itp.payment (invoiceNo, paid, description) VALUES (@1, @2, @3)";
                MySqlCommand cmd   = new MySqlCommand(query, returnConn);
                //cmd.CommandType = CommandType.Text; //default

                cmd.Parameters.AddWithValue("@1", invoice);

                if (radioButton1.Checked)
                {
                    amount = textBox6.Text;
                    int n;

                    if (!string.IsNullOrEmpty(amount) || !string.IsNullOrWhiteSpace(amount) || int.TryParse(amount, out n))
                    {
                        desc = "Payee " + payee + " has used Cash Payment method";
                        cmd.Parameters.AddWithValue("@2", amount);
                        cmd.Parameters.AddWithValue("@3", desc);
                    }
                    else
                    {
                        PanException.Show(this.MdiParent, "Invalid Input", "Invalid value for amount");
                    }
                }
                else if (radioButton2.Checked)
                {
                    amount = textBox5.Text;
                    cheque = textBox3.Text;
                    bank   = textBox4.Text;
                    int n;

                    if (!string.IsNullOrEmpty(amount) || !string.IsNullOrWhiteSpace(amount) || int.TryParse(amount, out n) || int.TryParse(cheque, out n))
                    {
                        desc = "Payee " + payee + " has used Cheque Payment method - Cheque No: " + cheque + " / Bank: " + bank;
                        cmd.Parameters.AddWithValue("@2", amount);
                        cmd.Parameters.AddWithValue("@3", desc);
                    }
                    else
                    {
                        PanException.Show(this.MdiParent, "Error", "Invalid Inputs");
                    }
                }
                else
                {
                    PanException.Show(this.MdiParent, "Error", "Select a payment method");
                }

                //connection.OpenConnection();
                cmd.ExecuteNonQuery();
                connection.CloseConnection();

                PanMessage.Show(this.MdiParent, "Success");
            }

            catch (MySqlException ex)
            {
                PanException.Show(this.MdiParent, ex);
            }
        }