Beispiel #1
0
 public void SetCount()
 {
     try
     {
         int ValidCount = 0;
         int LostCount  = 0;
         int LimitCount = 0;
         for (int i = 0; i < oNewDS.MyCardInfo.Count; i++)
         {
             NewDS.CardInfo temp = oNewDS.MyCardInfo[i];
             if (temp.CardType == 1)
             {
                 ValidCount = ValidCount + 1;
             }
             else if (temp.CardType == 2)
             {
                 LostCount = LostCount + 1;
             }
             else if (temp.CardType == 3)
             {
                 LimitCount = LimitCount + 1;
             }
         }
         lbValidCount.Text = ValidCount.ToString();
         lbLossCount.Text  = LostCount.ToString();
         lbLimitCount.Text = LimitCount.ToString();
     }
     catch
     {
     }
 }
Beispiel #2
0
        public bool DeleteCard()
        {
            bool result = true;

            try
            {
                NewDS.CardInfo temp = oNewDS.MyCardInfo[ID];
                temp.CardType   = 0;
                temp.BuildingNO = 0;
                temp.UnitNO     = 0;
                temp.RoomNO     = 0;
                temp.UIDL       = 0;
                temp.UID        = new byte[10];
                temp.arayDate   = new byte[5];
                temp.arayPhone  = new byte[11];
                temp.arayName   = new byte[10];
                temp.Remark     = "";
                byte[] arayTmp = new byte[64];
                arayTmp[0] = temp.UIDL;
                Array.Copy(temp.UID, 0, arayTmp, 1, temp.UIDL);
                arayTmp[11] = temp.CardType;
                arayTmp[12] = Convert.ToByte(temp.CardNum / 256);
                arayTmp[13] = Convert.ToByte(temp.CardNum % 256);
                arayTmp[14] = Convert.ToByte(temp.BuildingNO / 256);
                arayTmp[15] = Convert.ToByte(temp.BuildingNO % 256);
                arayTmp[16] = Convert.ToByte(temp.UnitNO / 256);
                arayTmp[17] = Convert.ToByte(temp.UnitNO % 256);
                arayTmp[18] = Convert.ToByte(temp.RoomNO / 256);
                arayTmp[19] = Convert.ToByte(temp.RoomNO % 256);
                Array.Copy(temp.arayDate, 0, arayTmp, 20, temp.arayDate.Length);
                Array.Copy(temp.arayName, 0, arayTmp, 25, temp.arayName.Length);
                Array.Copy(temp.arayPhone, 0, arayTmp, 35, temp.arayPhone.Length);

                byte[] arayTmpRemark = HDLUDP.StringToByte(temp.Remark);
                byte[] ArayMain      = new byte[18];
                if (arayTmpRemark.Length > 18)
                {
                    Array.Copy(arayTmpRemark, 0, ArayMain, 0, 18);
                }
                else
                {
                    Array.Copy(arayTmpRemark, 0, ArayMain, 0, arayTmpRemark.Length);
                }
                Array.Copy(ArayMain, 0, arayTmp, 46, ArayMain.Length);
                if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3518, SubNetID, DeviceID, false, false, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)
                {
                }
                else
                {
                    result = false;
                }
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Beispiel #3
0
 private void ModifyCard()
 {
     try
     {
         NewDS.CardInfo temp = null;
         if (oNewDS != null)
         {
             temp = oNewDS.MyCardInfo[ID];
         }
         else if (oDS != null)
         {
             temp = oDS.MyCardInfo[ID];
         }
         lbUIDLV.Text = temp.UIDL.ToString();
         string strUID = "";
         for (int i = 0; i < temp.UIDL; i++)
         {
             strUID = strUID + GlobalClass.AddLeftZero(temp.UID[i].ToString("X"), 2) + " ";
         }
         lbUIDDV.Text         = strUID.Trim();
         cbType.SelectedIndex = temp.CardType - 1;
         txtBuilding.Text     = temp.BuildingNO.ToString("X");
         txtUnit.Text         = temp.UnitNO.ToString("X");
         txtRoom.Text         = temp.RoomNO.ToString("X");
         txtName.Text         = HDLPF.Byte2String(temp.arayName);
         txtPhone.Text        = HDLPF.Byte2String(temp.arayPhone);
         txtRemark.Text       = temp.Remark;
         if (temp.arayDate[3] > 23)
         {
             temp.arayDate[3] = 23;
         }
         if (temp.arayDate[4] > 59)
         {
             temp.arayDate[4] = 59;
         }
         numTime1.Value = Convert.ToDecimal(temp.arayDate[3]);
         numTime2.Value = Convert.ToDecimal(temp.arayDate[4]);
         if (temp.arayDate[1] > 12)
         {
             temp.arayDate[1] = 12;
         }
         if (temp.arayDate[2] > 31)
         {
             temp.arayDate[2] = 31;
         }
         DateTime d2 = new DateTime(temp.arayDate[0] + 2000, temp.arayDate[1], temp.arayDate[2]);
         TimePicker.Text  = d2.ToString();
         TimePicker.Value = d2;
     }
     catch
     {
     }
 }
Beispiel #4
0
        private void PIC_MouseHover(object sender, EventArgs e)
        {
            string str = "";

            NewDS.CardInfo temp = oNewDS.MyCardInfo[ID];
            str = CsConst.mstrINIDefault.IniReadValue("Public", "00360", "") + ":" + GlobalClass.AddLeftZero(temp.BuildingNO.ToString("X"), 2) + "\r\n" +
                  CsConst.mstrINIDefault.IniReadValue("Public", "00361", "") + ":" + GlobalClass.AddLeftZero(temp.UnitNO.ToString("X"), 2) + "\r\n" +
                  CsConst.mstrINIDefault.IniReadValue("Public", "00362", "") + ":" + GlobalClass.AddLeftZero(temp.RoomNO.ToString("X"), 2) + "\r\n" +
                  CsConst.mstrINIDefault.IniReadValue("Public", "00363", "") + ":" + (temp.arayDate[0] + 2000).ToString() + "/" + temp.arayDate[1].ToString() + "/" + temp.arayDate[2].ToString() + "  " + temp.arayDate[3].ToString() + ":" + temp.arayDate[4].ToString() + "\r\n" +
                  CsConst.mstrINIDefault.IniReadValue("Public", "00364", "") + ":" + HDLPF.Byte2String(temp.arayName) + "\r\n" +
                  CsConst.mstrINIDefault.IniReadValue("Public", "00365", "") + ":" + HDLPF.Byte2String(temp.arayPhone) + "\r\n" +
                  CsConst.mstrINIDefault.IniReadValue("Public", "00366", "") + ":" + temp.Remark.ToString();
            toolTip1.Show(str, PIC);
        }
Beispiel #5
0
        private void UserForNewDoor_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (oNewDS == null)
            {
                return;
            }
            if (oNewDS.MyCardInfo == null)
            {
                return;
            }
            picSelect.Visible = true;
            isSelect          = true;
            byte[]        arayTmp = new byte[0];
            FrmAddNewCard frmTmp  = new FrmAddNewCard(arayTmp, oNewDS, DeviceType, StrName, 1, ID);

            frmTmp.ShowDialog();
            int Width = Pnl.Width;
            int Heigh = Pnl.Height;

            Pnl.Controls.Clear();
            int WCount = Width / 150;
            int num    = 0;

            for (int i = 0; i < oNewDS.MyCardInfo.Count; i++)
            {
                NewDS.CardInfo temp = oNewDS.MyCardInfo[i];
                if (temp.CardType == Convert.ToByte(intTag))
                {
                    UserForNewDoor tmp = new UserForNewDoor(oNewDS, i, DeviceType, ShowType, StrName, Pnl, intTag, Frm);
                    tmp.Name = "Card" + num.ToString();
                    tmp.Left = (num % WCount) * 140 + 10;
                    tmp.Top  = (num / WCount) * 120 + 10;
                    Pnl.Controls.Add(tmp);
                    num = num + 1;
                }
            }
            if (Frm is FrmNewDS)
            {
                (Frm as FrmNewDS).SetCount();
            }
            else if (Frm is frmDS)
            {
                (Frm as frmDS).SetCount();
            }
        }
