예제 #1
0
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (sectionTxt.Text == "")
            {
                sectionErrorLabel.Visible = true;
            }
            else
            {
                sectionErrorLabel.Visible = false;
            }
            if (statusDD.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }
            if (sectionErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.ShowMSG("Fields with * are mandatory.", "Error...", "Error");
            }
            else
            {
                if (edit == 0) // code for SAVe
                {
                    section s = new section();

                    if (statusDD.SelectedIndex == 0)
                    {
                        s.sec_status = 1;
                    }
                    else
                    {
                        s.sec_status = 0;
                    }

                    obj.st_insertSections(sectionTxt.Text, s.sec_status);
                    obj.SubmitChanges();
                    MainClass.ShowMSG(sectionTxt.Text + " added successfully.", "Success...", "Success");
                    MainClass.disable_reset(panel6);
                    loadData();
                }
                else // code for update
                {
                    byte stat;
                    if (statusDD.SelectedIndex == 0)
                    {
                        stat = 1;
                    }
                    else
                    {
                        stat = 0;
                    }
                    obj.st_updateSections(sectionTxt.Text, stat, sectionID);

                    MainClass.ShowMSG(sectionTxt.Text + " updated successfully.", "Success...", "Success");
                    MainClass.disable_reset(panel6);
                    loadData();
                }
            }
        }
예제 #2
0
 public override void addBtn_Click(object sender, EventArgs e)
 {
     edit = 0;
     MainClass.enable_reset(panel6);
 }
예제 #3
0
 public override void editBtn_Click(object sender, EventArgs e)
 {
     edit = 1;
     MainClass.enable(panel6);
 }
예제 #4
0
        private void btnAddMembers_Click(object sender, EventArgs e)
        {
            if (btnStatus == "add")
            {
                if (MemberIDNull.Visible || FNameNull.Visible || LNameNull.Visible || AddressNull.Visible || ContactNull.Visible)
                {
                    MainClass.showMsgLibrary("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "INSERT INTO libraryMember (member_ID, FirstName, LastName, address, contactNo, addDate) VALUES ('" + txtMemberID.Text + "','" + txtFName.Text + "','" + txtLName.Text + "','" + txtAddress.Text + "','" + txtContact.Text + "','" + AddDate.Text + "')";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsg(txtFName.Text + " 's Details Added Successfully", "Success", "success");
                        }
                    }
                    catch
                    {
                        int member_ID = 0;
                        int contactNo = 0;

                        try
                        {
                            member_ID = int.Parse(txtMemberID.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Member ID should be a numerical Value!", "Warning", "Error");
                        }
                        try
                        {
                            contactNo = int.Parse(txtContact.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Contact no should be an integer!", "Warning", "Error");
                        }
                    }
                }
                con.Close();
                lblMain.Text = "View";
            }

            else if (btnStatus == "update")
            {
                if (MemberIDNull.Visible || FNameNull.Visible || LNameNull.Visible || AddressNull.Visible || ContactNull.Visible)
                {
                    MainClass.showMsgLibrary("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "UPDATE libraryMember SET member_ID ='" + txtMemberID.Text + "' ,FirstName='" + txtFName.Text + "',LastName='" + txtLName.Text + "',address='" + txtAddress.Text + "',contactNo='" + txtContact.Text + "',addDate='" + AddDate.Text + "' where member_ID ='" + txtMemberID.Text + "' ";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsg(txtFName.Text + " 's Details Updated Successfully", "Success", "success");
                        }
                    }
                    catch
                    {
                        int contactNo = 0;

                        try
                        {
                            contactNo = int.Parse(txtContact.Text);
                        }
                        catch
                        {
                            MainClass.showMsgLibrary("Contact no should be a numerical!", "Warning", "Error");
                        }
                    }
                }
            }
            con.Close();
            showMemberDetails();
            MainClass.disable_reset(panel6);
            lblMain.Text = "View";
        }
예제 #5
0
 private void addMembers_Load(object sender, EventArgs e)
 {
     MainClass.disable_reset(panel6);
     showMemberDetails();
 }
