Example #1
0
        protected override void ExecItemTAG1()
        {
            DateTime StartTime = DateTime.Now;

            contextMenu.Close();
            string msg = Pub.GetResText(formCode, "Msg001", "");

            RefreshMsg(msg);
            List <string> sql   = new List <string>();
            int           RecNo = Report.DetailGrid.Recordset.RecordNo;

            while (!Report.DetailGrid.Recordset.Eof())
            {
                if (Report.FieldByName("Checked").AsInteger == (int)GRSystemImage.grsi3DChecked)
                {
                    sql.Add(Pub.GetSQL(DBCode.DB_001003, new string[] { "704", GetSysID() }));
                }
                Report.DetailGrid.Recordset.Next();
            }
            Report.DetailGrid.Recordset.MoveTo(RecNo);
            if (sql.Count == 0)
            {
                RefreshMsg("");
                Pub.ShowErrorMsg(Pub.GetResText(formCode, "Error001", ""));
                return;
            }
            if (db.ExecSQL(sql) != 0)
            {
                return;
            }
            db.WriteSYLog(this.Text, CurrentTool, msg);
            ExecItemRefresh();
            msg = string.Format(Pub.GetResText(formCode, "Msg002", ""), sql.Count);
            RefreshMsg(msg + Pub.GetDateDiffTimes(StartTime, DateTime.Now, true), true);
        }
Example #2
0
        private void ExportGridReport(GridppReport report, GRExportType exportType, string Title, string FileName)
        {
            DateTime StartTime = DateTime.Now;
            string   msg       = Pub.GetResText("", "MsgExportingData", "");

            msg = string.Format(msg, Title);
            if (File.Exists(FileName))
            {
                File.Delete(FileName);
            }
            if (report.DetailGrid != null)
            {
                if (report.ColumnByName("CheckBox") != null)
                {
                    report.ColumnByName("CheckBox").Visible = false;
                }
            }
            bool ret = report.ExportDirect(exportType, FileName, true, false);

            if (report.DetailGrid != null)
            {
                if (report.ColumnByName("CheckBox") != null)
                {
                    report.ColumnByName("CheckBox").Visible = true;
                }
            }
            if (!ret)
            {
                return;
            }
            msg = Pub.GetResText("", "MsgExportSuccess", "");
            msg = string.Format(msg, Title);
            RefreshMsg(msg + Pub.GetDateDiffTimes(StartTime, DateTime.Now, true), true);
            Pub.MessageBoxShow(msg, MessageBoxIcon.Information);
        }
Example #3
0
        protected void ExecMacOprt(byte flag, bool IsMac)
        {
            currOprt = CurrentTool;
            bool   state;
            string msg    = "";
            string MacMsg = "";

            if (!InitMacList(IsMac))
            {
                return;
            }
            IsExec = true;
            string tmp = "";

            RefreshForm(false);
            DateTime start = new DateTime();

            start = DateTime.Now;
            string ExecTimes = "";

            txtMag.Text = "";
            for (int i = 0; i < connList.Count; i++)
            {
                TConnInfoFinger conn = connList[i];
                RefreshMsg(currOprt + "[" + conn.MacSN.ToString() + "]......");
                DeviceObject.objFK623.InitConn(conn);
                state     = ExecMacCommand(flag, conn.MacSN, conn.MacType, ref MacMsg);
                ExecTimes = "    " + Pub.GetDateDiffTimes(start, DateTime.Now);
                if (IsMac)
                {
                    if (MacMsg != "")
                    {
                        MacMsg = "[" + MacMsg + "]";
                    }
                    tmp = DeviceObject.objFK623.ErrMsg;
                    SetMacResult(conn.MacSN, state, MacMsg + tmp + ExecTimes);
                    msg = msg + GetMacMsg(conn.MacSN) + ":" + MacMsg + DeviceObject.objFK623.ErrMsg + ";";
                }
                else if (state)
                {
                    SetMacResult(conn.MacSN, state, Pub.GetResText(formCode, "MsgSaveSucceed", "") + ExecTimes);
                    msg = msg + GetMacMsg(conn.MacSN) + ":" + Pub.GetResText(formCode, "MsgSaveSucceed", "") + MacMsg + ";";
                }
                else
                {
                    SetMacResult(conn.MacSN, state, Pub.GetResText(formCode, "MsgSaveFailed", "") + ExecTimes);
                    msg = msg + GetMacMsg(conn.MacSN) + ":" + Pub.GetResText(formCode, "MsgSaveFailed", "") + MacMsg + ";";
                }
                Application.DoEvents();
                start = DateTime.Now;
                if (!IsExec)
                {
                    break;
                }
            }
            db.WriteSYLog(this.Text, currOprt, msg);
            IsExec = false;
            RefreshForm(true);
            RefreshMsg("");
        }
