Ejemplo n.º 1
0
        private void delete_Click(object sender, EventArgs e)
        {
            String temNic = "";

            temNic = nictxt.Text;
            Boolean ans = checkNIC(temNic);

            if (temNic == "")
            {
                // MessageBox.Show("Pleace Insert NIC!!!");
                ErrorDialogBox.ShowDialog("Pleace Insert NIC!!!", "Validation Error");
            }
            else if (ans != true)
            {
                ErrorDialogBox.ShowDialog("Invalid NIC. Please enter Registerd NIC", "Validation Error");
            }
            else
            {
                con.Open();
                cmd = new SqlCommand("Delete from  Staff_Mang_Table where NIC =  '" + nictxt.Text + "'", con);
                cmd.ExecuteNonQuery();
                SuccessfullMessageBox.ShowDialog("Delere Records Successfully!!!", "Confirmation Message");
                // MessageBox.Show("Delere Records Successfully!!!");
                con.Close();
                display();
                clearallData();
            }
        }
        private void changePassword_btn_Click(object sender, EventArgs e)
        {
            String getNIC = Login.setNIC;

            if (Login.setpassword == currentPassword_txt.Text)
            {
                if (newPassword_txt.Text == confirmPassword_txt.Text)
                {
                    con.Open();
                    cmd = new SqlCommand("update Staff_Mang_Table set password= '******' where NIC = @getNIC", con);
                    cmd.Parameters.Add("@getNIC", SqlDbType.VarChar).Value = getNIC;
                    cmd.ExecuteNonQuery();
                    SuccessfullMessageBox.ShowDialog("Password Update Successfully !!!", "Confirmation Message");
                    con.Close();
                }
                else
                {
                    ErrorDialogBox.ShowDialog("Confirm Password Does't macth with new Password!!!", "New Password Invaild");
                    newPassword_txt.Text     = "";
                    confirmPassword_txt.Text = "";
                }
            }
            else
            {
                ErrorDialogBox.ShowDialog("Current Password does not match.!!!", "Current Password Invaild");
            }
        }
Ejemplo n.º 3
0
        private void cancelbtn_Click(object sender, EventArgs e)
        {
            if (staffnicLabel.Text == null || typeLable.Text == null)
            {
                ErrorDialogBox.ShowDialog("Please double click one rquest from table First", "Invaild Data");
            }
            else
            {
                con.Open();
                cmd = new SqlCommand("Delete from staff_Temp_Request_Leaves where sid = @sid", con);
                cmd.Parameters.Add("@sid", SqlDbType.Int).Value = sid;
                cmd.ExecuteNonQuery();
                con.Close();

                SuccessfullMessageBox.ShowDialog("Request Cancle Successfully !!!", "Confirmation Message");


                String cancleby = Login.setNIC;
                con.Open();
                cmd = new SqlCommand("insert into staff_cancle_Leaves (NIC, type, reason, date, cancleby)values('" + staffnicLabel.Text + "', '" + typeLable.Text + "', '" + reasonLable.Text + "', '" + dateLable.Text + "', @approveby)", con);

                cmd.Parameters.Add("@approveby", SqlDbType.VarChar).Value = cancleby;

                cmd.ExecuteNonQuery();

                con.Close();
                cleareText();
            }
        }
Ejemplo n.º 4
0
        public static void ShowDialog(string msg, string tMsg)
        {
            ErrorDialogBox sdb = new ErrorDialogBox(msg, tMsg);

            sdb.ShowDialog();
        }
