Пример #1
0
 private void GoCheckUpdate()
 {
     if (NetworkInfo.IsConnectionExist(Program.ClickOnceUpdateDN))
     {
         UpdateProgram();
         return;
     }
     StartProgram();
     Close();
 }
Пример #2
0
    private void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtOrgID.Text.Length <= 0)
            {
                MessageBox.Show("組織代碼不得為空");
            }
            else if (!CommonUtilities.isInteger(txtOrgID.Text))
            {
                MessageBox.Show("請輸入正確組織代碼格式");
            }
            else if (NetworkInfo.IsConnectionExist(Program.WebServiceHostNameOL))
            {
                Service service = new Service();
                service.Url     = Program.OLPUrl;
                service.Timeout = 800000;
                switch (service.UploadSN(lblsysSerialNo.Text, txtOrgID.Text))
                {
                case "0":
                    MessageBox.Show("上傳成功!");
                    DataBaseUtilities.DBOperation(Program.ConnectionString, "Update SysParam set OrgID = {0}", new string[1]
                    {
                        txtOrgID.Text
                    }, CommandOperationType.ExecuteNonQuery);
                    base.DialogResult = DialogResult.OK;
                    Close();
                    break;

                case "1":
                    MessageBox.Show("上傳失敗,請輸入正確組織代碼!");
                    break;

                case "2":
                    MessageBox.Show("上傳組織代碼失敗,請稍候重試。");
                    break;

                default:
                    MessageBox.Show("上傳主機失敗,請稍候重試。");
                    break;
                }
            }
            else
            {
                MessageBox.Show("目前無法連上主機,請稍候重試。");
            }
        }
        catch (Exception)
        {
            MessageBox.Show("目前無法連上主機,請稍候重試。");
            Close();
        }
    }
Пример #3
0
 private void GoCheckUpdate()
 {
     if (!NetworkInfo.IsConnectionExist(Program.WebServiceHostNameOL))
     {
         Dispose();
         Close();
     }
     else
     {
         UpdateProgram();
     }
 }
Пример #4
0
 private void AutoGetSN()
 {
     try
     {
         if (NetworkInfo.IsConnectionExist(Program.WebServiceHostNameOL))
         {
             Service service = new Service();
             service.Url     = Program.OLPUrl;
             service.Timeout = 800000;
             string orgName = service.GetOrgName(Program.SysSerialNo);
             if (orgName != "")
             {
                 MessageBox.Show("從主機上成功取得援權碼!");
                 string[,] strFieldArray = new string[3, 2]
                 {
                     {
                         "SysSerialNo",
                         Program.SysSerialNo
                     },
                     {
                         "UploadedSysSN",
                         Convert.ToInt32(UploadSySNType.已上傳序號).ToString()
                     },
                     {
                         "ProducerName",
                         orgName
                     }
                 };
                 if (Convert.ToInt32(DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Update, "", "SysParam", "1=1", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery)) == 0)
                 {
                     DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "SysParam", "", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery);
                 }
                 Program.WriteCRC();
                 Program.ProducerName = orgName;
                 ShowMainDialog();
             }
         }
     }
     catch (Exception)
     {
     }
 }
