private static string CheckRRFStatus(int rrfID) { GeneralInfo ginfo = new GeneralInfo(); ginfo.LoadAll(); if (ginfo.IsColumnNull("FacilityID")) { XtraMessageBox.Show("The Facility ID was not set, Please correct that and try again."); return "Unknown"; } int facilityID = ginfo.FacilityID; RRF rrf = new RRF(); rrf.LoadByPrimaryKey(rrfID); int startMonth = rrf.FromMonth; //Convert.ToInt32(cboFromMonth.EditValue); int endMonth = rrf.ToMonth; //Convert.ToInt32(cboToMonth.EditValue); //TODO: The Server side RRF reception will also have to handle the From/To Year values. int toYear = rrf.ToYear; //Convert.ToInt32(cboToYear.EditValue); int fromYear = rrf.FromYear; //Convert.ToInt32(cboFromYear.EditValue); RRFService.ServiceSoapClient sc = new RRFService.ServiceSoapClient(); try { string rrfStatus = sc.GetRRFStatus(facilityID, toYear, startMonth, endMonth); //TODO: The service as well needs to handle the From/To year value rrf.LastRRFStatus = rrfStatus; rrf.Save(); return rrfStatus; } catch { XtraMessageBox.Show("There was a network Error, Please connect to the internet and try again.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return "Unknown"; } }
private void GetLastBackupAndSyncDates() { GeneralInfo info = new GeneralInfo(); info.LoadAll(); TimeSpan tt = new TimeSpan(); if (!info.IsColumnNull("LastBackUp")) { string lastBackupDt = info.LastBackUp.ToString("MMM dd,yyyy") + " (" + DateTime.Now.Subtract(info.LastBackUp).Days + " days ago)"; ; lblLastBackupDate.Text = "Last Backup Date: " + lastBackupDt; } if (!info.IsColumnNull("LastSync")) { int days = DateTime.Now.Subtract(info.LastSync).Days; string lastSyncDt; if (days != 0) { lastSyncDt = info.LastSync.ToString("MMM dd,yyyy") + " (" + days + " days ago)"; } else lastSyncDt = info.LastSync.ToString("MMM dd,yyyy") + " (Today)"; lblLastSyncDate.Text = "Last Sync Date: " + lastSyncDt; } }
/// <summary> /// /// </summary> /// <param name="rrfID"></param> private void SendRRF(int rrfID) { // Do the webservice magic here. GeneralInfo ginfo = new GeneralInfo(); ginfo.LoadAll(); chkCalculateInPacks.Checked = false; ChooseGridView(); if (ginfo.IsColumnNull("FacilityID")) { XtraMessageBox.Show("The Facility ID Was not set, Please correct that and try again."); return; } int facilityID = ginfo.FacilityID; int startMonth = Convert.ToInt32(cboFromMonth.EditValue); int endMonth = Convert.ToInt32(cboToMonth.EditValue); //startMonth + 1; int fromYear = Convert.ToInt32(cboFromYear.EditValue); int toYear = Convert.ToInt32(cboToYear.EditValue); bool check; RRFService.ServiceSoapClient sc = new RRFService.ServiceSoapClient(); try { check = sc.RRFExists(facilityID, toYear, startMonth, endMonth); } catch { XtraMessageBox.Show("There was a network Error, Please connect to the internet and try again.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (check) { check = (XtraMessageBox.Show( "Another Report has been submitted for the period you specified, Are you sure you would like to overwrite it?", "Confirm Overwritting", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes); } if (!check) { RRFService.RrfSubmission rsubmission = new RrfSubmission { StartMonth = startMonth, EndMonth = endMonth, Year = toYear, FacilityId = facilityID, FacilityName = ginfo.HospitalName, Items = new List<RRFItem>() }; DataTable dtbl = ((DataView) gridItemChoiceView.DataSource).Table; foreach (DataRow dr in dtbl.Rows) { BLL.Items item = new Items(); item.LoadByPrimaryKey(Convert.ToInt32(dr["ID"])); if (!item.MappingID.HasValue) { continue; } RRFService.RRFItem itm = new RRFService.RRFItem() { ItemID = item.MappingID.Value // Convert.ToInt32(dr["ID"]) , BBalance = Convert.ToInt32(dr["BeginingBalance"]) , EBalance = Convert.ToInt32(dr["SOH"]) , Consumption = Convert.ToInt32(dr["Issued"]) , LossAdjustment = Convert.ToInt32(dr["LossAdj"]) , Max = Convert.ToInt32(dr["Max"]) , Received = Convert.ToInt32(dr["Received"]) , Requested = Convert.ToInt32(dr["Quantity"]) }; rsubmission.Items.Add(itm); } sc = new RRFService.ServiceSoapClient(); try { rsubmission.ReportedBy = ""; if (sc.SubmitRRF(rsubmission)) { XtraMessageBox.Show("The Request has been submitted to PFSA.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); RRF rrf = new RRF(); rrf.LoadByPrimaryKey(rrfID); rrf.DateOfSubmission = DateTime.Now; rrf.LastRRFStatus = CheckRRFStatus(rrf.ID); rrf.Save(); } } catch (Exception ex) { } } }
private void btnLogin_Click(object sender, EventArgs e) { try { //string connectionString = GenerateConnString.GetFromRegistry(); string connectionString = Program.ConnStringManager.GetFromRegistry(); if(string.IsNullOrEmpty(connectionString)) //If the connection string hasn't been set, let's assume that the database is installed in the default location (ApplicationStartUpPath\Database\PharmInventory.mdf) { connectionString = Program.ConnStringManager.GenerateDefaultConnectionString(@".\SQLExpress", @"C:\Databases\FE\PharmInventory.mdf",false); Program.ConnStringManager.SaveToRegistry(connectionString); } MyGeneration.dOOdads.BusinessEntity.RegistryConnectionString = connectionString; User us = new User(); us.GetUserByAccountInfo(txtUsername.Text, txtPassword.Text); if (us.RowCount > 0) { //check for last date of backup and if old just do another one GeneralInfo info = new GeneralInfo(); info.LoadAll(); TimeSpan spanAfterBackup; int daysSinceBackup = -1; if (!info.IsColumnNull("LastBackUp")) { spanAfterBackup = DateTime.Now.Subtract(info.LastBackUp); daysSinceBackup = spanAfterBackup.Days; } if (daysSinceBackup > 7 || daysSinceBackup == -1) { HelperClasses.DatabaseHelpers.AutoBackUp(); } DatabaseHelpers.FixInconsistencies(); //Clean any database inconsistencies //XtraMessageBox.Show("Would you please chose the FE Settings", "Warning"); var mw = new MainWindow {UserId = MainWindow.LoggedinId = us.ID}; UsId = us.ID; mw.Show(); try { HelperClasses.RegistrationHelper.SendAdditionalData("LastLogin", DateTime.Now.ToString()); } catch { } YearEnd yEnd = new YearEnd(); if (yEnd.InventoryRequired(true)) { XtraMessageBox.Show("Inventory information has not been filled for the past fiscal year!", "Inventory Required", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } this.Hide(); } else { XtraMessageBox.Show("Invalid Username or Password!", "Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Stop); txtPassword.Text = ""; txtPassword.Focus(); } } catch { //Tools.GenerateConnString generator = new Tools.GenerateConnString(); //generator.ShowDialog(); Program.ConnStringManager.ShowDialog(); } }