Ejemplo n.º 5
0
        private void loginbtn_Click(object sender, EventArgs e)
        {
            String atype = null;

            atype = atypelogin.Text.ToString();

            if (atypelogin.Text == "Admin")
            {
                String username = "******";
                String password = "******";

                if (usernametxt.Text == username && loginpasswordtxt.Text == password)
                {
                    this.Hide();
                    //   Form1 sf = new Form1();
                    //  sf.Show();
                    //   var form2 = Form1.StaffFrom2;
                    // this.Closed += (s, args) => this.Close();
                    //  form2.Show();

                    SchoolManagementSystem.mainMenu nm = new SchoolManagementSystem.mainMenu();
                    nm.Show();
                    //   var form3 = SchoolManagementSystem.mainMenu.maintt;
                    //   form3.Show();
                }
                else
                {
                    ErrorDialogBox.ShowDialog("UserName and Password Does not Match, Pleace Re Enter!!!", "Invaild UserName Or Password");
                    con.Close();
                    return;
                }
            }
            else if (atype == "Staff")
            {
                con.Open();
                SqlCommand     cmd     = new SqlCommand("select * from Staff_Mang_Table where NIC = '" + usernametxt.Text + "' AND password = '******'", con);
                SqlDataAdapter checkDa = new SqlDataAdapter(cmd);

                SqlDataReader reader = cmd.ExecuteReader();
                DataSet       ds     = new DataSet();

                int i = 0;
                while (reader.Read())
                {
                    i++;
                }


                if (i > 0)
                {
                    this.Hide();
                    staff_profile f = new staff_profile();
                    f.Show();
                    var form1 = staffprofile.StaffManagmentInstance_4;
                    //  this.Closed += (s, args) => this.Close();
                    form1.Show();
                }
                else
                {
                    ErrorDialogBox.ShowDialog("UserName and Password Does not Match, Pleace Re Enter!!!", "Invaild UserName Or Password");
                    con.Close();
                    return;
                }
            }
            else if (atypelogin.Text == "Student")
            {
            }
            else if (atypelogin.Text == "")
            {
                ErrorDialogBox.ShowDialog("Please Select UserType!!!", "Invaild User");

                con.Close();
                return;
            }


            setpassword = loginpasswordtxt.Text;
            setNIC      = usernametxt.Text;
        }
Ejemplo n.º 6
0
        public void updateData()
        {
            // ======= Validation ===========

            if (fnametxt.Text == "")
            {
                fnametxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("First name is Requied.", "Validation Error");
                fnametxt.Focus();
                return;
            }
            if (lnametxt.Text == "")
            {
                lnametxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Last name is Requied.", "Validation Error");
                lnametxt.Focus();
                return;
            }
            if (tpnotxt.Text == "")
            {
                tpnotxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Telephone No is Requied.", "Validation Error");
                tpnotxt.Focus();
                return;
            }

            else
            {
                Regex regtp = new Regex(@"^\d{10}$");
                if (!regtp.IsMatch(tpnotxt.Text))
                {
                    tpnotxt.BackColor = Color.Red;
                    ErrorDialogBox.ShowDialog("Telephone must containt 10 numbers and NO Alpebetic Letters", "Validation Error");
                    tpnotxt.Focus();
                    return;
                }
            }
            if (emailtxt.Text == "")
            {
                emailtxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Email is Requied.", "Validation Error");
                emailtxt.Focus();
                return;
            }
            else
            {
                Regex regEmail = new Regex(@"^(([^<>()[\]\\.,;:\s@\""]+"
                                           + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"
                                           + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
                                           + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
                                           + @"[a-zA-Z]{2,}))$",
                                           RegexOptions.Compiled);
                if (!regEmail.IsMatch(emailtxt.Text))
                {
                    emailtxt.BackColor = Color.Red;
                    ErrorDialogBox.ShowDialog("Please Insert Valid Email Requied.", "Validation Error");
                    emailtxt.Focus();
                    return;
                }
            }
            if (address1txt.Text == "")
            {
                address1txt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Addres line 01 is Requied.", "Validation Error");
                address1txt.Focus();
                return;
            }
            if (address2txt.Text == "")
            {
                address2txt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Addres line 02 is Requied.", "Validation Error");
                address2txt.Focus();
                return;
            }
            if (address3txt.Text == "")
            {
                address3txt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Addres line 03 is Requied.", "Validation Error");
                address3txt.Focus();
                return;
            }
            if (nictxt.Text == "")
            {
                nictxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("NIC is Requied.", "Validation Error");
                nictxt.Focus();
                return;
            }
            else
            {
                Regex regNIC = new Regex(@"^[0-9]{9}[vV]$");
                if (!regNIC.IsMatch(nictxt.Text))
                {
                    nictxt.BackColor = Color.Red;
                    ErrorDialogBox.ShowDialog("NIC must containt 9 numbers and 'V' or 'v' at the last.", "Validation Error");
                    nictxt.Focus();
                    return;
                }
            }
            if (passwordtxt.Text == "")
            {
                passwordtxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Password is Requied.", "Validation Error");
                passwordtxt.Focus();
                return;
            }

            String temNic = nictxt.Text;

            Boolean ans = checkNIC(temNic);

            if (ans != true)
            {
                ErrorDialogBox.ShowDialog("Invalid NIC. Please enter Registerd NIC", "Validation Error");
            }
            else
            {
                MemoryStream ms = new MemoryStream();
                profile_picxtxt.Image.Save(ms, profile_picxtxt.Image.RawFormat);
                byte[] image = ms.ToArray();

                con.Open();
                cmd = new SqlCommand("update Staff_Mang_Table set title = '" + titletxt.Text + "', fname = '" + fnametxt.Text + "', lname = '" + lnametxt.Text + "', gender = '" + gendertxt.Text + "',tpno = '" + tpnotxt.Text + "', email = '" + emailtxt.Text + "', address1 = '" + address1txt.Text + "', address2 = '" + address2txt.Text + "', address3 = '" + address3txt.Text + "', qualification = '" + qualificationtxt.Text + "', accountType = '" + atypetxt.Text + "', password = '******', startdate = '" + sdatetxt.Text + "', photo = @photo where NIC = '" + nictxt.Text + "'", con);

                cmd.Parameters.Add("@photo", SqlDbType.VarBinary).Value = image;

                cmd.ExecuteNonQuery();

                SuccessfullMessageBox.ShowDialog("Update Successfully !!!", "Confirmation Message");
                // MessageBox.Show("Update Successfully !!!");
                con.Close();
                display();
                clearallData();
            }
        }