Example #4
0
        protected override void ExecItemRefresh()
        {
            DateTime StartTime = DateTime.Now;

            QuerySQL = Pub.GetSQL(DBCode.DB_000207, new string[] { "0", DepartID, dtpYM.Value.Year.ToString(),
                                                                   dtpYM.Value.Month.ToString() });
            RefreshMsg(StrReading);
            DataTable dt = null;

            if (QuerySQL != "")
            {
                try
                {
                    dt = SystemInfo.db.GetDataTable(QuerySQL);
                }
                catch (Exception E)
                {
                    Pub.ShowErrorMsg(E, QuerySQL);
                }
            }
            ComboBox cbb;

            for (int i = 1; i <= 31; i++)
            {
                cbb = (ComboBox)pnlRight.Controls["cbbDay" + i.ToString("00")];
                if (cbb.Items.Count > 0)
                {
                    cbb.SelectedIndex = 0;
                }
            }
            if (dt != null)
            {
                DateTime d = new DateTime(dtpYM.Value.Year, dtpYM.Value.Month, 1);
                for (int i = 1; i <= 31; i++)
                {
                    cbb = (ComboBox)pnlRight.Controls["cbbDay" + i.ToString("00")];
                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        if (dt.Rows[j]["DepShiftDate"].ToString() == d.AddDays(i - 1).ToString())
                        {
                            for (int k = 0; k < cbb.Items.Count; k++)
                            {
                                if (((TIDAndName)cbb.Items[k]).id == dt.Rows[j]["ShiftNo"].ToString())
                                {
                                    cbb.SelectedIndex = k;
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
            }
            dt.Clear();
            dt.Reset();
            RefreshMsg(StrReadEnd + Pub.GetDateDiffTimes(StartTime, DateTime.Now, true), true);
        }
        private void CalcRecords(string EmpTag, string EmpNo, string DepartTag, string DepartID, string DepartList, string ResultYM)
        {
            progBar.ProgressType = DevComponents.DotNetBar.eProgressItemType.Standard;
            progBar.Value        = 0;
            string        msg       = Pub.GetResText(formCode, "Msg001", "");
            int           empCount  = 0;
            bool          IsError   = false;
            DateTime      StartTime = DateTime.Now;
            List <string> sql       = new List <string>();
            DataTable     dt        = null;

            try
            {
                dt = SystemInfo.db.GetDataTable(Pub.GetSQL(DBCode.DB_000404, new string[] { "5", EmpTag, EmpNo, DepartTag, DepartID, DepartList }));
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    lblMsg.Text = msg + string.Format("{0}/{1}", i + 1, dt.Rows.Count) + "  [" +
                                  dt.Rows[i]["DepartID"].ToString() + "]" + dt.Rows[i]["DepartName"].ToString() + " - [" +
                                  dt.Rows[i]["EmpNo"].ToString() + "]" + dt.Rows[i]["EmpName"].ToString() + "  " +
                                  Pub.GetDateDiffTimes(StartTime, DateTime.Now, true);
                    Application.DoEvents();
                    if (!CalcRecordsData(dt.Rows[i]["EmpNo"].ToString(), dt.Rows[i]["EmpName"].ToString(),
                                         dt.Rows[i]["DepartID"].ToString(), dt.Rows[i]["DepartName"].ToString(), ResultYM))
                    {
                        IsError = true;
                        break;
                    }
                    empCount     += 1;
                    progBar.Value = (i + 1) * 100 / dt.Rows.Count;
                    Application.DoEvents();
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dt != null)
                {
                    dt.Clear();
                    dt.Reset();
                }
                dt = null;
            }
            if (IsError)
            {
                msg = Pub.GetResText(formCode, "Msg003", "");
            }
            else
            {
                msg = Pub.GetResText(formCode, "Msg002", "");
            }
            RefreshMsg(string.Format(msg, empCount, Pub.GetDateDiffTimes(StartTime, DateTime.Now, true)));
        }
Example #6
0
        private void ExecMacOprt()
        {
            bool   state;
            string msg    = "";
            string MacMsg = "";

            if (!InitMacList())
            {
                return;
            }
            IsWorking = true;
            RefresButton();
            DateTime start = new DateTime();

            start = DateTime.Now;
            string      ExecTimes = "";
            TDIConnInfo conn;

            for (int i = 0; i < connList.Count; i++)
            {
                conn = connList[i];
                RefreshMsg(oprt + "[" + conn.MacSN_GPRS.ToString() + "]......", i);
                RefreshMacMsg(oprt + "[" + conn.MacSN_GPRS.ToString() + "]......");
                DeviceObject.objFK623.InitConn(conn);
                if (!DeviceObject.objFK623.IsOpen)
                {
                    DeviceObject.objFK623.Open();
                }
                DeviceObject.objFK623.EnableDevice(0);
                state = DeviceObject.objFK623.IsOpen;
                if (state)
                {
                    state = ExecMacCommand(conn.MacSN_GPRS, ref MacMsg);
                }
                ExecTimes = "    " + Pub.GetDateDiffTimes(start, DateTime.Now);
                if (MacMsg != "")
                {
                    MacMsg = "[" + MacMsg + "]";
                }
                UpdateMacMsg(MacMsg + DeviceObject.objFK623.ErrMsg + ExecTimes, state);
                msg = msg + conn.MacSN_GPRS.ToString() + ":" + MacMsg + DeviceObject.objFK623.ErrMsg + ";";
                DeviceObject.objFK623.EnableDevice(1);
                DeviceObject.objFK623.Close();
                Application.DoEvents();
                start = DateTime.Now;
                if (!IsWorking)
                {
                    break;
                }
            }
            SystemInfo.db.WriteSYLog(this.Text, oprt, msg);
            IsWorking = false;
            RefresButton();
            RefreshMsg("", 0);
        }
Example #7
0
        protected override void ExecItemRefresh()
        {
            DateTime StartTime = DateTime.Now;

            contextMenu.Close();
            int row = -1;

            RefreshMsg(StrReading);
            if (QuerySQL != "")
            {
                try
                {
                    if (!db.IsOpen)
                    {
                        db.Open(SystemInfo.ConnStr);
                    }
                    row = dispView.SelRowNo;
                    //dispView.Report.DetailGrid.Recordset.QuerySQL = QuerySQL;

                    dispView.Stop();
                    dispView.Start();
                    //dispView.Refresh();
                    Application.DoEvents();
                }
                catch (Exception E)
                {
                    Pub.ShowErrorMsg(E, QuerySQL);
                }
                finally
                {
                    if (row < dispView.RowCount)
                    {
                        dispView.SelRowNo = row;
                    }
                    else if (dispView.RowCount > 0)
                    {
                        dispView.SelRowNo = dispView.RowCount - 1;
                    }
                }
            }
            string s = this.Text;

            if (s == "")
            {
                s = Pub.GetResText("Main", "mnu" + formCode, "");
            }
            SetReportTitle(dispView, s);
            RefreshForm(true);
            RefreshMsg(StrReadEnd + Pub.GetDateDiffTimes(StartTime, DateTime.Now, true), true);
        }
Example #8
0
        protected virtual void ExecItemRefresh()
        {
            if ((db == null) || (SystemInfo.ConnStr == ""))
            {
                return;
            }
            DateTime StartTime = DateTime.Now;
            int      row       = -1;

            RefreshMsg(StrReading);
            if (QuerySQL != "")
            {
                try
                {
                    if (bindingSource.DataSource != null)
                    {
                        row = bindingSource.Position;
                    }
                    bindingSource.DataSource = null;
                    if (!db.IsOpen)
                    {
                        db.Open(SystemInfo.ConnStr);
                    }
                    bindingSource.DataSource = db.GetDataTable(QuerySQL);
                }
                catch (Exception E)
                {
                    Pub.ShowErrorMsg(E, QuerySQL);
                }
                finally
                {
                    if ((bindingSource.DataSource != null) && (row >= 0))
                    {
                        if (row < bindingSource.Count)
                        {
                            bindingSource.Position = row;
                        }
                        else if (bindingSource.Count > 0)
                        {
                            bindingSource.Position = bindingSource.Count - 1;
                        }
                    }
                }
            }
            RefreshForm(true);
            RefreshMsg(StrReadEnd + Pub.GetDateDiffTimes(StartTime, DateTime.Now, true), true);
        }
Example #9
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            List <string> sysField = new List <string>();
            List <string> srcField = new List <string>();

            for (int i = 0; i < impGrid.RowCount; i++)
            {
                if ((impGrid[0, i].Value != null) && Pub.ValueToBool(impGrid[0, i].Value))
                {
                    sysField.Add(impGrid[2, i].Value.ToString());
                    if (impGrid[3, i].Value.ToString() == "" || impGrid[3, i].Value == null)
                    {
                        Pub.MessageBoxShow(Pub.GetResText(formCode, "Error003", ""));
                        return;
                    }
                    srcField.Add(impGrid[3, i].Value.ToString());
                }
            }
            if (sysField.Count == 0)
            {
                impGrid.Focus();
                Pub.MessageBoxShow(Pub.GetResText(formCode, "Error003", ""));
                return;
            }
            IsImporting = true;
            DateTime StartTime = DateTime.Now;

            RefreshForm();
            string DepartUpID = "";

            if (txtDepart.Tag != null)
            {
                DepartUpID = txtDepart.Tag.ToString();
            }
            if (DepartUpID == "")
            {
                DepartUpID = SystemInfo.CommanyID;
            }
            int    RecordCount = dtIn.Rows.Count;
            int    RecordFact  = 0;
            string FileName    = SystemInfo.AppPath + "FormDataIn\\" +
                                 DateTime.Now.Date.ToString(SystemInfo.DateFormatLog) + ".txt";
            string Msg = string.Format(Pub.GetResText(formCode, "Msg001", ""), Title);

            progBar.Value = 0;
            label7.Text   = RecordCountString + RecordCount.ToString();
            label8.Text   = RecordIndexString + "0";
            label9.Text   = RecordFactString + RecordFact.ToString();
            Pub.WriteTextFile(FileName, Msg);
            string ErrorMsg = "";
            string NoStr    = Pub.GetResText(formCode, "Msg003", "");

            Application.DoEvents();
            for (int i = 0; i < dtIn.Rows.Count; i++)
            {
                if (!IsImporting)
                {
                    break;
                }
                if (prcImportData(dtIn.Rows[i], sysField, srcField, DepartUpID, ref ErrorMsg))
                {
                    RecordFact = RecordFact + 1;
                }
                progBar.Value = (i + 1) * 100 / RecordCount;
                label7.Text   = RecordCountString + RecordCount.ToString();
                label8.Text   = RecordIndexString + (i + 1).ToString();
                label9.Text   = RecordFactString + RecordFact.ToString();
                if (ErrorMsg != "")
                {
                    Msg = string.Format(NoStr, i + 1) + ErrorMsg;
                    Pub.WriteTextFile(FileName, Msg);
                }
                Application.DoEvents();
            }
            IsImporting = false;
            RefreshForm();
            Msg = string.Format(Pub.GetResText(formCode, "Msg002", ""), Title, label7.Text, label8.Text, label9.Text);
            string ss = Pub.GetDateDiffTimes(StartTime, DateTime.Now);

            Pub.WriteTextFile(FileName, Msg + "    " + ss);
            Pub.MessageBoxShow(Msg + "\r\n\r\n" + ss, MessageBoxIcon.Information);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Example #10
0
        private void ExecMacOprt()
        {
            bool   state;
            string msg    = "";
            string MacMsg = "";

            if (!InitMacList())
            {
                return;
            }
            IsWorking = true;
            RefresButton();
            DateTime start = new DateTime();

            start = DateTime.Now;
            string      ExecTimes = "";
            string      url       = "";
            TDIConnInfo conn;

            for (int i = 0; i < connList.Count; i++)
            {
                conn = connList[i];
                RefreshMsg(oprt + "[" + conn.MacSN.ToString() + "]......", i);
                RefreshMacMsg(oprt + "[" + conn.MacSN.ToString() + "]......");


                SystemInfo.MacSeriesTypeId = 2;
                url = "http://" + conn.NetHost + "/";
                string body         = "";
                string urlTestConnt = "http://" + conn.NetHost + "/action/GetSysParam";
                bool   ret          = DeviceObject.objFK623.POST_GetResponse(urlTestConnt, conn.MacSeriesUserName, conn.SeaSeries_Pwd, ref body);

                if (ret)
                {
                    state = ExecMacCommand(conn.MacSN, url, conn.MacSeriesUserName, conn.SeaSeries_Pwd, ref MacMsg);
                }
                else
                {
                    state = false;
                }

                ExecTimes = "    " + Pub.GetDateDiffTimes(start, DateTime.Now);
                if (MacMsg != "")
                {
                    MacMsg = "[" + MacMsg + "]";
                }
                UpdateMacMsg(MacMsg + DeviceObject.objFK623.SeaBodyStr() + ExecTimes, state);
                msg = msg + conn.MacSN.ToString() + ":" + MacMsg + DeviceObject.objFK623.SeaBodyStr() + ";";

                Application.DoEvents();
                start = DateTime.Now;
                if (!IsWorking)
                {
                    break;
                }
            }
            SystemInfo.db.WriteSYLog(this.Text, oprt, msg);
            IsWorking = false;
            RefresButton();
            RefreshMsg("", 0);
        }
Example #11
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            List <string> sysField = new List <string>();
            List <string> srcField = new List <string>();

            for (int i = 0; i < impGrid.RowCount; i++)
            {
                if ((impGrid[0, i].Value != null) && Pub.ValueToBool(impGrid[0, i].Value))
                {
                    sysField.Add(impGrid[2, i].Value.ToString());
                    srcField.Add(impGrid[3, i].Value.ToString());
                }
            }
            if (sysField.Count == 0)
            {
                impGrid.Focus();
                Pub.ShowErrorMsg(Pub.GetResText(formCode, "Error003", ""));
                return;
            }
            IsImporting = true;
            DateTime StartTime = DateTime.Now;

            RefreshForm();
            string DepartUpSysID = "";

            if (txtDepart.Tag != null)
            {
                DepartUpSysID = txtDepart.Tag.ToString();
            }
            if (DepartUpSysID == "")
            {
                DepartUpSysID = SystemInfo.CommanySysID;
            }
            int    RecordCount = dtIn.Rows.Count;
            int    RecordFact  = 0;
            double SumMoney    = 0;
            string FileName    = SystemInfo.AppPath + "FormDataIn\\" +
                                 DateTime.Now.Date.ToString(SystemInfo.DateFormatLog) + ".txt";
            string Msg = string.Format(Pub.GetResText(formCode, "Msg001", ""), Title);

            progBar.Value = 0;
            label7.Text   = RecordCountString + RecordCount.ToString();
            label8.Text   = RecordIndexString + "0";
            label9.Text   = RecordFactString + RecordFact.ToString();
            if (IsShowCount)
            {
                label9.Text = label9.Text + "(" + SumMoney.ToString(SystemInfo.CurrencySymbol + "0.00") + ")";
            }
            Pub.WriteTextFile(FileName, Msg);
            string ErrorMsg = "";
            string NoStr    = Pub.GetResText(formCode, "Msg003", "");

            Application.DoEvents();

            /*if (dtIn.Rows.Count > 0)
             * {
             * try
             * {
             *  string s = dtIn.Rows[0]["AllowanceFlag"].ToString();
             *  DateTime dFlag = new DateTime();
             *  if (DateTime.TryParse(s, out dFlag))
             *  {
             *    DateTime dt = new DateTime();
             *    byte retCheck = db.CheckAllowanceFlag("", dFlag, ref dt);
             *    if (retCheck == 1)
             *    {
             *      Pub.MessageBoxShow(string.Format(Pub.GetResText("SFAllowanceAdd", "Error101", ""), dt.ToShortDateString()));
             *      return;
             *    }
             *    else if (retCheck == 2)
             *    {
             *      Pub.MessageBoxShow(string.Format(Pub.GetResText("SFAllowanceAdd", "Error102", ""), dt.ToShortDateString()));
             *      return;
             *    }
             *  }
             * }
             * catch
             * {
             * }
             * }*/
            for (int i = 0; i < dtIn.Rows.Count; i++)
            {
                if (!IsImporting)
                {
                    break;
                }
                if (prcImportData(dtIn.Rows[i], sysField, srcField, DepartUpSysID, ref ErrorMsg, ref SumMoney))
                {
                    RecordFact = RecordFact + 1;
                }
                progBar.Value = (i + 1) * 100 / RecordCount;
                label7.Text   = RecordCountString + RecordCount.ToString();
                label8.Text   = RecordIndexString + (i + 1).ToString();
                label9.Text   = RecordFactString + RecordFact.ToString();
                if (IsShowCount)
                {
                    label9.Text = label9.Text + "(" + SumMoney.ToString(SystemInfo.CurrencySymbol + "0.00") + ")";
                }
                if (ErrorMsg != "")
                {
                    Msg = string.Format(NoStr, i + 1) + ErrorMsg;
                    Pub.WriteTextFile(FileName, Msg);
                }
                Application.DoEvents();
            }
            IsImporting = false;
            RefreshForm();
            Msg = string.Format(Pub.GetResText(formCode, "Msg002", ""), Title, label7.Text, label8.Text, label9.Text);
            string ss = Pub.GetDateDiffTimes(StartTime, DateTime.Now);

            Pub.WriteTextFile(FileName, Msg + "    " + ss);
            Pub.MessageBoxShow(Msg + "\r\n\r\n" + ss, MessageBoxIcon.Information);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Example #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (dtpStart.Value > dtpEnd.Value)
            {
                dtpStart.Focus();
                Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorStartDateBegreater", ""));
                return;
            }
            int  week = 0;
            long days = Pub.DateDiff(DateInterval.Day, dtpStart.Value.Date, dtpEnd.Value.Date) + 1;

            if (days > 31)
            {
                Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "Error001", ""), 31));
                return;
            }
            if (cbWeek.Checked)
            {
                week = 1;
                if (days > 7)
                {
                    Pub.MessageBoxShow(string.Format(Pub.GetResText(formCode, "Error001", ""), 7));
                    return;
                }
            }
            if (rbEmp.Checked && (cardGrid.RowCount == 0))
            {
                Pub.MessageBoxShow(Pub.GetResText(formCode, "ErrorSelectEmp", ""));
                return;
            }
            IsWorking = true;
            RefreshControl();
            string    msg       = Pub.GetResText(formCode, "Msg001", "");
            bool      IsError   = false;
            DateTime  StartTime = DateTime.Now;
            DataTable dt        = null;

            label3.Text   = msg;
            progBar.Value = 0;
            string   EmpNo;
            DateTime StartDate = dtpStart.Value.Date;
            DateTime EndDate   = dtpEnd.Value.Date;
            int      empCount  = 0;

            try
            {
                if (SystemInfo.DBType == 0)
                {
                    SystemInfo.objACKQ.PKQ_Temp_KQ_KQData(StartDate, EndDate);
                }

                SystemInfo.db.WriteConfig("KQ", "AllowAdjust", true);
                if (rbAll.Checked)
                {
                    dt = SystemInfo.db.GetDataTable(Pub.GetSQL(DBCode.DB_000213, new string[] { "0" }));
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        label3.Text = msg + string.Format("{0}/{1}", i + 1, dt.Rows.Count) + "  [" +
                                      dt.Rows[i]["DepartID"].ToString() + "]" + dt.Rows[i]["DepartName"].ToString() + " - [" +
                                      dt.Rows[i]["EmpNo"].ToString() + "]" + dt.Rows[i]["EmpName"].ToString() + "  " +
                                      Pub.GetDateDiffTimes(StartTime, DateTime.Now, true);
                        EmpNo = dt.Rows[i]["EmpNo"].ToString();
                        if (!CalcEmpData(EmpNo, StartDate, EndDate, week))
                        {
                            IsError = true;
                            break;
                        }
                        empCount     += 1;
                        progBar.Value = (i + 1) * 100 / dt.Rows.Count;
                        if (!IsWorking)
                        {
                            break;
                        }
                        Application.DoEvents();
                    }
                }
                else
                {
                    DataTable dtGrid = (DataTable)cardGrid.DataSource;
                    for (int i = 0; i < dtGrid.Rows.Count; i++)
                    {
                        label3.Text = msg + string.Format("{0}/{1}", i + 1, cardGrid.RowCount) + "  [" +
                                      dtGrid.Rows[i]["DepartID"].ToString() + "]" + dtGrid.Rows[i]["DepartName"].ToString() + " - [" +
                                      dtGrid.Rows[i]["EmpNo"].ToString() + "]" + dtGrid.Rows[i]["EmpName"].ToString() + "  " +
                                      Pub.GetDateDiffTimes(StartTime, DateTime.Now, true);
                        EmpNo = dtGrid.Rows[i]["EmpNo"].ToString();
                        if (!CalcEmpData(EmpNo, StartDate, EndDate, week))
                        {
                            IsError = true;
                            break;
                        }
                        empCount     += 1;
                        progBar.Value = (i + 1) * 100 / cardGrid.RowCount;
                        if (!IsWorking)
                        {
                            break;
                        }
                        Application.DoEvents();
                    }
                }
                SystemInfo.db.DeleteConfig("KQ", "AllowAdjust");
            }
            catch (Exception E)
            {
                IsError = true;
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dt != null)
                {
                    dt.Clear();
                    dt.Reset();
                }
                dt = null;
            }
            IsWorking = false;
            RefreshControl();
            if (IsError)
            {
                msg = Pub.GetResText(formCode, "Msg003", "");
            }
            else
            {
                msg = Pub.GetResText(formCode, "Msg002", "");
            }
            label3.Text = string.Format(msg, empCount, Pub.GetDateDiffTimes(StartTime, DateTime.Now, true));
        }