Beispiel #6
0
 private void btnValid_Click(object sender, EventArgs e)
 {
     try
     {
         if (oNewDS == null)
         {
             return;
         }
         if (oNewDS.MyCardInfo == null)
         {
             return;
         }
         btnValid.BackColor = Color.Transparent;
         btnLost.BackColor  = Color.Transparent;
         btnFobib.BackColor = Color.Transparent;
         int Width = panel19.Width;
         int Heigh = panel19.Height;
         int Tag   = Convert.ToInt32((sender as Button).Tag);
         (sender as Button).BackColor = Color.Yellow;
         SelectCardType = Tag;
         panel19.Controls.Clear();
         int WCount = Width / 150;
         int num    = 0;
         for (int i = 0; i < oNewDS.MyCardInfo.Count; i++)
         {
             NewDS.CardInfo temp = oNewDS.MyCardInfo[i];
             if (temp.CardType == Convert.ToByte(Tag))
             {
                 UserForNewDoor tmp = new UserForNewDoor(oNewDS, i, MyintDeviceType, cbHint.SelectedIndex, myDevName, panel19, SelectCardType, this);
                 tmp.Name = "Card" + num.ToString();
                 tmp.Left = (num % WCount) * 140 + 10;
                 tmp.Top  = (num / WCount) * 120 + 10;
                 panel19.Controls.Add(tmp);
                 num = num + 1;
             }
         }
     }
     catch
     {
     }
 }