Ejemplo n.º 7
0
        //Insert Data to the DataBase

        private void Insert_Click(object sender, EventArgs e)
        {
            // ======= Validation ===========

            if (fnametxt.Text == "")
            {
                fnametxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("First name is Requied.", "Validation Error");
                fnametxt.Focus();
                return;
            }
            if (lnametxt.Text == "")
            {
                lnametxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Last name is Requied.", "Validation Error");
                lnametxt.Focus();
                return;
            }
            if (tpnotxt.Text == "")
            {
                tpnotxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Telephone No is Requied.", "Validation Error");
                tpnotxt.Focus();
                return;
            }

            else
            {
                Regex regtp = new Regex(@"^\d{10}$");
                if (!regtp.IsMatch(tpnotxt.Text))
                {
                    tpnotxt.BackColor = Color.Red;
                    ErrorDialogBox.ShowDialog("Telephone must containt 10 numbers and NO Alpebetic Letters", "Validation Error");
                    tpnotxt.Focus();
                    return;
                }
            }
            if (emailtxt.Text == "")
            {
                emailtxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Email is Requied.", "Validation Error");
                emailtxt.Focus();
                return;
            }
            else
            {
                Regex regEmail = new Regex(@"^(([^<>()[\]\\.,;:\s@\""]+"
                                           + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"
                                           + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
                                           + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
                                           + @"[a-zA-Z]{2,}))$",
                                           RegexOptions.Compiled);
                if (!regEmail.IsMatch(emailtxt.Text))
                {
                    emailtxt.BackColor = Color.Red;
                    ErrorDialogBox.ShowDialog("Please Insert Valid Email Requied.", "Validation Error");
                    emailtxt.Focus();
                    return;
                }
            }
            if (address1txt.Text == "")
            {
                address1txt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Addres line 01 is Requied.", "Validation Error");
                address1txt.Focus();
                return;
            }
            if (address2txt.Text == "")
            {
                address2txt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Addres line 02 is Requied.", "Validation Error");
                address2txt.Focus();
                return;
            }
            if (address3txt.Text == "")
            {
                address3txt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Addres line 03 is Requied.", "Validation Error");
                address3txt.Focus();
                return;
            }
            if (nictxt.Text == "")
            {
                nictxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("NIC is Requied.", "Validation Error");
                nictxt.Focus();
                return;
            }
            else
            {
                Regex regNIC = new Regex(@"^[0-9]{9}[vV]$");
                if (!regNIC.IsMatch(nictxt.Text))
                {
                    nictxt.BackColor = Color.Red;
                    ErrorDialogBox.ShowDialog("NIC must containt 9 numbers and 'V' or 'v' at the last.", "Validation Error");
                    nictxt.Focus();
                    return;
                }
            }
            if (passwordtxt.Text == "")
            {
                passwordtxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Password is Requied.", "Validation Error");
                passwordtxt.Focus();
                return;
            }



            //Image

            MemoryStream ms = new MemoryStream();

            profile_picxtxt.Image.Save(ms, profile_picxtxt.Image.RawFormat);
            image = ms.ToArray();

            String temNic = nictxt.Text;

            Boolean ans = checkNIC(temNic);

            if (ans == true)
            {
                ErrorDialogBox.ShowDialog("This Employee Already Registered!!!Pleace Register another Employee.", "Validation Error");
            }
            else
            {
                con.Open();
                cmd = new SqlCommand("INSERT INTO Staff_Mang_Table VALUES('" + nictxt.Text + "','" + titletxt.Text + "','" + fnametxt.Text + "','" + lnametxt.Text + "','" + gendertxt.Text + "','" + tpnotxt.Text + "','" + emailtxt.Text + "','" + address1txt.Text + "','" + address2txt.Text + "','" + address3txt.Text + "','" + qualificationtxt.Text + "','" + atypetxt.Text + "','" + passwordtxt.Text + "','" + sdatetxt.Text + "', @photo)", con);

                cmd.Parameters.Add("@photo", SqlDbType.VarBinary).Value = image;
                cmd.ExecuteNonQuery();
                SuccessfullMessageBox.ShowDialog("Registration Successfully.", "Confirmation Message");
                con.Close();
                display();
            }
        }