Example #13
0
        protected override void ExecItemRefresh()
        {
            DateTime StartTime  = DateTime.Now;
            string   StartDate  = dtpStart.Value.ToString(SystemInfo.SQLDateFMT);
            string   EndDate    = dtpEnd.Value.ToString(SystemInfo.SQLDateFMT);
            string   EmpTag     = "0";
            string   EmpNo      = "";
            string   DepartTag  = "0";
            string   DepartID   = "";
            string   DepartList = "";

            if ((txtEmp.Text.Trim() != "") && (txtEmp.Tag != null))
            {
                EmpNo  = txtEmp.Tag.ToString();
                EmpTag = "1";
            }
            else if (txtEmp.Text.Trim() != "")
            {
                EmpNo = txtEmp.Text.Trim();
            }
            if ((txtDepart.Text.Trim() != "") && (txtDepart.Tag != null))
            {
                DepartID  = txtDepart.Tag.ToString();
                DepartTag = "1";
            }
            else if (txtDepart.Text.Trim() != "")
            {
                DepartID = txtDepart.Text.Trim();
            }
            ReadingShift = true;
            RefreshForm(true);
            if (DepartTag == "1")
            {
                if (DepartID != "")
                {
                    DepartList = db.GetDepartChildID(DepartID);
                }
                if (DepartList == "")
                {
                    DepartList = "''";
                }
            }
            contextMenu.Close();
            RefreshMsg(StrReading);
            if (button1.Checked)
            {
                DataTable dt  = null;
                string    sql = "";
                try
                {
                    if (!db.IsOpen)
                    {
                        db.Open(SystemInfo.ConnStr);
                    }
                    dt = db.GetDataTable(Pub.GetSQL(DBCode.DB_002007, new string[] { "0", OprtInfo.DepartPower, EmpTag, EmpNo, DepartTag, DepartID, DepartList }));
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        sql = Pub.GetSQL(DBCode.DB_002007, new string[] { "1", dt.Rows[i]["EmpSysID"].ToString(), StartDate, EndDate });
                        db.ExecSQL(sql);
                        RefreshMsg(StrReading + string.Format("    {0}/{1}", i + 1, dt.Rows.Count));
                        Application.DoEvents();
                    }
                }
                catch (Exception E)
                {
                    RefreshMsg(StrReading);
                    Pub.ShowErrorMsg(E);
                }
                finally
                {
                    if (dt != null)
                    {
                        dt.Reset();
                        dt.Clear();
                    }
                }
            }
            RefreshMsg(StrReading);
            SetReportDate(dispView, label4.Text + ": " + dtpStart.Value.ToShortDateString() + " - " + dtpStart.Value.ToShortDateString());
            QuerySQL = "";
            string NormalRest   = Pub.GetResText(formCode, "NormalRest", "");
            string TurnsoffRest = Pub.GetResText(formCode, "TurnsoffRest", "");

            if (button1.Checked)
            {
                QuerySQL = Pub.GetSQL(DBCode.DB_002007, new string[] { "2", StartDate, EndDate, EmpTag, EmpNo, DepartTag, DepartID, DepartList, OprtInfo.DepartPower });
            }
            else if (button2.Checked)
            {
                QuerySQL = Pub.GetSQL(DBCode.DB_002007, new string[] { "3", StartDate, EndDate, EmpTag, EmpNo, DepartTag, DepartID, DepartList, OprtInfo.DepartPower });
            }
            else if (button4.Checked)
            {
                QuerySQL = Pub.GetSQL(DBCode.DB_002007, new string[] { "4", StartDate, EndDate, DepartTag, DepartID, DepartList, OprtInfo.DepartPower });
            }
            else if (button6.Checked)
            {
                QuerySQL = Pub.GetSQL(DBCode.DB_002007, new string[] { "5", NormalRest, TurnsoffRest, EmpTag, EmpNo, DepartTag, DepartID, DepartList, OprtInfo.DepartPower });
            }
            else if (button8.Checked)
            {
                QuerySQL = Pub.GetSQL(DBCode.DB_002007, new string[] { "6", NormalRest, TurnsoffRest, DepartTag, DepartID, DepartList, OprtInfo.DepartPower });
            }
            int row = -1;

            if (QuerySQL != "")
            {
                dispView.Report.DetailGrid.Recordset.QuerySQL = QuerySQL;
                try
                {
                    if (!db.IsOpen)
                    {
                        db.Open(SystemInfo.ConnStr);
                    }
                    row = dispView.SelRowNo;
                    dispView.Refresh();
                    Application.DoEvents();
                }
                catch (Exception E)
                {
                    Pub.ShowErrorMsg(E, QuerySQL);
                }
                finally
                {
                    if (row < dispView.RowCount)
                    {
                        dispView.SelRowNo = row;
                    }
                    else if (dispView.RowCount > 0)
                    {
                        dispView.SelRowNo = dispView.RowCount - 1;
                    }
                }
            }
            RefreshMsg(StrReadEnd + Pub.GetDateDiffTimes(StartTime, DateTime.Now, true), true);
            ReadingShift = false;
            RefreshForm(true);
        }