예제 #6
0
 public override void editBtn_Click(object sender, EventArgs e)
 {
     edit = 1;
     MainClass.enable(panel6);
     imagePathTxt.Enabled = false;
 }
예제 #7
0
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text == "")
            {
                nameErrorLabel.Visible = true;
            }
            else
            {
                nameErrorLabel.Visible = false;
            }
            if (usernameTxt.Text == "")
            {
                usernameErrorLabel.Visible = true;
            }
            else
            {
                usernameErrorLabel.Visible = false;
            }
            if (passwordTxt.Text == "")
            {
                passwordErrorLabel.Visible = true;
            }
            else
            {
                passwordErrorLabel.Visible = false;
            }
            if (confirmPassTxt.Text == "")
            {
                confirmPassErrorLabel.Visible = true;
            }
            else
            {
                confirmPassErrorLabel.Visible = false;
            }
            if (passwordTxt.Text != confirmPassTxt.Text)
            {
                mismatchedErrorLabel.Visible = true;
            }
            else
            {
                mismatchedErrorLabel.Visible = false;
            }
            if (phone1Txt.Text == "")
            {
                phone1ErrorLabel.Visible = true;
            }
            else
            {
                phone1ErrorLabel.Visible = false;
            }
            if (roleDD.SelectedIndex == -1)
            {
                roleErrorLabel.Visible = true;
            }
            else
            {
                roleErrorLabel.Visible = false;
            }
            if (statusDD.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }

            if (nameErrorLabel.Visible || usernameErrorLabel.Visible || passwordErrorLabel.Visible || confirmPassErrorLabel.Visible || mismatchedErrorLabel.Visible || phone1ErrorLabel.Visible || roleErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.ShowMSG("Fields with * are mandatory.", "Stop...", "Error");
            }
            else
            {
                if (edit == 0) // code for SAVE operation
                {
                    if (imagePathTxt.Text == "")
                    {
                        byte stat = statusDD.SelectedIndex == 0? Convert.ToByte(1) : Convert.ToByte(0);
                        obj.st_insertStaffWithoutImage(nameTxt.Text, usernameTxt.Text, passwordTxt.Text, phone1Txt.Text, phone2Txt.Text, Convert.ToInt32(roleDD.SelectedValue.ToString()), stat);
                        MainClass.ShowMSG(nameTxt.Text + " added successfully into the system.", "Success", "Success");
                        MainClass.disable_reset(panel6);
                        loadData();
                    }
                    else
                    {
                        byte         stat = statusDD.SelectedIndex == 0 ? Convert.ToByte(1) : Convert.ToByte(0);
                        MemoryStream ms   = new MemoryStream();
                        i.Save(ms, ImageFormat.Jpeg);
                        byte[] arr = ms.ToArray();
                        obj.st_insertStaff(nameTxt.Text, usernameTxt.Text, passwordTxt.Text, phone1Txt.Text, phone2Txt.Text, Convert.ToInt32(roleDD.SelectedValue.ToString()), stat, arr);
                        MainClass.ShowMSG(nameTxt.Text + " added successfully into the system.", "Success", "Success");
                        MainClass.disable_reset(panel6);
                        loadData();
                    }
                }
                else if (edit == 1) // code for UPDATE operation
                {
                    byte stat = statusDD.SelectedIndex == 0 ? Convert.ToByte(1) : Convert.ToByte(0);
                    if (i == null)
                    {
                        obj.st_updateStaffWithoutImage(nameTxt.Text, usernameTxt.Text, passwordTxt.Text, phone1Txt.Text, phone2Txt.Text, Convert.ToInt32(roleDD.SelectedValue.ToString()), stat, staffID);
                        MainClass.ShowMSG(nameTxt.Text + " data updated successfully into the system.", "Success", "Success");
                        MainClass.disable_reset(panel6);
                        loadData();
                    }
                    else
                    {
                        MemoryStream ms = new MemoryStream();
                        i.Save(ms, ImageFormat.Jpeg);
                        byte[] arr = ms.ToArray();
                        obj.st_updateStaff(nameTxt.Text, usernameTxt.Text, passwordTxt.Text, phone1Txt.Text, phone2Txt.Text, Convert.ToInt32(roleDD.SelectedValue.ToString()), stat, arr, staffID);
                        MainClass.ShowMSG(nameTxt.Text + " data updated successfully into the system.", "Success", "Success");
                        MainClass.disable_reset(panel6);
                        loadData();
                    }
                }
            }
        }
