public bool Save(T_RoomDevie value, ref string msg)
        {
            bool ret = false;

            using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
            {
                if (!string.IsNullOrWhiteSpace(value.DeviceCode))
                {
                    if (Compare(value))
                    {
                        dc.T_RoomDevies.InsertOnSubmit(value);
                        dc.SubmitChanges();
                        //return false;
                    }
                    else
                    {
                        msg = SystemProperties.MessageNotification.Exist;
                        ret = true;
                        //return true;
                    }
                }
                //dc.SubmitChanges();
                //return false;
                return(ret);
            }
        }
 public bool Compare(T_RoomDevie value)
 {
     using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
     {
         return(dc.T_RoomDevies
                .Where(x =>
                       x.SerialPort == value.SerialPort || x.RoomCode == value.RoomCode)
                .Any());
     }
 }
예제 #3
0
        void DeleteRoomDevice(string RoomCodes)
        {
            T_RoomDevie RD = new T_RoomDevie();

            RD.RoomCode = RoomCodes;
            using (DeviceModule DM = new DeviceModule())
            {
                DM.Delete(RD);
            }
        }
 public void Delete(T_RoomDevie value)
 {
     //T_RoomDevie valuedelete = new T_RoomDevie();
     using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
     {
         //valuedelete = dc.T_RoomDevies.Where(x => x.RoomCode == value.RoomCode).FirstOrDefault();
         var valuedelete = dc.T_RoomDevies.FirstOrDefault(x => x.RoomCode == value.RoomCode);
         dc.T_RoomDevies.DeleteOnSubmit(valuedelete);
         dc.SubmitChanges();
     }
 }
예제 #5
0
        void SaveRoomDevice()
        {
            T_RoomDevie RD = new T_RoomDevie();

            RD.RoomCode   = txtRoomCode.Text;
            RD.RoomType   = txtDescription.Text;
            RD.DeviceCode = txtDeviceDescription.Text;
            RD.DeviceName = DeviceName;
            RD.SerialPort = COMSerial;
            using (DeviceModule device = new DeviceModule())
            {
                if (device.Save(RD, ref MsgReturned))
                {
                    SystemProperties.ShowMessage.MessageError(MsgReturned, "Room and device");
                }
            }
        }