Example #14
0
        /// <summary>
        /// 写入信息
        /// </summary>
        protected override void ExecItemTAG3()
        {
            base.ExecItemTAG3();
            refreshForm(false);
            DateTime StartTime = DateTime.Now;

            RefreshMsg(ItemTAG5.Text);
            byte[] sendData      = new byte[0];
            string info          = "";
            string Category      = "01";
            string CardNo        = "";
            string Varieties     = "01";
            string Money         = "0.00";
            string CategoryName  = "01";
            string VarietiesName = "01";

            isStop    = false;
            infoIndex = 0;
            try
            {
                if (serialPort.IsOpen)
                {
                    string cmdStr = "D1 89 31 06 36 56";
                    sendData = HexStringToByteArray(cmdStr);
                    Thread.Sleep(300);
                    serialPort.Write(sendData, 0, sendData.Length);
                    isHand = true;
                    CardList.Clear();
                    post_GetInfo(false);
                }
                else
                {
                    Pub.MessageBoxShow(Pub.GetResText(formCode, "Error01", ""), MessageBoxIcon.Error);
                }

                if (CardList.Count <= 0)
                {
                    Pub.MessageBoxShow(Pub.GetResText(formCode, "Error08", ""), MessageBoxIcon.Error);
                }
                dtReal.Rows.Clear();
                for (int a = 0; a < CardList.Count; a++)
                {
                    if (isStop)
                    {
                        break;
                    }
                    if (serialPort.IsOpen)
                    {
                        writeReadData = "";
                        CardNo        = CardList[a].ToString();

                        Varieties = cbbVarieties.Tag.ToString();
                        double d = 0;
                        double.TryParse(cbbMoney.Text.Trim(), out d);
                        Money         = d.ToString("#0.00");
                        Category      = cbbCategory.Tag.ToString();
                        CategoryName  = cbbCategory.Text.Trim();
                        VarietiesName = cbbVarieties.Text.Trim();

                        for (int i = 1; i < 3; i++)
                        {
                            if (isStop)
                            {
                                break;
                            }
                            string UID         = getUID(getCardNo(CardNo));
                            string blockNumber = i.ToString("X2");
                            string data        = "";
                            switch (i)
                            {
                            case (int)CardSector.SectorOne:
                                data = Convert.ToInt32(Varieties).ToString("X8");
                                break;

                            case (int)CardSector.SectorTwo:
                                data = Convert.ToInt32(Category).ToString("X8");
                                break;

                            case (int)CardSector.SectorTree:
                                data = 0.ToString("X2") + ((int)(Convert.ToDouble(Money) * 100)).ToString("X6");
                                break;
                            }
                            data = getUID(data);
                            Cmd cmd_buffer = new Cmd();
                            cmd_buffer.Command1 = "06";
                            cmd_buffer.Data1    = getData("23 21 " + UID + " " + blockNumber + " " + data);

                            string tmp = cmd_buffer.Data1.Replace(" ", "");
                            cmd_buffer.Datalen1 = (tmp.Length / 2).ToString("X2");

                            cmd_buffer.Checksum1      = Check_sum(cmd_buffer.Header1.Trim() + " " + cmd_buffer.Command1.Trim() + " " + cmd_buffer.Datalen1.Trim());
                            cmd_buffer.Data_checksum1 = DataCheck_sum(cmd_buffer.Data1.Trim());
                            string mag = cmd_buffer.Buf();
                            sendData = HexStringToByteArray(mag);

                            Thread.Sleep(300);
                            serialPort.Write(sendData, 0, sendData.Length);
                        }
                    }
                    else
                    {
                        Pub.MessageBoxShow(Pub.GetResText(formCode, "Error01", ""), MessageBoxIcon.Error);;
                    }

                    progBar.Value = (a + 1) * 100 / CardList.Count;
                    lblMsg.Text   = ItemTAG5.Text + " " + (a + 1).ToString() + " / " + CardList.Count + " " + CardNo + "[" + CategoryName + "]" + "[" + VarietiesName + "]";
                    Application.DoEvents();
                }
                post_DataReceived(false);
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                RefreshMsg(Pub.GetDateDiffTimes(StartTime, DateTime.Now, true), true);
                refreshForm(true);
            }
            ExecItemTAG2();
            if (!db.IsOpen)
            {
                db.Open(SystemInfo.ConnStr);
            }
            db.WriteSYLog(this.Text, CurrentTool, info);
        }
