public bool Compare(T_Application value)
 {
     using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
     {
         return(dc.T_Applications.Where(x => x.Active == value.Active && x.Application.ToLower() == value.Application.ToLower()).FirstOrDefault() == null ? true : false);
     }
 }
        public void Save(T_Application value, ref string msg)
        {
            T_Application valueupdate = new T_Application();

            using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
            {
                //check data is already exist
                if (Compare(value))
                {
                    //is Save New
                    if (value.ID == 0)
                    {
                        dc.T_Applications.InsertOnSubmit(value);
                        msg = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}", SystemProperties.MessageNotification.Saved, value.Application, value.Active);
                    }
                    // Is Update
                    else
                    {
                        valueupdate             = dc.T_Applications.Where(x => x.ID == value.ID).FirstOrDefault();
                        valueupdate.Application = value.Application;
                        valueupdate.Description = value.Description;
                        valueupdate.Active      = value.Active;
                        msg = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}", SystemProperties.MessageNotification.Updated, valueupdate.Application, valueupdate.Active);
                    }
                    dc.SubmitChanges();
                }
                else
                {
                    msg = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}", SystemProperties.MessageNotification.Exist, value.Application, value.Active);
                }
            }
        }
        private T_Application SetApplication()
        {
            T_Application valueRet = new T_Application();

            valueRet.ID          = isAdd?0:Convert.ToInt64(dgApplication.SelectedRows[0].Cells[0].Value.ToString());
            valueRet.Application = txtApplication.Text;
            valueRet.Description = txtDescription.Text;
            valueRet.Active      = cbActive.Checked;
            return(valueRet);
        }
        public void Delete(T_Application value, ref string msg)
        {
            T_Application valuedelete = new T_Application();

            using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
            {
                valuedelete = dc.T_Applications.Where(x => x.ID == value.ID).FirstOrDefault();
                msg         = string.Format("{0} " + Environment.NewLine + Environment.NewLine + "{1}" + Environment.NewLine + " {2}", SystemProperties.MessageNotification.Deleted, valuedelete.Application, valuedelete.Active);
                dc.T_Applications.DeleteOnSubmit(valuedelete);
                dc.SubmitChanges();
            }
        }