Ejemplo n.º 8
0
        private void requestlvbtn_Click(object sender, EventArgs e)
        {
            if (reasontxt.Text == "")
            {
                reasontxt.BackColor = Color.Red;
                ErrorDialogBox.ShowDialog("Reason is Requied.", "Validation Error");
                reasontxt.Focus();
                return;
            }


            if (typetxt.Text == "Casual_Leave")
            {
                if (casual > 0)
                {
                    con.Open();
                    cmd = new SqlCommand("Insert into staff_Temp_Request_Leaves (NIC, type, reason, date) values(@getNIC2,'" + typetxt.Text + "', '" + reasontxt.Text + "','" + selectDateTxt.Text + "')", con);
                    cmd.Parameters.Add("@getNIC2", SqlDbType.VarChar).Value = getNIC2;
                    cmd.ExecuteNonQuery();

                    con.Close();
                    displayleave();

                    SuccessfullMessageBox.ShowDialog("Casual Leave Request is Applly Successfully !!!", "Confirmation Message");
                }
                else
                {
                    ErrorDialogBox.ShowDialog("Sorry!!! All alocated Casual Leaves Are Used this Month.", "No Leaves");
                    // MessageBox.Show("Sorry!!! All alocated Casual Leaves Are Used.");
                }
            }



            else if (typetxt.Text == "HalfDay_Leave")
            {
                if (casual > 0)
                {
                    con.Open();
                    cmd = new SqlCommand("Insert into staff_Temp_Request_Leaves (NIC, type, reason, date) values(@getNIC2,'" + typetxt.Text + "', '" + reasontxt.Text + "','" + selectDateTxt.Text + "')", con);
                    cmd.Parameters.Add("@getNIC2", SqlDbType.VarChar).Value = getNIC2;
                    cmd.ExecuteNonQuery();
                    // MessageBox.Show("Leaves Pending!!!");
                    con.Close();
                    displayleave();
                    // MessageBox.Show("Half Day Leave Request is Applly Successfully !!!");
                    SuccessfullMessageBox.ShowDialog("Half Day Leave Request is Applly Successfully !!!", "Confirmation Message");
                }
                else
                {
                    ErrorDialogBox.ShowDialog("Sorry!!! All alocated Half Day Leaves Are Used this Month.", "No Leaves");
                    //MessageBox.Show("Sorry!!! All alocated Half Day Leaves Are Used this Month.");
                }
            }
            else if (typetxt.Text == "Medical_Leave")
            {
                if (medical > 0)
                {
                    con.Open();
                    cmd = new SqlCommand("Insert into staff_Temp_Request_Leaves (NIC, type, reason, date) values(@getNIC2,'" + typetxt.Text + "', '" + reasontxt.Text + "','" + selectDateTxt.Text + "')", con);
                    cmd.Parameters.Add("@getNIC2", SqlDbType.VarChar).Value = getNIC2;
                    cmd.ExecuteNonQuery();

                    con.Close();
                    displayleave();
                    SuccessfullMessageBox.ShowDialog("Medical_Leave Leave Request is Applly Successfully !!!", "Confirmation Message");
                    // MessageBox.Show("Medical Leave Request is Applly Successfully !!!");
                    //  Payment.SuccessDialogBox.ShowDialog("Medical_Leave Request is Applly Successfully !!!", "Successfull Message");
                }
                else
                {
                    ErrorDialogBox.ShowDialog("Sorry!!! All alocated Medical Leaves Are Used this Month.", "No Leaves");
                    // MessageBox.Show("Sorry!!! All alocated Medical Leaves Are Used this Month.");
                }
            }
            else if (typetxt.Text == "Short_Leave")
            {
                if (shortleave > 0)
                {
                    con.Open();
                    cmd = new SqlCommand("Insert into staff_Temp_Request_Leaves (NIC, type, reason, date) values(@getNIC2,'" + typetxt.Text + "', '" + reasontxt.Text + "','" + selectDateTxt.Text + "')", con);
                    cmd.Parameters.Add("@getNIC2", SqlDbType.VarChar).Value = getNIC2;
                    cmd.ExecuteNonQuery();
                    // MessageBox.Show("Leaves Pending!!!");
                    con.Close();
                    displayleave();
                    //Payment.SuccessDialogBox.ShowDialog("shortleaves Request is Applly Successfully !!!", "Successfull Message");
                    // MessageBox.Show("shortleaves Request is Applly Successfully !!!");
                    SuccessfullMessageBox.ShowDialog("shortleaves Leave Request is Applly Successfully !!!", "Confirmation Message");
                }
                else
                {
                    ErrorDialogBox.ShowDialog("Sorry!!! All alocated shortleaves Leaves Are Used this Month.", "No Leaves");
                    // MessageBox.Show("Sorry!!! All alocated Half Day Leaves Are Used this Month.");
                }
            }
            else
            {
                ErrorDialogBox.ShowDialog("Sorry!!! No ", " Invaild Type");
                MessageBox.Show("Invaild type !!!");
            }

            reasontxt.Text        = "";
            typetxt.SelectedIndex = -1;
        }