Example #15
0
        protected void ExecMacOprt(byte flag, byte dataFlag)
        {
            currOprt = CurrentTool;
            TConnInfoNewMJ conn;
            bool           state;
            string         msg     = "";
            string         MacMsg  = "";
            string         SysID   = "";
            bool           IsError = false;

            if (!InitMacList())
            {
                return;
            }
            IsExec = true;
            if (dataFlag == 1)
            {
                upDoorInfo.Clear();
                DataTableReader dr = null;
                try
                {
                    TMJUpDoorInfo doorInfo;
                    AccessV2API.TYPE_DoorBasic upInfo;
                    byte   DoorID;
                    string DoorPassword = "";
                    for (int i = 0; i < connList.Count; i++)
                    {
                        conn  = connList[i];
                        SysID = GetMacSysID(conn.MacSN.ToString());
                        dr    = db.GetDataReader(Pub.GetSQL(DBCode.DB_003001, new string[] { "7", SysID }));
                        while (dr.Read())
                        {
                            doorInfo       = new TMJUpDoorInfo();
                            doorInfo.MacSN = conn.MacSN;
                            byte.TryParse(dr["MacDoorID"].ToString(), out DoorID);
                            doorInfo.DoorID = DoorID;
                            upInfo          = new AccessV2API.TYPE_DoorBasic();
                            UInt32.TryParse(dr["MacDoorDelay"].ToString(), out upInfo.LockedDelay);
                            UInt32.TryParse(dr["MacDoorInterval"].ToString(), out upInfo.Interval);
                            DoorPassword = dr["MacDoorPassword"].ToString();
                            if (DoorPassword.Length >= 16)
                            {
                                upInfo.PasswordA = DoorPassword.Substring(0, 8);
                                upInfo.PasswordB = DoorPassword.Substring(8, 8);
                            }
                            else
                            {
                                upInfo.PasswordA = "00000000";
                                upInfo.PasswordB = "00000000";
                            }
                            doorInfo.DoorInfo = upInfo;
                            upDoorInfo.Add(doorInfo);
                        }
                    }
                }
                catch (Exception E)
                {
                    IsError = true;
                    Pub.ShowErrorMsg(E);
                }
                finally
                {
                    if (dr != null)
                    {
                        dr.Close();
                    }
                    dr = null;
                }
            }
            if (IsError)
            {
                return;
            }
            RefreshForm(false);
            DateTime start = new DateTime();

            start = DateTime.Now;
            string ExecTimes = "";

            for (int i = 0; i < connList.Count; i++)
            {
                conn = connList[i];
                RefreshMsg(currOprt + "[" + conn.MacSN.ToString() + "]......");
                DeviceObject.objMJNew.NewDevice(conn);
                state     = ExecMacCommand(flag, conn.MacSN.ToString(), ref MacMsg);
                ExecTimes = "    " + Pub.GetDateDiffTimes(start, DateTime.Now);
                if (MacMsg != "")
                {
                    MacMsg = "[" + MacMsg + "]";
                }
                SetMacResult(conn.MacSN.ToString(), state, MacMsg + GetErrMsg(state) + ExecTimes);
                msg = msg + GetMacMsg(conn.MacSN.ToString()) + ":" + MacMsg + GetErrMsg(state) + ";";
                Application.DoEvents();
                start = DateTime.Now;
                if (!IsExec)
                {
                    break;
                }
            }
            db.WriteSYLog(this.Text, currOprt, msg);
            IsExec = false;
            RefreshForm(true);
            RefreshMsg("");
        }
