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"; } }
/// <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) { } } }