예제 #8
0
 private void addBooks_Load(object sender, EventArgs e)
 {
     MainClass.disable_reset(panel6);
     showBookDetails();
 }
예제 #9
0
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (shiftNameTxt.Text == "")
            {
                shiftErrorLabel.Visible = true;
            }
            else
            {
                shiftErrorLabel.Visible = false;
            }

            if (shiftDD.SelectedIndex == -1)
            {
                shiftDDerrorLabel.Visible = true;
            }
            else
            {
                shiftDDerrorLabel.Visible = false;
            }

            if (shiftDDerrorLabel.Visible || shiftDDerrorLabel.Visible)
            {
                MainClass.ShowMSG("Fields with * are mandatory.", "Error...", "Error");
            }
            else
            {
                TimeSpan startTime = new TimeSpan(startPicker.Value.Hour, startPicker.Value.Minute, startPicker.Value.Second);
                TimeSpan endTime   = new TimeSpan(endPicker.Value.Hour, endPicker.Value.Minute, endPicker.Value.Second);
                //startTime.ToString();
                //endTime.ToString();
                //TimeSpan st = Convert.ToInt16(startPicker.Value.Hour.ToString());
                //TimeSpan et = endPicker.Value.TimeOfDay;

                //TimeSpan st = this.startPicker.Value.TimeOfDay;
                //TimeSpan et = this.endPicker.Value.TimeOfDay;

                //int st = Convert.ToInt16(startPicker.Value.ToString());
                //int et = Convert.ToInt16(endPicker.Value.ToString());

                //DateTime start = DateTime.Parse(startPicker.Text).Date;
                //DateTime end = DateTime.Parse(endPicker.Text).Date;

                //DateTime dt = startPicker.Value;
                //TimeSpan st = new TimeSpan(dt.Hour, dt.Minute, dt.Second);
                //DateTime en = endPicker.Value;
                //TimeSpan et = new TimeSpan(en.Hour, en.Minute, en.Second);

                //TimeSpan st = dt.TimeOfDay;

                //int t = Convert.ToInt16(startPicker.Value.Hour.ToString());
                //int y = Convert.ToInt16(endPicker.Value.Hour.ToString());

                //TimeSpan ts1 = TimeSpan.Parse(startPicker.Text);
                //TimeSpan ts2 = TimeSpan.Parse(endPicker.Text);


                //TimeSpan ts = startPicker.Value.TimeOfDay;
                //TimeSpan es = endPicker.Value.TimeOfDay;



                if (edit == 0) // code for SAVE operation
                {
                    try
                    {
                        shift s = new shift();


                        obj.st_insertShifts(shiftNameTxt.Text, Convert.ToByte(shiftDD.SelectedItem.ToString()), startTime, endTime);
                        obj.SubmitChanges();
                        MainClass.ShowMSG(shiftNameTxt.Text + " added successfully.", "Success...", "Success");
                        MainClass.disable_reset(panel6);
                        loadData();
                    }
                    catch (Exception ex)
                    {
                        MainClass.ShowMSG(ex.Message, "Error", "Error");
                    }
                }
                else
                {
                    obj.st_updateShifts(shiftNameTxt.Text, Convert.ToByte(shiftDD.SelectedItem.ToString()), startTime, endTime, shiftID);
                    MainClass.ShowMSG(shiftNameTxt.Text + " updated successfully.", "Success...", "Success");
                    MainClass.disable_reset(panel6);
                    loadData();
                }
            }
        }