Ejemplo n.º 9
0
        private void confirmbtn_Click(object sender, EventArgs e)
        {
            if (staffnicLabel.Text == null || typeLable.Text == null)
            {
                ErrorDialogBox.ShowDialog("Please double click one rquest from table First", "Invaild Data");
            }
            else
            {
                String approveby = Login.setNIC;
                con.Open();
                cmd = new SqlCommand("insert into staff_Approve_Leaves values('" + staffnicLabel.Text + "', '" + typeLable.Text + "', '" + reasonLable.Text + "', '" + dateLable.Text + "', @approveby)", con);

                cmd.Parameters.Add("@approveby", SqlDbType.VarChar).Value = approveby;

                cmd.ExecuteNonQuery();
                SuccessfullMessageBox.ShowDialog("Leave Approved", "Confirmation Message");

                con.Close();


                con.Open();
                cmd = new SqlCommand("Delete from staff_Temp_Request_Leaves where sid = @sid", con);
                cmd.Parameters.Add("@sid", SqlDbType.Int).Value = sid;
                cmd.ExecuteNonQuery();
                con.Close();


                displayleaveReuest();

                getLeaves();



                if (typeLable.Text == "Casual_Leave")
                {
                    casual = casual - 1;
                    con.Open();
                    cmd = new SqlCommand("update staff_Leaves set Casual_Leave = @Casual_Leave where NIC = '" + staffnicLabel.Text + "' ", con);
                    cmd.Parameters.Add("@Casual_Leave", SqlDbType.Int).Value = (int)casual;

                    cmd.ExecuteNonQuery();
                    con.Close();
                }
                else if (typeLable.Text == "Medical_Leave")
                {
                    medical = medical - 1;
                    con.Open();
                    cmd = new SqlCommand("update staff_Leaves set Medical_Leave = @Medical_Leave where NIC = '" + staffnicLabel.Text + "' ", con);
                    cmd.Parameters.Add("@Medical_Leave", SqlDbType.Int).Value = (int)medical;

                    cmd.ExecuteNonQuery();
                    con.Close();
                }
                else if (typeLable.Text == "Short_Leave")
                {
                    shortleave = shortleave - 1;
                    con.Open();
                    cmd = new SqlCommand("update staff_Leaves set Short_Leave = @Short_Leave where NIC = '" + staffnicLabel.Text + "' ", con);
                    cmd.Parameters.Add("@Short_Leave", SqlDbType.Int).Value = (int)shortleave;

                    cmd.ExecuteNonQuery();
                    con.Close();
                }
                else if (typeLable.Text == "HalfDay_Leave")
                {
                    halfday = halfday + 1;
                    con.Open();
                    cmd = new SqlCommand("update staff_Leaves set HalfDay_Leave = @HalfDay_Leave where NIC = '" + staffnicLabel.Text + "' ", con);
                    cmd.Parameters.Add("@HalfDay_Leave", SqlDbType.Int).Value = (int)halfday;

                    cmd.ExecuteNonQuery();
                    con.Close();
                    ///////////////////
                    if (halfday % 2 == 0)
                    {
                        casual = casual - 1;
                        con.Open();
                        cmd = new SqlCommand("update staff_Leaves set Casual_Leave = @Casual_Leave where NIC = '" + staffnicLabel.Text + "' ", con);
                        cmd.Parameters.Add("@Casual_Leave", SqlDbType.Int).Value = (int)casual;

                        cmd.ExecuteNonQuery();
                        con.Close();
                    }
                }
            }

            cleareText();
        }