Example #16
0
        protected void ExecMacOprt(byte flag, bool IsMac)
        {
            currOprt = CurrentTool;
            QHKS.TConnInfo conn;
            SystemInfo.GetDataCount = 0;
            bool   state;
            string msg    = "";
            string MacMsg = "";

            if (!InitMacList(IsMac))
            {
                return;
            }
            IsExec = true;
            string MacVer = "";
            string tmp    = "";

            RefreshForm(false);
            DateTime start = new DateTime();

            start = DateTime.Now;
            string ExecTimes = "";

            for (int i = 0; i < connList.Count; i++)
            {
                conn = connList[i];
                RefreshMsg(currOprt + "[" + connList[i].MacSN.ToString() + "]......");
                DeviceObject.objKS.Init(ref conn);
                state = true;
                if (IsMac)
                {
                    state = DeviceObject.objKS.SysDeviceInfoGet(ref MacVer);
                    if (MacVer == null)
                    {
                        MacVer = "";
                    }
                    if (state)
                    {
                        DeviceObject.objKS.InitMacVer(MacVer);
                        SyncTime();
                        UpdateIsSupportAirCZ(conn.MacSN, conn.ConnType);
                    }
                }
                if (state)
                {
                    state = ExecMacCommand(flag, connList[i].MacSN, ref MacMsg);
                }
                ExecTimes = "    " + Pub.GetDateDiffTimes(start, DateTime.Now);
                if (IsMac)
                {
                    if (MacMsg != "")
                    {
                        MacMsg = "[" + MacMsg + "]";
                    }
                    tmp = MacVer == "" ? "" : "(" + MacVer + ")";
                    SetMacResult(conn.MacSN, state, MacMsg + DeviceObject.objKS.ErrMsg + tmp + ExecTimes);
                    msg = msg + GetMacMsg(conn.MacSN) + ":" + MacMsg + DeviceObject.objKS.ErrMsg + ";";
                    if (state)
                    {
                        SystemInfo.GetDataCount = SystemInfo.GetDataCount + 1;
                    }
                }
                else if (state)
                {
                    SetMacResult(conn.MacSN, state, Pub.GetResText(formCode, "MsgSaveSucceed", "") + ExecTimes);
                    msg = msg + GetMacMsg(conn.MacSN) + ":" + Pub.GetResText(formCode, "MsgSaveSucceed", "") + MacMsg + ";";
                }
                else
                {
                    SetMacResult(conn.MacSN, state, Pub.GetResText(formCode, "MsgSaveFailed", "") + ExecTimes);
                    msg = msg + GetMacMsg(conn.MacSN) + ":" + Pub.GetResText(formCode, "MsgSaveFailed", "") + MacMsg + ";";
                }
                start = DateTime.Now;
                Application.DoEvents();
                if (!IsExec)
                {
                    break;
                }
            }
            if (SystemInfo.GetDataCount == connList.Count)
            {
                SystemInfo.IsGetData = true;
            }
            db.WriteSYLog(this.Text, currOprt, msg);
            IsExec = false;
            RefreshForm(true);
            RefreshMsg("");
        }