Beispiel #7
0
        public void LoadUser(int Type)
        {
            NewDS.CardInfo temp = oNewDS.MyCardInfo[ID];
            switch (Type)
            {
            case 0: lb.Text = temp.BuildingNO.ToString("X"); break;

            case 1: lb.Text = temp.UnitNO.ToString("X"); break;

            case 2: lb.Text = temp.RoomNO.ToString("X"); break;

            case 3: lb.Text = (temp.arayDate[0] + 2000).ToString() + "/" + temp.arayDate[1].ToString() + "/" + temp.arayDate[2].ToString() + "  " +
                              temp.arayDate[3].ToString() + ":" + temp.arayDate[4].ToString(); break;

            case 4: lb.Text = HDLPF.Byte2String(temp.arayName); break;

            case 5: lb.Text = HDLPF.Byte2String(temp.arayPhone); break;

            case 6: lb.Text = temp.Remark; break;
            }
        }
Beispiel #8
0
        private void btnModify_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                NewDS.CardInfo tmp  = new NewDS.CardInfo();
                string         str1 = txtBuilding.Text;
                string         str2 = txtUnit.Text;
                string         str3 = txtRoom.Text;
                if (oDS != null)
                {
                    tmp.CardNum = oDS.MyCardInfo[ID].CardNum;
                }
                else if (oNewDS != null)
                {
                    tmp.CardNum = oNewDS.MyCardInfo[ID].CardNum;
                }
                tmp.CardType   = Convert.ToByte(cbType.SelectedIndex + 1);
                tmp.BuildingNO = Convert.ToInt32(str1, 16);
                tmp.UnitNO     = Convert.ToInt32(str2, 16);
                tmp.RoomNO     = Convert.ToInt32(str3, 16);
                tmp.UIDL       = Convert.ToByte(lbUIDLV.Text);
                tmp.UID        = new byte[10];
                byte[] arayUIDTmp = GlobalClass.HexToByte(lbUIDDV.Text);
                if (arayUIDTmp.Length > 10)
                {
                    Array.Copy(arayUIDTmp, 0, tmp.UID, 0, 10);
                }
                else
                {
                    Array.Copy(arayUIDTmp, 0, tmp.UID, 0, arayUIDTmp.Length);
                }
                tmp.arayDate    = new byte[5];
                tmp.arayDate[0] = Convert.ToByte(TimePicker.Value.Year - 2000);
                tmp.arayDate[1] = Convert.ToByte(TimePicker.Value.Month);
                tmp.arayDate[2] = Convert.ToByte(TimePicker.Value.Day);
                tmp.arayDate[3] = Convert.ToByte(numTime1.Value);
                tmp.arayDate[4] = Convert.ToByte(numTime2.Value);
                tmp.arayPhone   = new byte[11];
                byte[] arayTmpRemark = HDLUDP.StringToByte(txtPhone.Text);
                if (arayTmpRemark.Length > 11)
                {
                    Array.Copy(arayTmpRemark, 0, tmp.arayPhone, 0, 11);
                }
                else
                {
                    Array.Copy(arayTmpRemark, 0, tmp.arayPhone, 0, arayTmpRemark.Length);
                }

                tmp.arayName  = new byte[10];
                arayTmpRemark = HDLUDP.StringToByte(txtName.Text);
                if (arayTmpRemark.Length > 10)
                {
                    Array.Copy(arayTmpRemark, 0, tmp.arayName, 0, 10);
                }
                else
                {
                    Array.Copy(arayTmpRemark, 0, tmp.arayName, 0, arayTmpRemark.Length);
                }

                tmp.Remark = txtRemark.Text.Trim();
                byte[] arayTmp = new byte[64];
                arayTmp[0] = tmp.UIDL;
                Array.Copy(tmp.UID, 0, arayTmp, 1, tmp.UIDL);
                arayTmp[11] = tmp.CardType;
                arayTmp[12] = Convert.ToByte(tmp.CardNum / 256);
                arayTmp[13] = Convert.ToByte(tmp.CardNum % 256);
                arayTmp[14] = Convert.ToByte(tmp.BuildingNO / 256);
                arayTmp[15] = Convert.ToByte(tmp.BuildingNO % 256);
                arayTmp[16] = Convert.ToByte(tmp.UnitNO / 256);
                arayTmp[17] = Convert.ToByte(tmp.UnitNO % 256);
                arayTmp[18] = Convert.ToByte(tmp.RoomNO / 256);
                arayTmp[19] = Convert.ToByte(tmp.RoomNO % 256);
                Array.Copy(tmp.arayDate, 0, arayTmp, 20, tmp.arayDate.Length);
                Array.Copy(tmp.arayName, 0, arayTmp, 25, tmp.arayName.Length);
                Array.Copy(tmp.arayPhone, 0, arayTmp, 35, tmp.arayPhone.Length);

                arayTmpRemark = HDLUDP.StringToByte(tmp.Remark);
                if (arayTmpRemark.Length > 18)
                {
                    Array.Copy(arayTmpRemark, 0, arayTmp, 46, 18);
                }
                else
                {
                    Array.Copy(arayTmpRemark, 0, arayTmp, 46, arayTmpRemark.Length);
                }

                if (CsConst.mySends.AddBufToSndList(arayTmp, 0x3518, SubnetID, DeviceID, false, false, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)
                {
                    if (oNewDS != null)
                    {
                        oNewDS.MyCardInfo[ID] = tmp;
                    }
                    else if (oDS != null)
                    {
                        oDS.MyCardInfo[ID] = tmp;
                    }
                    this.Close();
                }
                else
                {
                    MessageBox.Show(CsConst.mstrINIDefault.IniReadValue("Public", "99777", ""), ""
                                    , MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                    return;
                }
            }
            catch
            {
            }
            Cursor.Current = Cursors.Default;
        }