예제 #1
0
        private void ClearMethod()
        {
            IDTB.Clear();
            FirstNameTB.Clear();
            LastNametextBox.Clear();
            DateOfBirthTB.Value    = DateTime.Now;
            GenderTB.SelectedIndex = -1;
            ContacttextBox.Clear();
            NICtextBox.Clear();
            HouseNOtextBox.Clear();
            AddLine1Tb.Clear();
            AddLine2tb.Clear();
            postCodetextBox.Clear();
            DepartmentTextBoc.SelectedIndex  = -1;
            designationtextBox.SelectedIndex = -1;

            StatuscomboBox.SelectedIndex = -1;
            DateOfHired.Value            = DateTime.Now;
            BasicSalarytextBox.Clear();
            JobTitletextBox.Clear();
            PasswordTb.Clear();

            UpdateBtn.Enabled = false;
            button1.Enabled   = false;
            ReadID();

            ProfilePicture.Image = Resources.User1;
        }
        private Boolean Validation()
        {

            

            if (FirstNameTB.Text == "")
            {
                FirstNameTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("First Name Is Required", "Please Enter First Name", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                FirstNameTB.Focus();
                return true;
            }
            if (LastNametextBox.Text == "")
            {
                LastNametextBox.BackColor = Color.DodgerBlue;
                MessageBox.Show("Last Name Is Required", "Please Enter Last Name", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                LastNametextBox.Focus();
                return true;
            }
            if (DateOfBirthTB.Value == Dt)
            {
                DateOfBirthTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Date Of Birth Is Required", "Please Enter Date Of Birth", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DateOfBirthTB.Focus();
                return true;
            }

            if (GenderTB.SelectedIndex == -1)
            {
                GenderTB.BackColor = Color.DodgerBlue;
                MessageBox.Show("Gender Is Required", "Please Select Gender", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                GenderTB.Focus();
                return true;
            }

            if (ContacttextBox.Text == "")
            {
                ContacttextBox.BackColor = Color.DodgerBlue;
                MessageBox.Show("Contact Number Is Required", "Please Enter Contact", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ContacttextBox.Focus();
                return true;
            }
            if (NICtextBox.Text == "")
            {
                NICtextBox.BackColor = Color.DodgerBlue;
                MessageBox.Show("NIC Is Required", "Please Enter NIC", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NICtextBox.Focus();
                return true;
            }

            if (DepartmentTextBoc.SelectedIndex == -1)
            {
                DepartmentTextBoc.BackColor = Color.DodgerBlue;
                MessageBox.Show("Department Is Required", "Please Select Department", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                DepartmentTextBoc.Focus();
                return true;
            }
            if (designationtextBox.SelectedIndex == -1)
            {
                designationtextBox.BackColor = Color.DodgerBlue;
                MessageBox.Show("Designation Is Required", "Please Select Designation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                designationtextBox.Focus();
                return true;
            }
            if (StatuscomboBox.SelectedIndex == -1)
            {
                StatuscomboBox.BackColor = Color.DodgerBlue;
                MessageBox.Show("Status Is Required", "Please Select Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                StatuscomboBox.Focus();
                return true;
            }


            if (DateOfHired.Value == Dt)
            {
                DialogResult Result = MessageBox.Show("Do You Want To Enter To Day's Date ? ", "Yes Or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (Result == DialogResult.No)
                {
                    DateOfHired.Focus();
                    return true;
                }

            }


            if (BasicSalarytextBox.Text == "")
            {
                BasicSalarytextBox.BackColor = Color.DodgerBlue;
                MessageBox.Show("Basic Salary Is Required", "Please Enter Basic Salary", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                BasicSalarytextBox.Focus();
                return true;
            }

            if (JobTitletextBox.Text == "")
            {
                JobTitletextBox.BackColor = Color.DodgerBlue;
                MessageBox.Show("Job Title Is Required", "Please Enter Title", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                JobTitletextBox.Focus();
                return true;
            }

            if (HouseNOtextBox.Text == "")
            {
                HouseNOtextBox.BackColor = Color.DodgerBlue;
                MessageBox.Show("House Number Is Required", "Please Enter House Number", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                HouseNOtextBox.Focus();
                return true;
            }

            if (AddLine1Tb.Text == "")
            {
                AddLine1Tb.BackColor = Color.DodgerBlue;
                MessageBox.Show("Address Is Required", "Please Enter Address", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                AddLine1Tb.Focus();
                return true;
            }

            if (PasswordTb.Text == "")
            {
                PasswordTb.BackColor = Color.DodgerBlue;
                MessageBox.Show("Password Number Is Required", "Please Enter Password", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                PasswordTb.Focus();
                return true;
            }


            return false;
        }
예제 #3
0
        private void SavePersonal_Click(object sender, EventArgs e)
        {
            string query = ""; int DistrictKey = ((KeyValuePair <int, string>)District.SelectedItem).Key;
            string que = ""; int ThanaKey = ((KeyValuePair <int, string>)Thana.SelectedItem).Key;
            string qu = ""; int MarriedKey = ((KeyValuePair <int, string>)MarriedCombox.SelectedItem).Key;
            String DistrictValue = ((KeyValuePair <int, string>)District.SelectedItem).Value;
            String ThanaValue    = ((KeyValuePair <int, string>)Thana.SelectedItem).Value;
            String MarriedValue  = ((KeyValuePair <int, string>)MarriedCombox.SelectedItem).Value;

            if (StaffIDtextBox.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Staff ID");
                StaffIDtextBox.Focus();
                return;
            }

            if (ContacttextBox.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Contact Number");
                ContacttextBox.Focus();
                return;
            }
            if (DOB.Text == "")
            {
                MessageBox.Show("Please Enter Date of Birth");
                DOB.Focus();
                return;
            }
            if (DistrictKey < 1)
            {
                MessageBox.Show("Please Enter District");
                District.Focus();
                return;
            }
            if (ThanaKey < 1)
            {
                MessageBox.Show("Please Enter Thana");
                District.Focus();
                return;
            }

            if (PostCodetextBox.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Post Code");
                PostCodetextBox.Focus();
                return;
            }
            if (VillagetextBox.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Village Name");
                VillagetextBox.Focus();
                return;
            }
            if (PresentAddresstextBox.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Present Address");
                PresentAddresstextBox.Focus();
                return;
            }
            if (PermanentadresstextBox.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Permanent Address");
                PermanentadresstextBox.Focus();
                return;
            }
            if (MarriedKey < 1)
            {
                MessageBox.Show("Please Enter Marital Status");
                District.Focus();
                return;
            }

            if (FathersNametextBox.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Father's name");
                FathersNametextBox.Focus();
                return;
            }
            if (MothersNametextBox.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Mother's Name");
                MothersNametextBox.Focus();
                return;
            }
            if (ParentsAddresstextBox.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Present Address");
                ParentsAddresstextBox.Focus();
                return;
            }

            query = "SELECT COUNT(*) AS Count FROM Personal_Info WHERE StaffID = " + StaffIDtextBox.Text + "";
            if (stfID == 0)
            {
                if (DbAccess.NumberOfRecords(query) > 0)
                {
                    MessageBox.Show("This Username already exists! Please try another ID!");
                    StaffIDtextBox.Focus();
                    return;
                }
            }
            else
            {
                if (DbAccess.NumberOfRecords(query) > 1)
                {
                    MessageBox.Show("Update Not Successfully Done!");
                    StaffIDtextBox.Focus();
                    return;
                }
            }

            try
            {
                if (stfID == 0)
                {
                    query = "INSERT INTO Personal_Info(StaffID,Contact,[Date of Birth],District,Thana,[Post Code],Village,[Present Address],[Permanent Address],[Marital Status],[Father's  Name],[Mother's Name],[Parent's Address]) VALUES(" + Convert.ToInt32(StaffIDtextBox.Text) + ",  '" + ContacttextBox.Text + "', '" + DOB.Value.ToString("yyyy/MM/dd") + "', '" + DistrictValue + "', '" + ThanaValue + "', '" + PostCodetextBox.Text + "', '" + VillagetextBox.Text + "', '" + PresentAddresstextBox.Text + "', '" + PermanentadresstextBox.Text + "', '" + MarriedValue + "', '" + FathersNametextBox.Text + "', '" + MothersNametextBox.Text + "', '" + ParentsAddresstextBox.Text + "')";
                }


                else
                {
                    query = "UPDATE Personal_Info SET  Contact = '" + ContacttextBox.Text + "', [Date of Birth] = '" + DOB.Text + "',  District= '" + District.Text + "', Thana = '" + Thana.Text + "', [Post Code] = '" + PostCodetextBox.Text + "', Village = '" + VillagetextBox.Text + "',[Present Address] = '" + PresentAddresstextBox.Text + "', [Permanent Address] = '" + PermanentadresstextBox.Text + "', [Marital Status] = '" + MarriedValue + "',[Father's  Name] = '" + FathersNametextBox.Text + "', [Mother's Name]= '" + MothersNametextBox.Text + "',[Parent's Address] = '" + ParentsAddresstextBox.Text + "' WHERE StaffID = " + stfID;
                }

                if (DbAccess.ExecuteToDB(query))
                {
                    if (stfID == 0)
                    {
                        MessageBox.Show("Saved Successfully!!!");
                    }
                    else
                    {
                        MessageBox.Show("Update Successfully!!!");
                    }
                }
                else
                {
                    MessageBox.Show("Failed To Save!!!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Connection Error!!!");
            }
            finally
            {
                Reset();
            }
        }