Example #17
0
        protected override void ExecItemRefresh()
        {
            DateTime StartTime = DateTime.Now;

            contextMenu.Close();
            int row = -1;

            RefreshMsg(StrReading);
            if (tabControl1.SelectedIndex == 0)
            {
                if (QuerySQL != "")
                {
                    dispView.Report.DetailGrid.Recordset.QuerySQL = QuerySQL;
                    try
                    {
                        if (!db.IsOpen)
                        {
                            db.Open(SystemInfo.ConnStr);
                        }
                        row = dispView.SelRowNo;
                        dispView.Stop();
                        dispView.Start();
                        Application.DoEvents();
                    }
                    catch (Exception E)
                    {
                        Pub.ShowErrorMsg(E, QuerySQL);
                    }
                    finally
                    {
                        if (row < dispView.RowCount)
                        {
                            dispView.SelRowNo = row;
                        }
                        else if (dispView.RowCount > 0)
                        {
                            dispView.SelRowNo = dispView.RowCount - 1;
                        }
                    }
                }
                SetReportTitle(dispView, tabPage1.Text);
            }
            else
            {
                if (QuerySQL1 != "")
                {
                    dispView1.Report.DetailGrid.Recordset.QuerySQL = QuerySQL1;
                    try
                    {
                        if (!db.IsOpen)
                        {
                            db.Open(SystemInfo.ConnStr);
                        }
                        row = dispView1.SelRowNo;
                        //dispView1.Refresh();
                        dispView1.Stop();
                        dispView1.Start();
                        Application.DoEvents();
                    }
                    catch (Exception E)
                    {
                        Pub.ShowErrorMsg(E, QuerySQL1);
                    }
                    finally
                    {
                        if (row < dispView1.RowCount)
                        {
                            dispView1.SelRowNo = row;
                        }
                        else if (dispView1.RowCount > 0)
                        {
                            dispView1.SelRowNo = dispView1.RowCount - 1;
                        }
                    }
                }
                SetReportTitle(dispView1, tabPage2.Text);
            }
            RefreshForm(true);
            RefreshMsg(StrReadEnd + Pub.GetDateDiffTimes(StartTime, DateTime.Now, true), true);
        }
Example #18
0
        protected void ExecMacDoorOprt(byte flag, byte dataFlag)
        {
            currOprt = CurrentTool;
            TMJDoorInfo doorInfo;

            QHKS.TMJConnInfo connInfo;
            bool             state;
            string           msg    = "";
            string           MacMsg = "";

            if (!InitMacDoorList())
            {
                return;
            }
            IsExec = true;
            RefreshForm(false);
            DateTime start = new DateTime();

            start = DateTime.Now;
            string          ExecTimes = "";
            DataTableReader dr        = null;
            bool            IsError   = false;
            int             index     = 0;

            for (int i = 0; i < doorList.Count; i++)
            {
                doorInfo = doorList[i];
                connInfo = doorInfo.ConnInfo;
                RefreshMsg(currOprt + "[" + connInfo.MacSN + "  " + doorInfo.DoorID + ":" + doorInfo.DoorName + "]......");
                if (dataFlag == 1)
                {
                    doorPasswordList.Clear();
                    try
                    {
                        dr    = db.GetDataReader(Pub.GetSQL(DBCode.DB_003001, new string[] { "104", connInfo.MacSN }));
                        index = 0;
                        while (dr.Read())
                        {
                            string[] pass = dr["MacDoorPassword"].ToString().Split(' ');
                            if (pass.Length == 2)
                            {
                                doorPasswordList.Add(pass[0]);
                                doorPasswordList.Add(pass[1]);
                            }
                            else
                            {
                                doorPasswordList.Add("000000");
                                doorPasswordList.Add("000000");
                            }
                            index += 2;
                        }
                    }
                    catch (Exception E)
                    {
                        IsError = true;
                        Pub.ShowErrorMsg(E);
                    }
                    finally
                    {
                        if (dr != null)
                        {
                            dr.Close();
                        }
                        dr = null;
                    }
                }
                if (IsError)
                {
                    break;
                }
                DeviceObject.objMJ.Init(ref connInfo);
                state     = ExecMacDoorCommand(flag, doorInfo, ref MacMsg);
                ExecTimes = "    " + Pub.GetDateDiffTimes(start, DateTime.Now);
                if (MacMsg != "")
                {
                    MacMsg = "[" + MacMsg + "]";
                }
                SetMacDoorResult(doorInfo.DoorSysID, state, MacMsg + DeviceObject.objMJ.ErrMsg + ExecTimes);
                msg = msg + GetMacDoorMsg(doorInfo) + ":" + MacMsg + DeviceObject.objMJ.ErrMsg + ";";
                Application.DoEvents();
                start = DateTime.Now;
                if (!IsExec)
                {
                    break;
                }
            }
            db.WriteSYLog(this.Text, currOprt, msg);
            IsExec = false;
            RefreshForm(true);
            RefreshMsg("");
        }
