コード例 #1
0
        public void Save(T_ScanUserLog value, bool TimeIN)
        {
            T_ScanUserLog valueupdate = new T_ScanUserLog();

            using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
            {
                T_RegisteredStudentSemester values = new T_RegisteredStudentSemester();
                values = dc.T_RegisteredStudentSemesters.Where(x => x.StudentID == value.StudentID && x.Day.Replace(" ", "").Replace("  ", "").Replace("   ", "").Replace("    ", "") == value.Day && x.TimeStart.Hour == UserDetail.CurrDate().Hour&& x.Semester == SystemProperties.SemesterActive.Semester && x.YearClass == SystemProperties.SemesterActive.YearSemester).FirstOrDefault();

                if (TimeIN)
                {
                    values.AlreadyIN = true;
                    dc.T_ScanUserLogs.InsertOnSubmit(value);
                }
                else
                {
                    //Where(x => x.RoomCode == RoomCode && x.StudentID == StudID && x.TImeEnd == null && x.Day.ToLower() == Days().ToLower()).FirstOrDefault();
                    //valueupdate = dc.T_ScanUserLogs.Where(x => x.StudentID == value.StudentID && x.TimeIN.Value.ToShortDateString() == UserDetail.CurrDate().ToShortDateString() && x.TimeOUT==null).FirstOrDefault();
                    valueupdate         = dc.T_ScanUserLogs.Where(x => x.RoomCode == value.RoomCode && x.StudentID == value.StudentID && x.TimeOUT == null && x.Day.ToLower() == Days().ToLower()).FirstOrDefault();
                    valueupdate.TimeOUT = UserDetail.CurrDate();

                    values.AlreadyIN = false;
                }

                dc.SubmitChanges();
            }
        }
コード例 #2
0
        string Days()
        {
            DayOfWeek days = UserDetail.CurrDate().DayOfWeek;

            return(days.ToString());
        }
コード例 #3
0
        public static void  Cleared(Control me, bool enable, bool isCancel, bool isAdd)
        {
            foreach (Control ctr in me.Controls)
            {
                if (ctr.GetType() == typeof(TextBox))
                {
                    TextBox txt = (TextBox)ctr;
                    txt.ReadOnly = !enable;
                    txt.Text     = isAdd ? "" : txt.Text;
                    if (isCancel)
                    {
                        txt.Text = "";
                    }
                }
                else if (ctr.GetType() == typeof(CheckBox))
                {
                    CheckBox chk = (CheckBox)ctr;
                    chk.Enabled = enable;
                    chk.Checked = isAdd ? false : chk.Checked;
                    if (isCancel)
                    {
                        chk.Checked = false;
                    }
                }
                else if (ctr.GetType() == typeof(RadioButton))
                {
                    RadioButton chk = (RadioButton)ctr;
                    chk.Enabled = enable;
                    chk.Checked = isAdd ? false : chk.Checked;
                    if (isCancel)
                    {
                        chk.Checked = false;
                    }
                }
                else if (ctr.GetType() == typeof(PictureBox))
                {
                    PictureBox pic = (PictureBox)ctr;
                    pic.Enabled = enable;
                    pic.Image   = isAdd ? null : pic.Image;
                    if (isCancel)
                    {
                        pic.Image = null;
                    }
                }
                else if (ctr.GetType() == typeof(DataGridView))
                {
                    DataGridView dg = (DataGridView)ctr;
                    dg.Enabled = !enable;
                }
                else if (ctr.GetType() == typeof(ComboBox))
                {
                    ComboBox cmb = (ComboBox)ctr;
                    cmb.Enabled = enable;
                    cmb.Text    = isAdd ? "" : cmb.Text;
                }
                else if (ctr.GetType() == typeof(NumericUpDown))
                {
                    NumericUpDown txt = (NumericUpDown)ctr;
                    txt.ReadOnly = !enable;
                    txt.Value    = isAdd ? 1 : txt.Value;
                    txt.Enabled  = enable;
                    if (isCancel)
                    {
                        txt.Value = 1;
                    }
                }
                else if (ctr.GetType() == typeof(DateTimePicker))
                {
                    DateTimePicker dt = (DateTimePicker)ctr;
                    dt.Enabled = enable;
                    dt.Value   = isAdd ? UserDetail.CurrDate() : dt.Value;
                }
                else if (ctr.GetType() == typeof(MaskedTextBox))
                {
                    MaskedTextBox mtxtBox = (MaskedTextBox)ctr;
                    mtxtBox.Enabled = enable;
                    mtxtBox.Text    = isAdd ? "" : mtxtBox.Text;
                }

                else if (ctr.GetType() == typeof(Panel) || ctr.GetType() == typeof(GroupBox))
                {
                    Cleared(ctr, enable, isCancel, isAdd);
                }
            }
        }