private AcroFields InputFormFields(Device device, PdfStamper pdfStamper) { AcroFields tmpFields = pdfStamper.AcroFields; string unitPrice = GetUnitPrice(); if (string.IsNullOrEmpty(unitPrice)) { return(null); } tmpFields.SetField("topmostSubform[0].Page1[0].Department[0]", "FCBDD"); // .SetField("topmostSubform[0].Page1[0].Asterisked_items_____must_be_completed_by_the_department[0]", CurrentDevice.strAssetTag) tmpFields.SetField("topmostSubform[0].Page1[0].undefined[0]", device.Serial); tmpFields.SetField("topmostSubform[0].Page1[0].undefined_2[0]", MunisFunctions.GetVendorNameFromPO(device.PO)); tmpFields.SetField("topmostSubform[0].Page1[0].undefined_3[0]", device.Description); //.SetField("topmostSubform[0].Page1[0]._1[0]", "6") // .SetField("topmostSubform[0].Page1[0]._2[0]", "7") tmpFields.SetField("topmostSubform[0].Page1[0].undefined_4[0]", device.PO); tmpFields.SetField("topmostSubform[0].Page1[0].undefined_5[0]", AssetManagerFunctions.GetMunisCodeFromAssetCode(device.Location)); tmpFields.SetField("topmostSubform[0].Page1[0].undefined_6[0]", AttributeFunctions.DepartmentOf(device.Location)); tmpFields.SetField("topmostSubform[0].Page1[0].undefined_7[0]", AssetManagerFunctions.GetMunisCodeFromAssetCode(device.EquipmentType)); tmpFields.SetField("topmostSubform[0].Page1[0].undefined_8[0]", "GP"); //.SetField("topmostSubform[0].Page1[0].undefined_9[0]", "13") tmpFields.SetField("topmostSubform[0].Page1[0].undefined_10[0]", "1"); tmpFields.SetField("topmostSubform[0].Page1[0].undefined_11[0]", unitPrice); tmpFields.SetField("topmostSubform[0].Page1[0].undefined_12[0]", device.PurchaseDate.ToString("MM/dd/yyyy")); tmpFields.SetField("topmostSubform[0].Page1[0].Date[0]", DateTime.Now.ToString("MM/dd/yyyy")); return(tmpFields); }
static void Main() { Logging.Logger("Starting application..."); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += Application_ThreadException; try { // GlobalSwitches.ServerOnline = CanReachServer(); Logging.Logger("Loading attributes..."); AttributeFunctions.PopulateAttributeIndexes(); //Logging.Logger("Caching tables..."); // if (GlobalSwitches.ServerOnline) CacheFunctions.CacheTables(); Logging.Logger("Init Scanning UI..."); var scanUI = new ScanningUI(); Logging.Logger("Init Scanning Controller..."); var scanController = new ScanningController(scanUI); Logging.Logger("Launch UI..."); Application.Run(scanUI); } catch (Exception ex) { Logging.Logger("ERROR: " + ex.ToString()); Console.WriteLine(ex.ToString()); if (ex.InnerException != null) { if (ex.InnerException.Message.Contains("connect")) { OtherFunctions.Message("Cannot connect to server.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "No Connection"); Application.Exit(); } } else { OtherFunctions.Message(ex.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Stop, "Error"); } } }
private void ChangeDatabase(DatabaseName database) { try { if (currentTransaction == null) { if (!GlobalSwitches.CachedMode & ServerInfo.ServerPinging) { if (database != ServerInfo.CurrentDataBase) { var blah = OtherFunctions.Message("Are you sure? This will close all open forms.", MessageBoxButtons.YesNo, MessageBoxIcon.Question, "Change Database", this); if (blah == DialogResult.Yes) { if (this.OkToCloseChildren()) { this.CloseChildren(); ServerInfo.CurrentDataBase = database; AttributeFunctions.PopulateAttributeIndexes(); RefreshCombos(); SecurityTools.PopulateUserAccess(); InitDBControls(); GlobalSwitches.BuildingCache = true; Task.Run(() => DBCacheFunctions.RefreshLocalDBCache()); ShowTestDBWarning(); SetDatabaseTitleText(); ShowAll(); } } } } else { OtherFunctions.Message("Cannot switch database while Offline or in Cached Mode.", MessageBoxButtons.OK, MessageBoxIcon.Information, "Unavailable", this); } } else { OtherFunctions.Message("There is currently an active transaction. Please commit or rollback before switching databases.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Stop"); } } finally { DatabaseToolCombo.SelectedIndex = (int)ServerInfo.CurrentDataBase; } }
public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ThreadException += MyApplication_UnhandledException; bool connectionSuccessful = false; bool cacheAvailable = false; try { NetworkInfo.LocalDomainUser = Environment.UserName; ChildFormControl.SplashScreenInstance().Show(); ProcessCommandArgs(); Logging.Logger("Starting AssetManager..."); Status("Checking Server Connection..."); connectionSuccessful = CheckConnection(); ServerInfo.ServerPinging = connectionSuccessful; Status("Checking Cache State..."); cacheAvailable = DBCacheFunctions.CacheUpToDate(connectionSuccessful); // If connected to DB and cache is out-of-date, rebuild it. if (connectionSuccessful && !cacheAvailable) { Status("Building Cache DB..."); Task.Run(() => { DBCacheFunctions.RefreshLocalDBCache(); }).Wait(); } // No DB connection and cache not ready. Don't run. if (!connectionSuccessful & !cacheAvailable) { OtherFunctions.Message("Could not connect to server and the local DB cache is unavailable. The application will now close.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "No Connection"); Application.Exit(); return; } // No DB connection but cache is ready. Prompt and run. else if (!connectionSuccessful & cacheAvailable) { GlobalSwitches.CachedMode = true; OtherFunctions.Message("Could not connect to server. Running from local DB cache.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Cached Mode"); } // Try to populate access groups and user from DB. Status("Checking Access Level..."); SecurityTools.PopulateAccessGroups(); SecurityTools.PopulateUserAccess(); // Make sure the current user is allowed to run the software. if (!SecurityTools.CanAccess(SecurityGroups.CanRun)) { OtherFunctions.Message("You do not have permission to run this software.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, "Access Denied"); Application.Exit(); return; } Status("Caching Attributes..."); AttributeFunctions.PopulateAttributeIndexes(); Status("Collecting Field Info..."); DBControlExtensions.GetFieldLengths(); Status("Ready!"); Application.Run(new UserInterface.Forms.AssetManagement.MainForm()); } catch (Exception ex) { ErrorHandling.ErrHandle(ex, System.Reflection.MethodBase.GetCurrentMethod()); Application.Exit(); } }
private AcroFields TransferFormFields(Device device, PdfStamper pdfStamper) { AcroFields tmpFields = pdfStamper.AcroFields; using (var newDialog = new Dialog(parentForm)) { newDialog.Text = "Additional Input Required"; ComboBox cmbFrom = new ComboBox(); cmbFrom.FillComboBox(Attributes.DeviceAttributes.Locations); newDialog.AddCustomControl("cmbFromLoc", "Transfer FROM:", (Control)cmbFrom); ComboBox cmbTo = new ComboBox(); cmbTo.FillComboBox(Attributes.DeviceAttributes.Locations); newDialog.AddCustomControl("cmbToLoc", "Transfer TO:", (Control)cmbTo); newDialog.AddLabel("Reason For Transfer-Check One:", true); newDialog.AddCheckBox("chkBetterU", "Better Use of asset:"); newDialog.AddCheckBox("chkTradeIn", "Trade-in or exchange:"); newDialog.AddCheckBox("chkExcess", "Excess assets:"); newDialog.AddCheckBox("chkOther", "Other:"); newDialog.AddRichTextBox("rtbOther", "If Other, Please explain:"); newDialog.ShowDialog(); if (newDialog.DialogResult != DialogResult.OK) { return(null); } string fromLocationCode = cmbFrom.SelectedValue.ToString(); string fromLocDescription = cmbFrom.Text; string toLocationCode = cmbTo.SelectedValue.ToString(); string toLocDescription = cmbTo.Text; tmpFields.SetField("topmostSubform[0].Page1[0].AssetTag_number[0]", device.AssetTag); tmpFields.SetField("topmostSubform[0].Page1[0].Serial_number[0]", device.Serial); tmpFields.SetField("topmostSubform[0].Page1[0].Description_of_asset[0]", device.Description); tmpFields.SetField("topmostSubform[0].Page1[0].Department[0]", AttributeFunctions.DepartmentOf(fromLocationCode)); tmpFields.SetField("topmostSubform[0].Page1[0].Location[0]", fromLocDescription); tmpFields.SetField("topmostSubform[0].Page1[0].Department_2[0]", AttributeFunctions.DepartmentOf(toLocationCode)); tmpFields.SetField("topmostSubform[0].Page1[0].Location_2[0]", toLocDescription); tmpFields.SetField("topmostSubform[0].Page1[0].Better_utilization_of_assets[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkBetterU")))); tmpFields.SetField("topmostSubform[0].Page1[0].Trade-in_or_exchange_with_Other_Departments[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkTradeIn")))); tmpFields.SetField("topmostSubform[0].Page1[0].Excess_assets[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkExcess")))); tmpFields.SetField("topmostSubform[0].Page1[0].undefined[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkOther")))); tmpFields.SetField("topmostSubform[0].Page1[0].Other__Please_explain_1[0]", newDialog.GetControlValue("rtbOther").ToString()); //key //topmostSubform[0].Page1[0].AssetTag_number[0] //topmostSubform[0].Page1[0].Serial_number[0] //topmostSubform[0].Page1[0].Description_of_asset[0] //topmostSubform[0].Page1[0].Department[0] //topmostSubform[0].Page1[0].Location[0] //topmostSubform[0].Page1[0].Department_2[0] //topmostSubform[0].Page1[0].Location_2[0] //topmostSubform[0].Page1[0].Better_utilization_of_assets[0] //topmostSubform[0].Page1[0].Trade-in_or_exchange_with_Other_Departments[0] //topmostSubform[0].Page1[0].Excess_assets[0] //topmostSubform[0].Page1[0].undefined[0] //topmostSubform[0].Page1[0].Other__Please_explain_1[0] //topmostSubform[0].Page1[0].Other__Please_explain_2[0] //topmostSubform[0].Page1[0].Method_of_Delivery_or_Shipping_Please_Check_One[0] //topmostSubform[0].Page1[0].Hand-carried_by[0] //topmostSubform[0].Page1[0].undefined_2[0] //topmostSubform[0].Page1[0].Carrier_company[0] //topmostSubform[0].Page1[0].US_Mail[0] //topmostSubform[0].Page1[0].Shipping_receipt_number[0] //topmostSubform[0].Page1[0].Date_of_shipment_or_transfer[0] //topmostSubform[0].Page1[0].Signature_of_SENDING_official[0] //topmostSubform[0].Page1[0].Department_3[0] //topmostSubform[0].Page1[0].Date[0] //topmostSubform[0].Page1[0].Signature_of_RECEIVING_official[0] //topmostSubform[0].Page1[0].Department_4[0] //topmostSubform[0].Page1[0].Date_2[0] //topmostSubform[0].Page1[0].PrintButton1[0] } return(tmpFields); }
private AcroFields DisposalFormFields(Device device, PdfStamper pdfStamper) { AcroFields tmpFields = pdfStamper.AcroFields; using (var newDialog = new Dialog(parentForm, true)) { newDialog.Text = "Additional Input Required"; #region Section2 newDialog.AddLabel("Reason for asset disposal-please check one:", true); newDialog.AddCheckBox("chkAuction", "Prep for public auction:"); newDialog.AddCheckBox("chkObsolete", "Functional obsolescence:"); newDialog.AddCheckBox("chkTradeIn", "Trade-in or exchange:"); newDialog.AddCheckBox("chkDamaged", "Asset is damaged beyond repair:"); newDialog.AddCheckBox("chkScrap", "Sold as scrap, not at a public sale:"); newDialog.AddCheckBox("chkParts", "Used for parts:"); newDialog.AddCheckBox("chkOther", "Other:"); newDialog.AddRichTextBox("rtbOther", "If Other, Please explain:"); #endregion #region Section3 newDialog.AddLabel("Method of asset disposal-please check one:", true); newDialog.AddCheckBox("chkHand", "Hand carried by:"); newDialog.AddRichTextBox("rtbHand", ""); newDialog.AddCheckBox("chkCarrier", "Carrier company:"); newDialog.AddRichTextBox("rtbCarrier", ""); newDialog.AddCheckBox("chkShipping", "Shipping receipt number:"); newDialog.AddRichTextBox("rtbShipping", ""); newDialog.AddCheckBox("chkDisposed", "Disposed of on premises:"); newDialog.AddRichTextBox("rtbDisposed", ""); newDialog.AddCheckBox("chkOtherMethod", "Other. Please explain:"); newDialog.AddRichTextBox("rtpOtherMethod", ""); #endregion #region Section4 newDialog.AddTextBox("txtSaleAmount", "List the amount of proceeds from the sale of the disposed asset, if any."); newDialog.AddLabel("If the asset item was traded, provide the following information for the asset BEGING ACQUIRED:", true); newDialog.AddTextBox("txtAssetTag", "Asset/Tag Number:"); newDialog.AddTextBox("txtSerial", "Serial Number:"); newDialog.AddTextBox("txtDescription", "Description:"); #endregion newDialog.ShowDialog(); if (newDialog.DialogResult != DialogResult.OK) { return(null); } tmpFields.SetField("topmostSubform[0].Page1[0].AssetTag_number[0]", device.AssetTag); tmpFields.SetField("topmostSubform[0].Page1[0].Mfg_serial_number_1[0]", device.Serial); tmpFields.SetField("topmostSubform[0].Page1[0].Mfg_serial_number_2[0]", device.Description); tmpFields.SetField("topmostSubform[0].Page1[0].Mfg_serial_number_3[0]", AttributeFunctions.DepartmentOf(device.Location)); tmpFields.SetField("topmostSubform[0].Page1[0].County_s_possession[0]", DateTime.Now.ToString("MM/dd/yyyy")); #region Section 2 tmpFields.SetField("topmostSubform[0].Page1[0].Preparation_for_public_auction[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkAuction")))); tmpFields.SetField("topmostSubform[0].Page1[0].Functional_obsolescence[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkObsolete")))); tmpFields.SetField("topmostSubform[0].Page1[0].Trade-in_or_exchange[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkTradeIn")))); tmpFields.SetField("topmostSubform[0].Page1[0].Asset_is_damaged_beyond_repair[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkDamaged")))); tmpFields.SetField("topmostSubform[0].Page1[0].Sold_as_scrap__not_at_a_public_sale[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkScrap")))); tmpFields.SetField("topmostSubform[0].Page1[0].Used_for_parts[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkParts")))); tmpFields.SetField("topmostSubform[0].Page1[0].undefined[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkOther")))); tmpFields.SetField("topmostSubform[0].Page1[0].Other__Please_explain_2[0]", newDialog.GetControlValue("rtbOther").ToString()); #endregion #region Section 3 tmpFields.SetField("topmostSubform[0].Page1[0].Method_of_asset_disposal_please_check_one[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkHand")))); tmpFields.SetField("topmostSubform[0].Page1[0].Hand_carried_by[0]", newDialog.GetControlValue("rtbHand").ToString()); tmpFields.SetField("topmostSubform[0].Page1[0]._1[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkCarrier")))); tmpFields.SetField("topmostSubform[0].Page1[0].Carrier_company[0]", newDialog.GetControlValue("rtbCarrier").ToString()); tmpFields.SetField("topmostSubform[0].Page1[0]._2[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkShipping")))); tmpFields.SetField("topmostSubform[0].Page1[0].Shipping_receipt_number[0]", newDialog.GetControlValue("rtbShipping").ToString()); tmpFields.SetField("topmostSubform[0].Page1[0]._3[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkDisposed")))); tmpFields.SetField("topmostSubform[0].Page1[0].Disposed_of_on_premises[0]", newDialog.GetControlValue("rtbDisposed").ToString()); tmpFields.SetField("topmostSubform[0].Page1[0]._4[0]", CheckValueToString(System.Convert.ToBoolean(newDialog.GetControlValue("chkOtherMethod")))); tmpFields.SetField("topmostSubform[0].Page1[0].Other__Please_explain_3[0]", newDialog.GetControlValue("rtpOtherMethod").ToString()); #endregion #region Section 4 tmpFields.SetField("topmostSubform[0].Page1[0].List_the_amount_of_proceeds_from_the_sale_of_the_disposed_asset__if_any[0]", newDialog.GetControlValue("txtSaleAmount").ToString()); tmpFields.SetField("topmostSubform[0].Page1[0].AssetTag_number_2[0]", newDialog.GetControlValue("txtAssetTag").ToString()); tmpFields.SetField("topmostSubform[0].Page1[0].Serial_number[0]", newDialog.GetControlValue("txtSerial").ToString()); tmpFields.SetField("topmostSubform[0].Page1[0].Description_of_asset[0]", newDialog.GetControlValue("txtDescription").ToString()); tmpFields.SetField("topmostSubform[0].Page1[0].Department_1[0]", AttributeFunctions.DepartmentOf(device.Location)); tmpFields.SetField("topmostSubform[0].Page1[0].Date[0]", DateTime.Now.ToString("MM/dd/yyyy")); #endregion } return(tmpFields); }