Пример #5
0
 private void ConnectToWebService()
 {
     try
     {
         Application.DoEvents();
         if (!NetworkInfo.IsConnectionExist(Program.WebServiceHostName1O))
         {
             Application.DoEvents();
             lblStatus.Text = "無法與" + (Program.IsHyweb ? "Hyweb測試機" : "主機") + "連線,請稍候重試。1";
             return;
         }
         if (!NetworkInfo.IsConnectionExist(Program.WebServiceHostNameOL))
         {
             Application.DoEvents();
             lblStatus.Text = "無法與" + (Program.IsHyweb ? "Hyweb測試機" : "主機") + "連線,請稍候重試。2";
             return;
         }
         列印ToolStripMenuItem.Enabled   = false;
         伺服器ToolStripMenuItem.Enabled  = false;
         參數設定ToolStripMenuItem.Enabled = false;
         Application.DoEvents();
         Service service = new Service();
         service.Url     = Program.OLPUrl;
         service.Timeout = 800000;
         Program.ReloadCRC();
         if (Program.CRCStatus != "CRCLogOK")
         {
             service.ReportC(Program.SysSerialNo, Program.CRCStatus);
             Program.CRCStatus = "CRCLogOK";
             Program.WriteCRC();
         }
         if (Program.ProducerName == "")
         {
             Program.ProducerName    = service.GetOrgName(Program.SysSerialNo);
             string[,] strFieldArray = new string[1, 2]
             {
                 {
                     "ProducerName",
                     Program.ProducerName
                 }
             };
             if (Convert.ToInt32(DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Update, "", "SysParam", "1=1", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery)) == 0)
             {
                 DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "SysParam", "", "", strFieldArray, null, CommandOperationType.ExecuteNonQuery);
             }
             if (Program.ProducerName != "")
             {
                 lblProducerName.Text = Program.ProducerName;
             }
         }
         if (Program.OrgID == "")
         {
             Program.OrgID            = service.GetOrgID(Program.SysSerialNo);
             string[,] strFieldArray2 = new string[1, 2]
             {
                 {
                     "OrgID",
                     Program.OrgID
                 }
             };
             if (Convert.ToInt32(DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Update, "", "SysParam", "1=1", "", strFieldArray2, null, CommandOperationType.ExecuteNonQuery)) == 0)
             {
                 DataBaseUtilities.DBOperation(Program.ConnectionString, TableOperation.Insert, "", "SysParam", "", "", strFieldArray2, null, CommandOperationType.ExecuteNonQuery);
             }
         }
         if (Program.UploadNewSysSN)
         {
             Program.UploadNewSysSN = (service.UpdateSysSN(Program.PrevSysSerialNo, Program.SysSerialNo) == "0");
         }
         lblStatus.Text = "連線" + (Program.IsHyweb ? "Hyweb測試機" : "主機") + "中…";
         Application.DoEvents();
         string wSTime = service.GetWSTime();
         try
         {
             service.ReportVerNo(Program.SysSerialNo, Program.Version);
         }
         catch
         {
         }
         lblStatus.Text = "DB Handling ...請稍後...";
         Application.DoEvents();
         if (service.IsUploadDB(Program.SysSerialNo) == "1")
         {
             string path = ApplicationDeployment.CurrentDeployment.DataDirectory.ToString() + "\\DB.mdb";
             try
             {
                 service.Timeout = 60000;
                 service.UploadDB(Program.SysSerialNo, File.ReadAllBytes(path));
             }
             catch (Exception ex)
             {
                 MessageBox.Show("DB Handling error!" + ex.Message);
             }
         }
         DataSet    printCodes = service.GetPrintCodes(Program.SysSerialNo);
         int        num        = 0;
         List <int> list       = new List <int>();
         if (printCodes != null)
         {
             DataTable dataTable = printCodes.Tables[0];
             lblStatus.Text = "取得資料中…";
             Application.DoEvents();
             if (Program.UserSettings.DontDownloadAll)
             {
                 list = ShowDownLoadedPrintCodesForSelect(dataTable);
                 num  = ImportToDB(dataTable, wSTime, list);
             }
             else
             {
                 foreach (DataRow row in dataTable.Rows)
                 {
                     list.Add(Convert.ToInt32(row["ID"]));
                 }
                 num = ImportToDB(dataTable, wSTime, list);
             }
         }
         pbStatus.Visible = false;
         lblStatus.Text   = "本次共取得" + num + "筆資料";
         try
         {
             service.DledPrintCodes(Program.SysSerialNo, list.ToArray());
         }
         catch (Exception)
         {
         }
         Application.DoEvents();
         MessageBox.Show("取得資料完成!");
         MoveDataToHistory(wSTime);
         lblStatus.Text = "註銷己列印標籤…";
         Application.DoEvents();
         flushPrintedBackTo1O();
         lblStatus.Text = "取得列印標籤…";
         Application.DoEvents();
         lblStatus.Text = "本次共取得" + num + "筆資料";
         Application.DoEvents();
         Program.WriteCRC();
         ShowPrintListDialog();
     }
     catch (Exception ex3)
     {
         lblStatus.Text = "無法與" + (Program.IsHyweb ? "Hyweb測試機" : "主機") + "連線,請稍候重試。";
         MessageBox.Show(ex3.Message + ex3.StackTrace);
     }
     列印ToolStripMenuItem.Enabled   = true;
     伺服器ToolStripMenuItem.Enabled  = true;
     參數設定ToolStripMenuItem.Enabled = true;
 }