예제 #10
0
        private void btnAddBooks_Click(object sender, EventArgs e)
        {
            if (btnStatus == "add")
            {
                if (BookIDNull.Visible || BookNameNull.Visible || AuthorNull.Visible)
                {
                    MainClass.showMsg("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "INSERT INTO libraryBooks (book_ID, name, author, quantity, addDate) VALUES ('" + txtBookID.Text + "','" + txtBookName.Text + "','" + txtAuthor.Text + "', '1', '" + AddDate.Text + "')";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsgLibrary(txtBookName.Text + "Successfully Added!", "Success", "Success");
                        }
                    }
                    catch
                    {
                        int book_ID = 0;

                        try
                        {
                            book_ID = int.Parse(txtBookID.Text);
                        }
                        catch
                        {
                            MainClass.showMsg("Book ID should be an numerical value!", "Warning", "Error");
                        }
                    }
                }
                con.Close();
                lblMain.Text = "View";
            }
            else if (btnStatus == "update")
            {
                if (BookIDNull.Visible || BookNameNull.Visible || AuthorNull.Visible)
                {
                    MainClass.showMsg("Fields with * are mandetory!", "Warning", "Error");
                }
                else
                {
                    try
                    {
                        con.Open();
                        if (con.State == System.Data.ConnectionState.Open)
                        {
                            string q = "UPDATE libraryBooks SET book_ID ='" + txtBookID.Text + "' ,name='" + txtBookName.Text + "',author='" + txtAuthor.Text + "',quantity='1',addDate='" + AddDate.Text + "' where book_ID ='" + txtBookID.Text + "' ";
                            Console.Write(q);
                            SqlCommand cmd = new SqlCommand(q, con);
                            cmd.ExecuteNonQuery();
                            MainClass.showMsgLibrary("Successfull Updated!", "Success", "Success");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error");
                    }
                }
            }
            con.Close();
            showBookDetails();
            MainClass.disable_reset(panel6);
            lblMain.Text = "View";
        }
예제 #11
0
        public override void saveBtn_Click(object sender, EventArgs e)
        {
            if (roleTxt.Text == "")
            {
                roleErrorLabel.Visible = true;
            }
            else
            {
                roleErrorLabel.Visible = false;
            }
            if (statusDD.SelectedIndex == -1)
            {
                statusErrorLabel.Visible = true;
            }
            else
            {
                statusErrorLabel.Visible = false;
            }
            if (roleErrorLabel.Visible || statusErrorLabel.Visible)
            {
                MainClass.ShowMSG("Fields with * are mandatory.", "Error...", "Error");
            }
            else
            {
                if (edit == 0) // code for SAVE operation
                {
                    role r = new role();
                    r.r_name = roleTxt.Text;
                    if (statusDD.SelectedIndex == 0)
                    {
                        r.r_status = 1;
                    }
                    else
                    {
                        r.r_status = 0;
                    }

                    //obj.roles.InsertOnSubmit(r);
                    obj.st_insertRoles(roleTxt.Text, r.r_status);
                    obj.SubmitChanges();
                    MainClass.ShowMSG(roleTxt.Text + " added successfully.", "Success...", "Success");
                    MainClass.disable_reset(panel6);
                    loadData();
                }
                else if (edit == 1) // code for UPDATE
                {
                    byte stat;
                    if (statusDD.SelectedIndex == 0)
                    {
                        stat = 1;
                    }
                    else
                    {
                        stat = 0;
                    }
                    obj.st_updateRoles(roleTxt.Text, stat, roleID);
                    //var data = obj.roles.Single(x => x.r_id == roleID);

                    //data.r_name = roleTxt.Text;
                    //if (statusDD.SelectedIndex == 0)
                    //{
                    //    data.r_status = 1;
                    //}
                    //else
                    //{
                    //    data.r_status = 0;
                    //}
                    //obj.SubmitChanges();
                    MainClass.ShowMSG(roleTxt.Text + " updated successfully.", "Success...", "Success");
                    MainClass.disable_reset(panel6);
                    loadData();
                }
            }
        }
예제 #12
0
 private void Roles_Load(object sender, EventArgs e)
 {
     MainClass.disable_reset(panel6);
 }
 private void backBtn_Click(object sender, EventArgs e)
 {
     MainClass.showWindow(new Students(), this, MDI.ActiveForm);
 }
        public override void ViewBtn_Click(object sender, EventArgs e)
        {
            operationLabel.Text = "VIEW";

            MainClass.showWindow(new StudentReport(attendDate.Text, selectGrade.SelectedIndex, selectClass.SelectedIndex), this, MDI.ActiveForm);
        }