コード例 #1
0
        public void Save(T_DeviceSettingRFID value, ref string msg)
        {
            //T_DeviceSettingRFID valueupdate = new T_DeviceSettingRFID();
            using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
            {
                if (Compare(value))
                {
                    if (value.ID == 0)
                    {
                        dc.T_DeviceSettingRFIDs.InsertOnSubmit(value);
                        msg = string.Format("{0}" + Environment.NewLine + Environment.NewLine + "Device Name: {1}" + Environment.NewLine + "Port: {2}" + Environment.NewLine + "Baund Rate: {3}" + Environment.NewLine + "Data Bit: {4}" + Environment.NewLine + "Parity: {5}" + Environment.NewLine + "Stop Bit: {6}", SystemProperties.MessageNotification.Saved, value.DeviceName, value.Port, value.BaundRate, value.DataBit, value.Parity, value.StopBit);
                    }
                    else
                    {
                        //valueupdate = dc.T_DeviceSettingRFIDs.Where(x => x.ID == value.ID).FirstOrDefault();
                        var valueupdate = dc.T_DeviceSettingRFIDs.FirstOrDefault(x => x.ID == value.ID);
                        valueupdate.DeviceName = value.DeviceName;
                        valueupdate.BaundRate  = value.BaundRate;
                        valueupdate.DataBit    = value.DataBit;
                        valueupdate.Parity     = value.Parity;;
                        valueupdate.Port       = value.Port;
                        valueupdate.StopBit    = value.StopBit;
                        valueupdate.Active     = value.Active;
                        msg = string.Format("{0}" + Environment.NewLine + Environment.NewLine + "Device Name: {1}" + Environment.NewLine + "Port: {2}" + Environment.NewLine + "Baund Rate: {3}" + Environment.NewLine + "Data Bit: {4}" + Environment.NewLine + "Parity: {5}" + Environment.NewLine + "Stop Bit: {6}", SystemProperties.MessageNotification.Updated, value.DeviceName, value.Port, value.BaundRate, value.DataBit, value.Parity, value.StopBit);
                    }
                }
                else
                {
                    msg = SystemProperties.MessageNotification.Exist;
                }

                dc.SubmitChanges();
            }
        }
コード例 #2
0
 public void Delete(T_DeviceSettingRFID value, ref string msg)
 {
     //T_DeviceSettingRFID valuedelete = new T_DeviceSettingRFID();
     using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
     {
         //var valuedelete = dc.T_DeviceSettingRFIDs.Where(x => x.ID == value.ID).FirstOrDefault();
         var valuedelete = dc.T_DeviceSettingRFIDs.FirstOrDefault(x => x.ID == value.ID);
         dc.T_DeviceSettingRFIDs.DeleteOnSubmit(valuedelete);
         dc.SubmitChanges();
         msg = string.Format("{0}" + Environment.NewLine + Environment.NewLine + "Device Name: {1}" + Environment.NewLine + "Port: {2}" + Environment.NewLine + "Baund Rate: {3}" + Environment.NewLine + "Data Bit: {4}" + Environment.NewLine + "Parity: {5}" + Environment.NewLine + "Stop Bit: {6}", SystemProperties.MessageNotification.Deleted, valuedelete.DeviceName, valuedelete.Port, valuedelete.BaundRate, valuedelete.DataBit, valuedelete.Parity, valuedelete.StopBit);
     }
 }
コード例 #3
0
 public bool Compare(T_DeviceSettingRFID value)
 {
     using (AttMonSysRFIDDataContext dc = new AttMonSysRFIDDataContext(SystemConnection.ConnectionString))
     {
         //return dc.T_DeviceSettingRFIDs.Where(x => x.Active == value.Active && x.DeviceName.ToLower() == value.DeviceName.ToLower() && x.BaundRate == value.BaundRate && x.DataBit == value.DataBit && x.Parity == value.Parity && x.Port == value.Port && x.StopBit == value.StopBit).FirstOrDefault() == null ? true : false;
         return(dc.T_DeviceSettingRFIDs
                .Where(x =>
                       x.Active == value.Active &&
                       x.DeviceName.ToLower() == value.DeviceName.ToLower() &&
                       x.BaundRate == value.BaundRate &&
                       x.DataBit == value.DataBit &&
                       x.Parity == value.Parity &&
                       x.Port == value.Port &&
                       x.StopBit == value.StopBit)
                .Any());
     }
 }
コード例 #4
0
        private T_DeviceSettingRFID SetDeviceConfig(bool isDelete)
        {
            T_DeviceSettingRFID value = new T_DeviceSettingRFID();

            value.Active     = cbActive.Checked;
            value.BaundRate  = Convert.ToInt32(txtBaundRate.Text);
            value.DataBit    = Convert.ToInt32(txtDataBits.Text);
            value.Parity     = cmbParity.Text;
            value.StopBit    = cmbStopBits.Text;
            value.Port       = txtComPort.Text;
            value.DeviceName = txtName.Text;
            value.ID         = isAdd?0:Convert.ToInt64(dgDevice.SelectedRows[0].Cells[0].Value.ToString());
            if (isDelete)
            {
                value.ID = Convert.ToInt64(dgDevice.SelectedRows[0].Cells[0].Value.ToString());
            }
            return(value);
        }