Example #19
0
        protected override void ExecItemRefresh()
        {
            DateTime StartTime = DateTime.Now;

            RefreshMsg(StrReading);
            while (tabControl1.TabPages.Count > 0)
            {
                while (tabControl1.TabPages[0].Controls.Count > 0)
                {
                    tabControl1.TabPages[0].Controls[0].Dispose();
                }
                tabControl1.TabPages[0].Dispose();
            }
            tabControl1.TabPages.Clear();
            DataTableReader dr  = null;
            DataTableReader dr1 = null;
            TabPage         page;
            PictureBox      pic;
            MemoryStream    ms;
            int             w;
            int             h;
            int             x = 0;
            int             y = 0;

            try
            {
                if (!db.IsOpen)
                {
                    db.Open(SystemInfo.ConnStr);
                }
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_003007, new string[] { "0" }));
                while (dr.Read())
                {
                    page            = new TabPage();
                    page.Text       = dr["MapName"].ToString();
                    page.Tag        = dr["MapSysID"].ToString();
                    page.AutoScroll = true;
                    page.Name       = "tabPage" + tabControl1.TabPages.Count.ToString();
                    pic             = new PictureBox();
                    pic.Name        = "pic" + tabControl1.TabPages.Count.ToString();
                    pic.SizeMode    = PictureBoxSizeMode.AutoSize;
                    byte[] buff = (byte[])(dr["mapPic"]);
                    if (buff.Length > 0)
                    {
                        ms        = new MemoryStream(buff);
                        pic.Image = Image.FromStream(ms);
                        ms.Dispose();
                    }
                    w            = pic.Width;
                    h            = pic.Height;
                    pic.SizeMode = PictureBoxSizeMode.Zoom;
                    pic.Width    = w;
                    pic.Height   = h;
                    page.Controls.Add(pic);
                    pic.Left = 0;
                    pic.Top  = 0;
                    tabControl1.TabPages.Add(page);
                    dr1 = db.GetDataReader(Pub.GetSQL(DBCode.DB_003007, new string[] { "8", page.Tag.ToString() }));
                    while (dr1.Read())
                    {
                        doorInfo = new TMapDoorInfo(dr1["MacDoorSysID"].ToString(), dr1["MacSN"].ToString(),
                                                    dr1["MacDoorID"].ToString(), dr1["MacDoorName"].ToString());
                        int.TryParse(dr1["LocationX"].ToString(), out x);
                        int.TryParse(dr1["LocationY"].ToString(), out y);
                        doorInfo.X            = x;
                        doorInfo.Y            = y;
                        doorInfo.MacConnType  = dr1["MacConnType"].ToString();
                        doorInfo.MacIPAddress = dr1["MacIPAddress"].ToString();
                        doorInfo.MacPort      = dr1["MacPort"].ToString();
                        doorInfo.MacConnPWD   = dr1["MacConnPWD"].ToString();
                        DrawMapDot(pic, x, y);
                    }
                    dr1.Close();
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
                if (dr1 != null)
                {
                    dr1.Close();
                }
                dr1 = null;
            }
            RefreshForm(true);
            RefreshMsg(StrReadEnd + Pub.GetDateDiffTimes(StartTime, DateTime.Now, true), true);
            picW = new int[tabControl1.TabPages.Count];
            picH = new int[tabControl1.TabPages.Count];
            zoom = new double[tabControl1.TabPages.Count];
            for (int i = 0; i < zoom.Length; i++)
            {
                picW[i] = tabControl1.TabPages[i].Controls[0].Width;
                picH[i] = tabControl1.TabPages[i].Controls[0].Height;
                zoom[i] = 1;
            }
        }
Example #20
0
        protected void ExecMacOprt(byte flag, bool IsMac)
        {
            currOprt = CurrentTool;
            bool   state;
            string msg    = "";
            string MacMsg = "";

            if (!InitMacList(IsMac))
            {
                return;
            }
            IsExec = true;
            string tmp = "";

            RefreshForm(false);
            DateTime start = new DateTime();

            start = DateTime.Now;
            string ExecTimes = "";

            txtMag.Text = "";
            string url = "";

            for (int i = 0; i < connList.Count; i++)
            {
                TConnInfoSEA conn = connList[i];
                if (RegisterInfo.IsValid || RegisterInfo.IsTest)
                {
                    if (RegisterInfo.EndDate < DateTime.Now)
                    {
                        MacMsg = RegisterInfo.StateText;
                        break;
                    }
                }

                url = "http://" + conn.NetIP + "/";
                string body         = "";
                string urlTestConnt = "http://" + conn.NetIP + "/action/GetSysParam";
                bool   ret          = DeviceObject.objFK623.POST_GetResponse(urlTestConnt, conn.NetName, conn.NetPassword, ref body);

                if (ret)
                {
                    state = ExecMacCommand(flag, Convert.ToInt32(conn.MacSN), url, conn.NetName, conn.NetPassword, ref MacMsg);
                }
                else
                {
                    state = false;
                }

                ExecTimes = "    " + Pub.GetDateDiffTimes(start, DateTime.Now);
                if (IsMac)
                {
                    if (MacMsg != "")
                    {
                        MacMsg = "[" + MacMsg + "]";
                    }
                    tmp = DeviceObject.objFK623.SeaBodyStr();
                    SetMacResult(Convert.ToInt32(conn.MacSN), state, MacMsg + tmp + ExecTimes);
                    msg = msg + GetMacMsg(Convert.ToInt32(conn.MacSN)) + ":" + MacMsg + DeviceObject.objFK623.SeaBodyStr() + ";";
                }
                else if (state)
                {
                    SetMacResult(Convert.ToInt32(conn.MacSN), state, Pub.GetResText(formCode, "MsgSaveSucceed", "") + ExecTimes);
                    msg = msg + GetMacMsg(Convert.ToInt32(conn.MacSN)) + ":" + Pub.GetResText(formCode, "MsgSaveSucceed", "") + MacMsg + ";";
                }
                else
                {
                    SetMacResult(Convert.ToInt32(conn.MacSN), state, Pub.GetResText(formCode, "MsgSaveFailed", "") + ExecTimes);
                    msg = msg + GetMacMsg(Convert.ToInt32(conn.MacSN)) + ":" + Pub.GetResText(formCode, "MsgSaveFailed", "") + MacMsg + ";";
                }
                Application.DoEvents();
                start = DateTime.Now;
                if (!IsExec)
                {
                    break;
                }
            }
            db.WriteSYLog(this.Text, currOprt, msg);
            IsExec = false;
            RefreshForm(true);
            RefreshMsg("");
        }