private void LoadData()
        {
            string          IsFirstCard  = "";
            string          MacFirstCard = "";
            DataTableReader dr           = null;

            cbbMode1.Items.Clear();
            cbbMode2.Items.Clear();
            try
            {
                if (!db.IsOpen)
                {
                    db.Open(SystemInfo.ConnStr);
                }
                TCommonType ctype;
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003001, new string[] { "110" }));
                while (dr.Read())
                {
                    ctype = new TCommonType(dr["MacDoorCommandWaySysID"].ToString(), dr["MacDoorCommandWayID"].ToString(),
                                            dr["MacDoorCommandWayName"].ToString(), true);
                    cbbMode1.Items.Add(ctype);
                    cbbMode2.Items.Add(ctype);
                }
                dr.Close();
                cbbMode1.SelectedIndex = 0;
                cbbMode2.SelectedIndex = 0;
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003001, new string[] { "102", SysID }));
                if (dr.Read())
                {
                    IsFirstCard  = dr["IsFirstCard"].ToString();
                    MacFirstCard = dr["MacFirstCard"].ToString();
                }
                dr.Close();
                TMacFirstCard card = new TMacFirstCard(MacFirstCard);
                txtBeginTime.Text = card.StartTime;
                txtEndTime.Text   = card.EndTime;
                SetWayIndex(cbbMode1, card.Way[0]);
                SetWayIndex(cbbMode2, card.Way[1]);
                checkBox1.Checked = card.Week[6] == 1;
                checkBox2.Checked = card.Week[0] == 1;
                checkBox3.Checked = card.Week[1] == 1;
                checkBox4.Checked = card.Week[2] == 1;
                checkBox5.Checked = card.Week[3] == 1;
                checkBox6.Checked = card.Week[4] == 1;
                checkBox7.Checked = card.Week[5] == 1;
                if (card.EmpList != "")
                {
                    string sql = "";
                    if (SystemInfo.HasFaCard)
                    {
                        sql = Pub.GetSQL(DBCode.DB_003001, new string[] { "108", card.EmpList });
                    }
                    else
                    {
                        sql = Pub.GetSQL(DBCode.DB_003001, new string[] { "301", card.EmpList });
                    }
                    dr = db.GetDataReader(sql);
                    while (dr.Read())
                    {
                        QuickSearchNormalCardByEmpSysID(dr["EmpSysID"].ToString(), cardGrid, MaxCard);
                    }
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            chkEnabled.Checked = IsFirstCard.ToUpper() == "Y";
            chkEnabled_CheckedChanged(null, null);
        }
