Ejemplo n.º 1
0
        void Save()
        {
            if (SystemProperties.ShowMessage.MessageQuestion(SystemProperties.MessageNotification.YouWantToSave, "Year level") == DialogResult.Yes)
            {
                if (!string.IsNullOrWhiteSpace(txtYearLevel.Text))
                {
                    using (Maintenance _maintain = new Maintenance())
                    {
                        T_YearLevel value = new T_YearLevel();
                        value.ID        = isAdd ? 0 : Convert.ToInt64(dgYearLevel.SelectedRows[0].Cells[0].Value.ToString());
                        value.YearLevel = txtYearLevel.Text;
                        value.Active    = cbActive.Checked;
                        value.Count     = Convert.ToInt32(txtCount.Value);
                        _maintain.Save(value, ref MsgReturned);

                        SystemProperties.ShowMessage.MessageInformation(MsgReturned, "Year level");
                        SystemProperties.Cleared(this, false, true, true);
                    }
                }
                else
                {
                    SystemProperties.ShowMessage.MessageError(SystemProperties.MessageNotification.CheckInput + Environment.NewLine + Environment.NewLine + "Year level", "Year level");
                }
            }
            LoadYearLevel();
        }
        public void Save(T_YearLevel value, ref string msg)
        {
            T_YearLevel valueupdate = new T_YearLevel();

            using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
            {
                //check data is already exist
                if (Compare(value))
                {
                    //is Save New
                    if (value.ID == 0)
                    {
                        dc.T_YearLevels.InsertOnSubmit(value);
                        msg = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}", SystemProperties.MessageNotification.Saved, value.YearLevel, value.Active);
                    }
                    // Is Update
                    else
                    {
                        valueupdate           = dc.T_YearLevels.Where(x => x.ID == value.ID).FirstOrDefault();
                        valueupdate.YearLevel = value.YearLevel;
                        valueupdate.Active    = value.Active;
                        valueupdate.Count     = value.Count;
                        msg = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}", SystemProperties.MessageNotification.Updated, valueupdate.YearLevel, valueupdate.Active);
                    }
                    dc.SubmitChanges();
                }
                else
                {
                    msg = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}", SystemProperties.MessageNotification.Exist, value.YearLevel, value.Active);
                }
            }
        }
 public bool Compare(T_YearLevel value)
 {
     using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
     {
         return(dc.T_YearLevels.Where(x => x.Count == value.Count && x.Active == value.Active && x.YearLevel.ToLower() == value.YearLevel.ToLower()).FirstOrDefault() == null ? true : false);
     }
 }
        public void Delete(T_YearLevel value, ref string msg)
        {
            T_YearLevel valuedelete = new T_YearLevel();

            using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
            {
                valuedelete = dc.T_YearLevels.Where(x => x.ID == value.ID).FirstOrDefault();
                msg         = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}", SystemProperties.MessageNotification.Deleted, valuedelete.YearLevel, valuedelete.Active);
                dc.T_YearLevels.DeleteOnSubmit(valuedelete);
                dc.SubmitChanges();
            }
        }
Ejemplo n.º 5
0
 void Delete()
 {
     if (SystemProperties.ShowMessage.MessageQuestion(SystemProperties.MessageNotification.YouWantToDelete, "Year level") == DialogResult.Yes)
     {
         if (!string.IsNullOrWhiteSpace(txtYearLevel.Text))
         {
             T_YearLevel value = new T_YearLevel();
             value.ID = Convert.ToInt64(dgYearLevel.SelectedRows[0].Cells[0].Value.ToString());
             using (Maintenance _maintain = new Maintenance())
             {
                 _maintain.Delete(value, ref MsgReturned);
                 SystemProperties.ShowMessage.MessageInformation(MsgReturned, "Year level");
             }
         }
         else
         {
             SystemProperties.ShowMessage.MessageError(SystemProperties.MessageNotification.SelectFirst + " delete", "Year level");
         }
     }
     LoadYearLevel();
 }