Пример #1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                //Generate Password Hash and Check Login Data
                var dc = new ClassSRMDataContext(Config.connection);
                byte1 = UTF8Encoding.UTF8.GetBytes(txtPass.Text);
                byte2 = sha.ComputeHash(byte1);
                Hash  = BitConverter.ToString(byte2);
                var checkLogin = (from v in dc.tbl_Users where v.Name == txtUserName.Text && v.Pass == Hash select v);

                if (checkLogin.Count() > 0)
                {
                    this.Hide();
                    new Form1().ShowDialog();
                }
                else
                {
                    XtraMessageBox.Show("مشخصات کاربری اشتباه است", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtUserName.Select();
                    txtPass.Text = string.Empty;
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridView1.RowCount != 0)
            {
                try
                {
                    var dc = new ClassSRMDataContext(Config.connection);

                    int id = (int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Id");
                    dc.UpdateSchool(id, txtSName.Text, txtAName.Text, cmbClass.Text, txtDate.Text);
                    tblSchoolBindingSource.EndEdit();
                    dc = new ClassSRMDataContext(Config.connection);
                    XtraMessageBox.Show("مدرسه موردنظر با موفقیت ویرایش شد", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Schoollist_Load(null, null);
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                XtraMessageBox.Show("اطلاعاتی برای ویرایش وجود ندارد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        private void btnSchoolList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            new Schoollist().ShowDialog();
            tblSchoolBindingSource.DataSource = dc.SelectSchool();
        }
Пример #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var dc = new ClassSRMDataContext(Config.connection);
                if (rd.SelectedIndex == 0)
                {
                    dc.InsertActPoint((int)cmbStudent.EditValue, (int)txtScore.Value, txtDate.Text, txtDesc.Text);
                    XtraMessageBox.Show("امتیاز موردنظر با موفقیت ثبت شد", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    cmbStudent_EditValueChanged(null, null);
                }
                else
                {
                    int val = getValeofItem(cmbScore.Text);
                    dc.InsertActPoint((int)cmbStudent.EditValue, val, txtDate.Text, txtDesc.Text);
                    XtraMessageBox.Show("امتیاز موردنظر با موفقیت ثبت شد", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    cmbStudent_EditValueChanged(null, null);
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
        private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            try
            {
                var dc = new ClassSRMDataContext(Config.connection);

                int  id    = (int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Id");
                int  idStu = (int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "StudentId");
                bool exist = (bool)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Exist");
                var  date  = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Date").ToString();
                if (exist)
                {
                    exist = false;
                }
                else
                {
                    exist = true;
                }
                dc.UpdateCheck(id, idStu, exist, date);
                checkVBindingSource.EndEdit();
                dc = new ClassSRMDataContext(Config.connection);
                XtraMessageBox.Show("حضورغیاب موردنظر با موفقیت ویرایش شد", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception)
            {
            }
        }
Пример #6
0
        private void Process_Load(object sender, EventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            tblSchoolBindingSource.DataSource = dc.SelectSchool();
            cmbClass.ItemIndex = 0;
        }
Пример #7
0
        private void ChartQuery()
        {
            try
            {
                var dc        = new ClassSRMDataContext(Config.connection);
                var queryWin1 = (from tbl_ActPoints in dc.tbl_ActPoints //دریافت دانش آموز برتر
                                 group tbl_ActPoints by new
                {
                    tbl_ActPoints.StudentId
                } into g
                                 orderby
                                     (int?) g.Sum(p => p.Score) descending
                                 select new
                {
                    g.Key.StudentId,
                    AverageScore = (int?)g.Sum(p => p.Score)
                }).Take(1).FirstOrDefault();

                var queryWin2 = (from tbl_EvaPoint in dc.tbl_EvaPoints //دریافت دانش آموز برتر
                                 group tbl_EvaPoint by new
                {
                    tbl_EvaPoint.StudentId
                } into g
                                 orderby
                                     (int?) g.Sum(p => p.Score) descending
                                 select new
                {
                    g.Key.StudentId,
                    AverageScore = (int?)g.Sum(p => p.Score)
                }).Take(1).FirstOrDefault();
                var queryWin3 = (from T in (((from tbl_ActPoints in dc.tbl_ActPoints
                                              select new
                {
                    StudentId = (int?)tbl_ActPoints.StudentId,
                    Score = (int?)tbl_ActPoints.Score
                }).Concat(
                                                 from tbl_EvaPoints in dc.tbl_EvaPoints
                                                 select new
                {
                    StudentId = (int?)tbl_EvaPoints.StudentId,
                    Score = (int?)tbl_EvaPoints.Score
                })))
                                 group T by new
                {
                    T.StudentId
                } into g
                                 orderby g.Sum(p => p.Score) descending
                                 select new
                {
                    g.Key.StudentId,
                    HighScoreUser = g.Sum(p => p.Score)
                }).Take(1).FirstOrDefault();
                userId1 = queryWin1.StudentId.Value;
                userId2 = queryWin2.StudentId.Value;
                userId3 = queryWin3.StudentId.Value;
            }
            catch (Exception)
            {
            }
        }
Пример #8
0
        private void cmbClass_EditValueChanged(object sender, EventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            tblStudentBindingSource.DataSource = dc.SelectStudentByClassIdNoIMG((int)cmbClass.EditValue);
            cmbStudent.ItemIndex = 0;
        }
Пример #9
0
        private void tileView_ItemDrop(object sender, DevExpress.XtraGrid.Views.Tile.ItemDropEventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            var newStatus  = e.GroupColumnValue;
            var prevStatus = e.PrevGroupColumnValue;

            if (!prevStatus.Equals(newStatus))
            {
                var id  = tileView.GetRowCellValue(e.RowHandle, "Id");
                int lbl = (int)tileView.GetRowCellValue(e.RowHandle, "Label");
                if (newStatus.ToString().Equals("انجام شده"))
                {
                    lbl = 2;
                }
                else if (newStatus.ToString().Equals("درحال انجام"))
                {
                    lbl = 1;
                }
                else if (newStatus.ToString().Equals("برای انجام"))
                {
                    lbl = 0;
                }
                else
                {
                    lbl = (int)tileView.GetRowCellValue(e.RowHandle, "Label");
                }

                dc.UpdateTaskLabel((int)id, newStatus.ToString(), lbl);
                dc.SubmitChanges();
                dc = new ClassSRMDataContext(Config.connection);
                InitData();
            }
        }
Пример #10
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     if (gridView1.RowCount != 0)
     {
         try
         {
             var dc     = new ClassSRMDataContext(Config.connection);
             int id     = (int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Id");
             var result = XtraMessageBox.Show("آیا از حذف این امتیاز اطمینان دارید؟", "توجه", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
             if (result == DialogResult.Yes)
             {
                 dc.DeleteEvaBook(id);
                 XtraMessageBox.Show("امتیاز موردنظر با موفقیت حذف شد", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 cmbStudent_EditValueChanged(null, null);
             }
         }
         catch (Exception)
         {
         }
     }
     else
     {
         XtraMessageBox.Show("اطلاعاتی برای حذف وجود ندارد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #11
0
        private void Shedule_Load(object sender, EventArgs e)
        {
            context = new ClassSRMDataContext(Config.connection);
            DBAppointmentList apts = new DBAppointmentList();

            apts.AddRange(context.DBAppointments.ToArray());

            List <DBResource> resources = new List <DBResource>();

            resources.AddRange(context.DBResources.ToArray());

            AppointmentStorage aptStorage = schedulerStorage1.Appointments;
            ResourceStorage    resStorage = schedulerStorage1.Resources;

            aptStorage.Mappings.AllDay         = "AllDay";
            aptStorage.Mappings.Description    = "Description";
            aptStorage.Mappings.End            = "EndTime";
            aptStorage.Mappings.Label          = "Label";
            aptStorage.Mappings.Location       = "Location";
            aptStorage.Mappings.RecurrenceInfo = "RecurrenceInfo";
            aptStorage.Mappings.ReminderInfo   = "ReminderInfo";
            aptStorage.Mappings.ResourceId     = "CarIdShared";
            aptStorage.Mappings.Start          = "StartTime";
            aptStorage.Mappings.Status         = "Status";
            aptStorage.Mappings.Subject        = "Subject";
            aptStorage.Mappings.Type           = "EventType";

            resStorage.Mappings.Id      = "ID";
            resStorage.Mappings.Caption = "Model";
            resStorage.Mappings.Image   = "Picture";

            resStorage.DataSource = resources;
            aptStorage.DataSource = apts;
            schedulerControl1.GoToToday();
        }
Пример #12
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (gridView1.RowCount != 0)
            {
                try
                {
                    var dc = new ClassSRMDataContext(Config.connection);

                    byte[] imageData = imageToByteArray(img.Image);
                    int    id        = (int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Id");
                    dc.UpdateStudent(id, (int)lookUpEdit2.EditValue, txtName.Text, txtLName.Text, txtFName.Text, cmbGender.Text, imageData);
                    tblStudentBindingSource.EndEdit();
                    dc = new ClassSRMDataContext(Config.connection);
                    XtraMessageBox.Show("دانش آموز موردنظر با موفقیت ویرایش شد", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    loadStudent();
                }
                catch (Exception ex)
                {
                    XtraMessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                XtraMessageBox.Show("اطلاعاتی برای ویرایش وجود ندارد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #13
0
        private void PointBook_Load(object sender, EventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            GC.Collect();
            GC.WaitForPendingFinalizers();
            var tosifi = Config.ReadSetting("Tosifi System");

            if (tosifi == "true")
            {
                cmbScore2Visibility.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                cmbScoreVisibility.Visibility  = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
            }
            else
            {
                cmbScore2Visibility.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                cmbScoreVisibility.Visibility  = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            }

            tblSchoolBindingSource.DataSource = dc.SelectSchool();
            cmbClass.ItemIndex = 0;


            if (isQuastion)
            {
                cmbBook.SelectedIndex = bookIndex;
                cmbClass.EditValue    = SchoolId;
                tblStudentBindingSource.DataSource = dc.SelectStudentByClassIdNoIMG((int)cmbClass.EditValue);
                cmbStudent.EditValue = StudentId;
            }
        }
Пример #14
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     if (gridView1.RowCount != 0)
     {
         try
         {
             var dc     = new ClassSRMDataContext(Config.connection);
             int id     = (int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Id");
             var result = XtraMessageBox.Show("با حذف دانش آموز، تمامی امتیازات آن حذف خواهند شد.آیا ادامه می دهید؟", "توجه", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
             if (result == DialogResult.Yes)
             {
                 dc.DeleteStudent(id);
                 XtraMessageBox.Show("دانش آموز موردنظر با موفقیت حذف شد", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 loadStudent();
             }
         }
         catch (Exception ex)
         {
             XtraMessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         XtraMessageBox.Show("اطلاعاتی برای حذف وجود ندارد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #15
0
        private void cmbStudent_EditValueChanged(object sender, EventArgs e)
        {
            var dc    = new ClassSRMDataContext(Config.connection);
            var query = dc.SelectCurScore((int)cmbStudent.EditValue).First();

            lblCurScore.Text = query.ScoreSum.ToString();
        }
Пример #16
0
        private void PointActivityList_Load(object sender, EventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            tblSchoolBindingSource.DataSource = dc.SelectSchool();
            cmbClass.ItemIndex = 0;
            EditableProgressBar();
        }
Пример #17
0
        private void frmLetterAll_Load(object sender, EventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            tblSchoolBindingSource.DataSource = dc.SelectSchool();
            cmbClass.ItemIndex = 0;
            txtDate.EditValue  = DateTime.Now;
        }
Пример #18
0
        private void Ask_Load(object sender, EventArgs e)
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
            var dc = new ClassSRMDataContext(Config.connection);

            tblSchoolBindingSource.DataSource = dc.SelectSchool();
            cmbClass.ItemIndex = 0;
        }
Пример #19
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            tblSchoolBindingSource.DataSource = dc.SelectSchool();
            cmbClass.ItemIndex = Convert.ToInt32(Config.ReadSetting("Default School"));
            EnableAnim();
            pCalendar.DateTime = DateTime.Now;
            initScheduler();
            txtDate1.DateTime = DateTime.Now;
        }
Пример #20
0
        private void cmbClass_EditValueChanged(object sender, EventArgs e)
        {
            var dc    = new ClassSRMDataContext(Config.connection);
            int count = (cmbClass.Properties.DataSource as IList).Count;

            if (count > 0)
            {
                tblStudentBindingSource.DataSource = dc.SelectStudentByClassIdNoIMG((int)cmbClass.EditValue);
                cmbStudent.ItemIndex = 0;
            }
        }
Пример #21
0
        private void cmbClass2_EditValueChanged(object sender, EventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            int count = (cmbClass2.Properties.DataSource as IList).Count;

            if (count > 0)
            {
                bsStudent.DataSource = dc.SelectTopYear((int)cmbClass2.EditValue);
            }
        }
Пример #22
0
        private void cmbClass_EditValueChanged(object sender, EventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            string date  = txtDate.Text.Substring(0, 7);
            int    count = (cmbClass.Properties.DataSource as IList).Count;

            if (count > 0)
            {
                gridControl1.DataSource = dc.SelectTopMonth((int)cmbClass.EditValue, date + "/01", date + "/31");
            }
        }
Пример #23
0
        private void CompareBarChart_Load(object sender, EventArgs e)
        {
            try
            {
                var dc = new ClassSRMDataContext(Config.connection);

                tblSchoolBindingSource.DataSource = dc.SelectSchool();
            }
            catch (Exception)
            {
            }
        }
Пример #24
0
        private void cmbClass_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                var dc = new ClassSRMDataContext(Config.connection);

                tblStudentBindingSource.DataSource = dc.SelectStudentByClassIdNoIMG((int)cmbClass.EditValue);
            }
            catch (Exception)
            {
                XtraMessageBox.Show("برنامه با مشکل مواجه شد", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #25
0
        private void loadStudent()
        {
            try
            {
                var dc = new ClassSRMDataContext(Config.connection);

                tblStudentBindingSource.DataSource = dc.SelectStudentByClassId((int)cmbClass.EditValue);
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #26
0
        private void btnActive_Click(object sender, EventArgs e)
        {
            var dc = new ClassSRMDataContext(Config.connection);

            dc.InsertCheck((int)gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Id"), true, strDate);
            gridView1.DeleteSelectedRows();
            gridView1.SelectRow(0);
            lblCount.Text = gridView1.DataRowCount + " نفر بررسی نشده اند";
            if (gridView1.DataRowCount == 0)
            {
                Close();
            }
        }
Пример #27
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         var dc = new ClassSRMDataContext(Config.connection);
         dc.InsertSchool(txtSchool.Text, txtAdmin.Text, cmbClass.Text, txtDate.Text);
         XtraMessageBox.Show("مدرسه موردنظر با موفقیت ثبت شد", "توجه", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #28
0
        private void cmbClass_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                var dc = new ClassSRMDataContext(Config.connection);

                bsStudent.DataSource = dc.SelectGifts((int)cmbClass.EditValue, strYear + "/" + strCurMonth + "/" + "01", strYear + "/" + strCurMonth + "/" + "31", strYear + "/" + PrevMonth.ToString("00") + "/" + "01", strYear + "/" + PrevMonth.ToString("00") + "/" + "31");
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #29
0
        //Load Student
        private void LoadStudent()
        {
            var dc    = new ClassSRMDataContext(Config.connection);
            int count = (cmbClass.Properties.DataSource as IList).Count;

            if (count > 0)
            {
                int id = (int)cmbClass.EditValue;
                tblStudentBindingSource.DataSource = dc.SelectStudentByClassId(id);
            }
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Пример #30
0
        private void cmbClass_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                var dc = new ClassSRMDataContext(Config.connection);

                sumAEBindingSource.DataSource = from v in dc.SumAEs where v.StuClassId == (int)cmbClass.EditValue select v;
                chartControl1.Series["Series 1"].LegendText = cmbClass.Text;
            }
            catch (Exception)
            {
                XtraMessageBox.Show("مشکلی پیش آمده است", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }