Example #1
0
        private void MainWindow_Load(object sender, EventArgs e)
        {
            bool internet = false;
            /*新建fp文件 用于存放选择的端口号*/
            FileStream   fport = new FileStream("fp", FileMode.Create, FileAccess.Write);
            StreamWriter sw    = new StreamWriter(fport);

            sw.Close();
            oneCard  = new OneCard();
            manage   = new Manage();
            lost     = new Lost();
            internet = InternetCheck.IsConnectInternet();
            if (internet)
            {
                SLB_Internet.Text = "已接入互联网";
                DataTable dt = NPOI_OprateExcl.ExcelToTable(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 0);
                OparateMySQL.UpdateToMySQL(dt, 0);
                dt = NPOI_OprateExcl.ExcelToTable(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 1);
                OparateMySQL.UpdateToMySQL(dt, 1);
            }
            else
            {
                SLB_Internet.Text = "未接入互联网";
            }
        }
Example #2
0
 private void MainWindow_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (SLB_Internet.Text.ToString() == "已接入互联网")
     {
         DataTable dt = NPOI_OprateExcl.ExcelToTable(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 0);
         OparateMySQL.UpdateToMySQL(dt, 0);
         dt = NPOI_OprateExcl.ExcelToTable(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 1);
         OparateMySQL.UpdateToMySQL(dt, 1);
     }
 }
Example #3
0
 private void DGV_Lost_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (DGV_Lost.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex > -1)
     { //获取当前被点击的单元格
         DataGridViewButtonCell vCell = (DataGridViewButtonCell)DGV_Lost.CurrentCell;
         if (vCell.Value.ToString() != "已挂失")
         {
             NPOI_OprateExcl.ModifyACellToExcel(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 1, e.RowIndex, 13, true);
             NPOI_OprateExcl.ReadFromExclFile(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 1, DGV_Lost, "");
         }
     }
 }
Example #4
0
 private void button2_Click(object sender, EventArgs e)
 {
     NPOI_OprateExcl.ReadFromExclFile(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 1, DGV_Lost, TB_SearchICID.Text);
 }
Example #5
0
        private void BTN_WriteCard_Click(object sender, EventArgs e)
        {
            try
            {
                /*写入数据到写卡信息*/
                if (TB_icID.Text == "")
                {
                    MessageBox.Show("IC卡号不能为空!");
                }
                else
                {
                    List <Card> newc    = new List <Card>();
                    List <int>  floor   = new List <int>();
                    DateTime    time    = DateTime.Now;
                    object[]    data    = { 0, "", (Int64)0, 0, 0, "", "", false, false, time, 0, time, false, 0, "", time };
                    Int64       userid  = 0;
                    int         contact = 0;
                    if (TB_userID.Text == "")
                    {
                        userid = 000000000000000000;
                    }
                    else if (Convert.ToInt64(TB_userID.Text) < 100000000000000000)
                    {
                        userid = 000000000000000000;
                    }
                    else
                    {
                        userid = Convert.ToInt64(TB_userID.Text);
                    }
                    if (TB_comtact.Text != "")
                    {
                        contact = Convert.ToInt32(TB_comtact.Text);
                    }

                    if (TC_Car.SelectedTab.Name == "TP_Incar")
                    {
                        if ((CKB_InFloor.SelectedItems.Count == 0) || (TB_InCount.Text == ""))
                        {
                            MessageBox.Show("控制楼层和有效次数不能为空!");
                        }
                        else
                        {
                            List <int> floor0 = new List <int>();
                            bool       style = false, style1 = false;
                            for (int i = 0; i < CKB_InFloor.Items.Count; i++)
                            {
                                if (CKB_InFloor.GetItemChecked(i) == true)
                                {
                                    floor0.Add(i + 1);
                                }
                            }
                            if (RB_InAutocheck.Checked)
                            {
                                style = true;
                            }
                            else if (RB_InHandlecheck.Checked)
                            {
                                style = false;
                            }

                            if (RB_InHold5s.Checked)
                            {
                                style1 = true;
                            }
                            else if (RB_InNoHold5s.Checked)
                            {
                                style1 = false;
                            }
                            newc.Add(new Card
                            {
                                ICID         = int.Parse(TB_icID.Text),
                                UserName     = TB_userName.Text,
                                UserID       = userid,
                                LiveDepart   = TB_userRom.Text,
                                Contact      = contact,
                                Position     = TC_Car.SelectedTab.Name,
                                ControlFloor = floor0,
                                CallStyle    = style,
                                Keep5s       = style1,
                                ValidTime    = DTP_In.Value,
                                ValidCount   = int.Parse(TB_InCount.Text),
                                WriteTime    = DateTime.Now,
                                ADID         = int.Parse(TB_ADID.Text),
                                ADName       = TB_ADName.Text,
                                LostState    = false,
                            });
                            data[0]  = newc[0].ICID;
                            data[1]  = newc[0].UserName;
                            data[3]  = newc[0].LiveDepart;
                            data[4]  = newc[0].Contact;
                            data[5]  = newc[0].Position;
                            data[7]  = newc[0].CallStyle;
                            data[8]  = newc[0].Keep5s;
                            data[9]  = newc[0].ValidTime;
                            data[10] = newc[0].ValidCount;
                            data[11] = newc[0].WriteTime;
                            data[12] = newc[0].LostState;
                            data[14] = newc[0].ADName;
                            data[15] = newc[0].LostTime;
                            string str1 = null;
                            foreach (var xx in newc[0].ControlFloor)
                            {
                                // str1 += acct.ControlFloor[xx - 1].ToString() + ",";
                                str1 += xx.ToString() + ",";
                            }
                            data[6] = str1;
                            if (newc[0].UserID != 0)
                            {
                                data[2] = newc[0].UserID;
                            }
                            if (newc[0].ADID != 0)
                            {
                                data[13] = newc[0].ADID;
                            }
                            NPOI_OprateExcl.UpdateExcl(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 0, 1, data);
                            NPOI_OprateExcl.UpdatetoExcl(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 1, 1, data);
                            MessageBox.Show("写卡成功!");
                        }
                    }
                    else if (TC_Car.SelectedTab.Name == "TP_Outcar")
                    {
                        if ((CKB_OutFloor.SelectedItems.Count == 0) || (TB_OutCount.Text == ""))
                        {
                            MessageBox.Show("控制楼层和有效次数不能为空!");
                        }
                        else
                        {
                            List <int> floor0 = new List <int>();
                            bool       style = false, style1 = false;
                            for (int i = 0; i < CKB_OutFloor.Items.Count; i++)
                            {
                                if (CKB_OutFloor.GetItemChecked(i) == true)
                                {
                                    floor0.Add(i + 1);
                                }
                            }
                            if (RB_OutAutocheck.Checked)
                            {
                                style = true;
                            }
                            else if (RB_OutHandlecheck.Checked)
                            {
                                style = false;
                            }

                            if (RB_OutHold5s.Checked)
                            {
                                style1 = true;
                            }
                            else if (RB_OutNoHold5s.Checked)
                            {
                                style1 = false;
                            }
                            newc.Add(new Card
                            {
                                ICID         = int.Parse(TB_icID.Text),
                                UserName     = TB_userName.Text,
                                UserID       = userid,
                                LiveDepart   = TB_userRom.Text,
                                Contact      = contact,
                                Position     = TC_Car.SelectedTab.Name,
                                ControlFloor = floor0,
                                CallStyle    = style,
                                Keep5s       = style1,
                                ValidTime    = DTP_Out.Value,
                                ValidCount   = int.Parse(TB_OutCount.Text),
                                WriteTime    = DateTime.Now,
                                ADID         = int.Parse(TB_ADID.Text),
                                ADName       = TB_ADName.Text,
                                LostState    = false,
                            });
                            data[0]  = newc[0].ICID;
                            data[1]  = newc[0].UserName;
                            data[2]  = newc[0].UserID;
                            data[3]  = newc[0].LiveDepart;
                            data[4]  = newc[0].Contact;
                            data[5]  = newc[0].Position;
                            data[7]  = newc[0].CallStyle;
                            data[8]  = newc[0].Keep5s;
                            data[9]  = newc[0].ValidTime;
                            data[10] = newc[0].ValidCount;
                            data[11] = newc[0].WriteTime;
                            data[12] = newc[0].LostState;
                            data[13] = newc[0].ADID;
                            data[14] = newc[0].ADName;
                            data[15] = newc[0].LostTime;
                            string str1 = null;
                            foreach (var xx in newc[0].ControlFloor)
                            {
                                // str1 += acct.ControlFloor[xx - 1].ToString() + ",";
                                str1 += xx.ToString() + ",";
                            }
                            data[6] = str1;
                            NPOI_OprateExcl.UpdateExcl(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 0, 1, data);
                            NPOI_OprateExcl.UpdatetoExcl(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", 1, 1, data);
                            MessageBox.Show("写卡成功!");
                        }
                    }
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Example #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     NPOI_OprateExcl.ReadExcelFile(System.Windows.Forms.Application.StartupPath + @"\IC_Data.xls", CB_QueryOption.SelectedIndex, DGV_Data, TB_SearchItemData.Text, CB_QuaryItems.SelectedIndex);
 }