コード例 #1
0
 public void Save(T_NotificationSetting value, ref string msg)
 {
     //T_NotificationSetting valueupdate = new T_NotificationSetting();
     using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
     {
         if (Compare(value))
         {
             if (value.ID == 0 && GetAPIs().ToList().Count == 0)
             {
                 dc.T_NotificationSettings.InsertOnSubmit(value);
                 msg = string.Format("{0}" + Environment.NewLine + Environment.NewLine +
                                     "Site: {1}" + Environment.NewLine +
                                     "Page: {2}" + Environment.NewLine +
                                     "Mobile: {3}" + Environment.NewLine +
                                     "Message:  {4}",
                                     SystemProperties.MessageNotification.Saved,
                                     value.Site,
                                     value.Page,
                                     value.ParamMobileName,
                                     value.ParamMessageName);
             }
             else
             {
                 //var valueupdate = dc.T_NotificationSettings.Where(x => x.ID == value.ID).FirstOrDefault();
                 var valueupdate = dc.T_NotificationSettings.FirstOrDefault(x => x.ID == value.ID);
                 if (valueupdate != null)
                 {
                     valueupdate.Active           = value.Active;
                     valueupdate.Page             = value.Page;
                     valueupdate.ParamMessageName = value.ParamMessageName;
                     valueupdate.ParamMobileName  = value.ParamMobileName;
                     valueupdate.Site             = value.Site;
                     msg = string.Format("{0}" + Environment.NewLine + Environment.NewLine +
                                         "Site: {1}" + Environment.NewLine +
                                         "Page: {2}" + Environment.NewLine +
                                         "Mobile: {3}" + Environment.NewLine +
                                         "Message:  {4}",
                                         SystemProperties.MessageNotification.Updated,
                                         valueupdate.Site,
                                         valueupdate.Page,
                                         valueupdate.ParamMobileName,
                                         valueupdate.ParamMessageName);
                 }
                 else
                 {
                     msg = "Not allow to add new, Please can remove site.";
                 }
             }
         }
         else
         {
             msg = SystemProperties.MessageNotification.Exist;
         }
         dc.SubmitChanges();
     }
 }
コード例 #2
0
 public bool Compare(T_NotificationSetting value)
 {
     using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
     {
         //return dc.T_NotificationSettings.Where(x => x.Active == value.Active && x.Page == value.Page && x.Site == value.Site && x.ParamMessageName == value.ParamMessageName && x.ParamMobileName == value.ParamMobileName).FirstOrDefault() == null ? true : false;
         return(dc.T_NotificationSettings
                .Where(x =>
                       x.Active == value.Active &&
                       x.Page == value.Page &&
                       x.Site == value.Site &&
                       x.ParamMessageName == value.ParamMessageName &&
                       x.ParamMobileName == value.ParamMobileName)
                .Any());
     }
 }
コード例 #3
0
        public T_NotificationSetting SetupURLLink(bool isDelete)
        {
            T_NotificationSetting Notify = new T_NotificationSetting();

            Notify.ID               = isAdd?0:Convert.ToInt64(dgSMS.SelectedRows[0].Cells[0].Value.ToString());
            Notify.Site             = txtSite.Text;
            Notify.Page             = txtPage.Text;
            Notify.ParamMessageName = txtMessage.Text;
            Notify.ParamMobileName  = txtMobile.Text;
            Notify.Active           = cbActive.Checked;
            if (isDelete)
            {
                Notify.ID = Convert.ToInt64(dgSMS.SelectedRows[0].Cells[0].Value.ToString());
            }
            return(Notify);
        }
コード例 #4
0
 public void Delete(T_NotificationSetting value, ref string msg)
 {
     //T_NotificationSetting valuedelete = new T_NotificationSetting();
     using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
     {
         //var valuedelete = dc.T_NotificationSettings.Where(x => x.ID == value.ID).FirstOrDefault();
         var valuedelete = dc.T_NotificationSettings.FirstOrDefault(x => x.ID == value.ID);
         dc.T_NotificationSettings.DeleteOnSubmit(valuedelete);
         dc.SubmitChanges();
         msg = string.Format("{0}" + Environment.NewLine + Environment.NewLine +
                             "Site: {1}" + Environment.NewLine +
                             "Page: {2}" + Environment.NewLine +
                             "Mobile: {3}" + Environment.NewLine +
                             "Message:  {4}",
                             SystemProperties.MessageNotification.Deleted,
                             value.Site,
                             value.Page,
                             value.ParamMobileName,
                             value.ParamMessageName);
     }
 }