static void FGInventory(IAsyncResult result) { try { FGSyncService client = (FGSyncService)result.AsyncState; if (result.IsCompleted) { long lastSyncId = 0; bool returnResult = false; client.EndUpdateFGDesktop(result, out lastSyncId, out returnResult); if (returnResult) { DBClass db = new DBClass(); db.SaveOptions(Option.LastSyncId, lastSyncId.ToString()); } } } catch (WebException exp) { string msg = string.Empty; if (exp.Status == WebExceptionStatus.ConnectFailure) { msg = "Unable to connect to Dynamics AX. Please contact Network administrator."; } else { msg = exp.Message; } //MessageBox.Show(msg, "Connect Failure [" + AppVariables.DeviceName + "]", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); } catch (Exception exp) { string msg = exp.Message; } }
private void btnDelete_Click(object sender, EventArgs e) { DataRow row = ((DataTable)gridPasswords.DataSource).Rows[gridPasswords.CurrentRowIndex]; if (row != null) { bool result = new DBClass().DeleteUser((int)row["UserId"]); if (result) { MessageBox.Show("User has been deleted successfully.", "Login Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } else { MessageBox.Show("Cannot delete user.", "Login Info", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); } tbUserName.Text = tbPassword.Text = string.Empty; tbUserName.Tag = 0; cmbRole.SelectedIndex = 0; LoadData(); } }
private void menuItemResetData_Click(object sender, EventArgs e) { string msg = string.Empty; this.Refresh(); this.SuspendLayout(); panelWait.Visible = true; this.ResumeLayout(); try { DialogResult dialogRes = MessageBox.Show("Do you want to reset the Data on this device?", "Reset Data [" + AppVariables.DeviceName + "]", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); if (dialogRes == DialogResult.Yes) { DateTime dtStart = DateTime.Now; bool isResume = true; int iCount = 0; FGSyncService client = new FGSyncService(); DBClass db = new DBClass(); //List<WebRefFGSync.PalletEntity> data = client.ResetData().ToList(); //int total = db.ResetDataAll(data); //delete all data from mobile device db.ResetDataAll(); //now add data into device. do { List <InventAvailContract> data = client.GetFGYearInventory(iCount, true).ToList(); if (data.Count.Equals(0)) { isResume = false; } else { iCount = db.InsertDataAll(data); iCount++; } }while (isResume); client.Dispose(); DateTime dtEnd = DateTime.Now; var dateDiff = (dtEnd - dtStart).TotalMinutes; MessageBox.Show("Data has been reset. Total number of rows Imported: " + iCount.ToString() + "\nTime taken (Minutes): " + dateDiff.ToString(), "Reset Data", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); } } catch (WebException exp) { if (exp.Status == WebExceptionStatus.ConnectFailure) { msg = "Unable to connect to Dynamics AX. Please contact Network administrator."; } else { msg = exp.Message; } MessageBox.Show(msg, "Connect Failure [" + AppVariables.DeviceName + "]", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1); } catch (Exception exp) { MessageBox.Show(exp.Message); } finally { panelWait.Visible = false; } }
private void InsertPallet(string palletNum, string location, bool isManualUpdated) { panelFail.SuspendLayout(); panelSuccess.SuspendLayout(); try { Item dr = new Item(); dr.SerialNumber = palletNum; dr.Location = location; dr.IsMatched = true; dr.ProcessByIT = true; dr.DateUpdated = DateTime.Now; dr.UpdatedBy = AppVariables.UpdatedBy; dr.IsManualUpdated = isManualUpdated; dr.DeviceName = System.Net.Dns.GetHostName(); PalletMatch rowsAffected = new DBClass().Search(dr); if (rowsAffected == PalletMatch.Matched) { lbSuccessText.Text = palletNum + " has been matched successfully."; panelSuccess.Visible = true; panelFail.Visible = false; SystemSounds.Beep.Play(); } else if (rowsAffected == PalletMatch.MatchedWrongLocation) { lbFailText.Text = palletNum + " has not been matched but Location is wrong."; panelFail.Visible = true; panelSuccess.Visible = false; SystemSounds.Question.Play(); } else { lbFailText.Text = palletNum + " has not been matched."; panelFail.Visible = true; panelSuccess.Visible = false; SystemSounds.Question.Play(); } PrevSerialNum = palletNum; tbPalletNo.Text = string.Empty; tbPalletNo.Focus(); } catch (System.Data.SqlServerCe.SqlCeException exp) { if (exp.Message.StartsWith("A duplicate value cannot be inserted into a unique index.")) { MessageBox.Show("Serial# already inserted. Cannot insert again.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); palletNum = string.Empty; tbPalletNo.Focus(); } else { MessageBox.Show(exp.Message, "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); } panelSuccess.Visible = false; panelFail.Visible = false; } panelFail.ResumeLayout(); panelSuccess.ResumeLayout(); }