Beispiel #2
0
        protected override bool ExecMacDoorCommand(byte flag, TMJDoorInfo doorInfo, ref string MacMsg)
        {
            bool   ret     = base.ExecMacDoorCommand(flag, doorInfo, ref MacMsg);
            bool   IsError = false;
            int    Index   = 0;
            string cardNo  = "";

            switch (flag)
            {
            case 0:
                QHKS.TMJFirstCardInfo cardInfo = new QHKS.TMJFirstCardInfo();
                cardInfo.DoorID     = Convert.ToByte(doorInfo.DoorID);
                cardInfo.CommandWay = new byte[2];
                cardInfo.Week       = new byte[7];
                cardInfo.StartTime  = "00:00";
                cardInfo.EndTime    = "00:00";
                cardInfo.CardList   = new string[10];
                if (doorInfo.ExtField[0] == "Y")
                {
                    TMacFirstCard card = new TMacFirstCard(doorInfo.ExtField[1]);
                    for (int i = 0; i < 2; i++)
                    {
                        cardInfo.CommandWay[i] = card.Way[i];
                    }
                    for (int i = 0; i < 7; i++)
                    {
                        cardInfo.Week[i] = card.Week[i];
                    }
                    cardInfo.StartTime = card.StartTime;
                    cardInfo.EndTime   = card.EndTime;
                    if (card.EmpList != "")
                    {
                        DataTableReader dr = null;
                        try
                        {
                            string sql = "";
                            if (SystemInfo.HasFaCard)
                            {
                                sql = Pub.GetSQL(DBCode.DB_003001, new string[] { "108", card.EmpList });
                            }
                            else
                            {
                                sql = Pub.GetSQL(DBCode.DB_003001, new string[] { "301", card.EmpList });
                            }
                            dr = db.GetDataReader(sql);
                            while (dr.Read())
                            {
                                cardNo = dr["OtherCardNo"].ToString();
                                if (SystemInfo.AdvUseOtherCard && cardNo != "")
                                {
                                    cardInfo.CardList[Index] = "1-" + cardNo;
                                }
                                else
                                {
                                    cardInfo.CardList[Index] = dr["CardPhysicsNo10"].ToString();
                                }
                                Index += 1;
                            }
                        }
                        catch (Exception E)
                        {
                            IsError = true;
                            Pub.ShowErrorMsg(E);
                        }
                        finally
                        {
                            if (dr != null)
                            {
                                dr.Close();
                            }
                            dr = null;
                        }
                    }
                    for (int i = Index; i < 10; i++)
                    {
                        cardInfo.CardList[i] = "";
                    }
                }
                if (!IsError)
                {
                    ret = DeviceObject.objMJ.SetMacFirstCardInfo(ref cardInfo);
                }
                break;
            }
            return(ret);
        }
        protected override bool ExecMacDoorCommand(byte flag, TMJDoorInfo doorInfo, ref string MacMsg)
        {
            bool   ret     = base.ExecMacDoorCommand(flag, doorInfo, ref MacMsg);
            bool   IsError = false;
            int    Index   = 0;
            UInt32 cardNo  = 0;

            switch (flag)
            {
            case 0:
                AccessV2API.TYPE_DoorExpert_First cardInfo = new AccessV2API.TYPE_DoorExpert_First();
                cardInfo.CardNo     = new UInt32[10];
                cardInfo.WeekConfig = new byte[8];
                if (doorInfo.ExtField[0] == "Y")
                {
                    TMacFirstCard card = new TMacFirstCard(doorInfo.ExtField[1]);
                    cardInfo.InsideMode  = card.Way[0];
                    cardInfo.OutsideMode = card.Way[1];
                    for (int i = 0; i < 7; i++)
                    {
                        if (card.Week[i] == 0)
                        {
                            cardInfo.WeekConfig[i] = 1;
                        }
                        else
                        {
                            cardInfo.WeekConfig[i] = 0;
                        }
                    }
                    if (card.StartTime.Length == 5)
                    {
                        cardInfo.TimeBegin.wHour   = Convert.ToUInt16(card.StartTime.Substring(0, 2));
                        cardInfo.TimeBegin.wMinute = Convert.ToUInt16(card.StartTime.Substring(3, 2));
                    }
                    if (card.EndTime.Length == 5)
                    {
                        cardInfo.TimeEnd.wHour   = Convert.ToUInt16(card.EndTime.Substring(0, 2));
                        cardInfo.TimeEnd.wMinute = Convert.ToUInt16(card.EndTime.Substring(3, 2));
                    }
                    if (card.EmpList != "")
                    {
                        DataTableReader dr = null;
                        try
                        {
                            string sql = "";
                            if (SystemInfo.HasFaCard)
                            {
                                sql = Pub.GetSQL(DBCode.DB_003001, new string[] { "108", card.EmpList });
                            }
                            else
                            {
                                sql = Pub.GetSQL(DBCode.DB_003001, new string[] { "301", card.EmpList });
                            }
                            dr = db.GetDataReader(sql);
                            while (dr.Read())
                            {
                                UInt32.TryParse(dr["OtherCardNo"].ToString(), out cardNo);
                                if (SystemInfo.AdvUseOtherCard && cardNo > 0)
                                {
                                    cardInfo.CardNo[Index] = cardNo;
                                }
                                else
                                {
                                    UInt32.TryParse(dr["CardPhysicsNo10"].ToString(), out cardInfo.CardNo[Index]);
                                }
                                Index++;
                            }
                        }
                        catch (Exception E)
                        {
                            IsError = true;
                            Pub.ShowErrorMsg(E);
                        }
                        finally
                        {
                            if (dr != null)
                            {
                                dr.Close();
                            }
                            dr = null;
                        }
                    }
                }
                if (!IsError)
                {
                    AccessV2API.TYPE_DoorBasic  basic  = new AccessV2API.TYPE_DoorBasic();
                    AccessV2API.TYPE_DoorExpert expert = new AccessV2API.TYPE_DoorExpert();
                    ret = DeviceObject.objMJNew.ReadDoorInfo(doorInfo.DoorID, ref basic, ref expert);
                    if (ret)
                    {
                        expert.ExpertFirstCard = cardInfo;
                        if (doorInfo.ExtField[0] == "Y")
                        {
                            expert.EnableFirstCard = 1;
                        }
                        else
                        {
                            expert.EnableFirstCard = 0;
                        }
                        ret = DeviceObject.objMJNew.SetDoorExpertInfo(doorInfo.DoorID, expert);
                    }
                }
                break;
            }
            return(ret);
        }