void lqtToolStrip1_SaveAndNewClick(object sender, EventArgs e) { try { LQTUserMessage msg = SaveOrUpdateObject(); ((LqtMainWindowForm)_mdiparent).ShowStatusBarInfo(msg.Message, _reloadCtr); DataRepository.CloseSession(); ForlabRegion r = _site.Region; SiteCategory sc = _site.SiteCategory; _site = new ForlabSite(); _site.Region = r; _site.SiteCategory = sc; LoadSiteCtr(); _isedited = false; if (_site.SiteCategory != null)//b { comCategory.SelectedValue = _site.SiteCategory.Id; } } catch (Exception ex) { new FrmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog(); } }
private void butDeletesite_Click(object sender, EventArgs e) { if (lsvGroups.SelectedItems.Count > 0 && _error == false) //b { ForlabSite site = this.GetSelectedSite(); if (site != null && MessageBox.Show("Are you sure you want to delete this site?", "Delete Site", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { DataRepository.DeleteSite(site); DataRepository.CloseSession(); //b _region = DataRepository.GetRegionById(site.Region.Id); //b } catch (Exception ex) { _error = true; FrmShowError frm = new FrmShowError(new ExceptionStatus() { message = "Site could not be deleted.", ex = ex }); frm.ShowDialog(); LQTUserMessage msg = SaveOrUpdateObject();//added b this.Close(); } } DisplaySites(); } }
private void SaveSite() { int count = 0; int error = 0; try { foreach (RefSiteImportData rd in _rdata) { if (!rd.IsExist && !rd.HasError) { ForlabSite site = DataRepository.GetSiteByName(rd.SiteName); site.CD4RefSite = rd.CD4RefSiteId; site.ChemistryRefSite = rd.ChemistryRefSiteId; site.HematologyRefSite = rd.HematologyRefSiteId; site.ViralLoadRefSite = rd.ViralLoadRefSiteId; site.OtherRefSite = rd.OtheRefSiteId; count++; DataRepository.SaveOrUpdateSite(site); } else { error++; } } } catch { MessageBox.Show("Error: Unable to import Referral Site data.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { DataRepository.CloseSession(); } }
private int InstrumentUsage(ForlabSite s, ClassOfMorbidityTestEnum platform) { decimal sum = 0; // bool error = false; int removedInst = 0; IList <SiteInstrument> sinst = new List <SiteInstrument>(); if (s.GetInstrumentByPlatform(platform).Count > 0)//instrument percentage { sinst = s.GetInstrumentByPlatform(platform); foreach (SiteInstrument si in sinst) { sum = sum + si.TestRunPercentage; } if (sum != 100) { // error = true; foreach (SiteInstrument si in sinst) { foreach (SiteInstrumentImportData rd in _siteinstrumentdata) { if (rd.InstrumentName == si.Instrument.InstrumentName && rd.SiteName == s.SiteName && !rd.IsExist && !rd.HasError) { s.SiteInstruments.Remove(si); sum = sum + si.TestRunPercentage; removedInst++; } } } } } return(removedInst); }
private void InitializeSiteForm(ForlabSite site) { SiteForm frm = new SiteForm(site, _mdiparent); frm.ShowDialog(); //_rPane.RebindRegion(_region);//b RebindRegion(_region);//added b }
public FrmReferalSite(ForlabSite callingsite, IList <ForlabSite> referingsites, string platform) { _callingSite = callingsite; _referingSites = referingsites; _platform = platform; InitializeComponent(); PopRegion(); }
private void btnOk_Click(object sender, EventArgs e) { _selectedSite = DataRepository.GetSiteById((int)comSite.SelectedValue); this.Tag = _selectedSite.SiteName; this.DialogResult = System.Windows.Forms.DialogResult.OK; // LQT.GUI.UserCtr.SitePane sp= (LQT.GUI.UserCtr.SitePane)this.Parent; Close(); }
public void SetCallingSite(ForlabSite callingSite, string platform) { _callingSite = callingSite; _referingSites = DataRepository.GetReferingSiteByPlatform(platform); //if(platform=="CD4") // _platform = "FlowCytometry"; //else _platform = platform; }
public void SetValue(int Refsiteid) { ForlabSite site = DataRepository.GetSiteById(Refsiteid); if (site != null) { txtsitename.Text = site.SiteName; this.Tag = site.Id; } }
private void butNewsite_Click(object sender, EventArgs e) { if (CreateOrEditSite != null) { ForlabSite site = new ForlabSite(); site.Region = _region; CreateOrUpdateEventArgs eArgs = new CreateOrUpdateEventArgs(site); CreateOrEditSite(this, eArgs); } DisplaySites(); }
public SiteForm(ForlabSite site, Form mdiparent) { this._site = site; this._mdiparent = mdiparent; InitializeComponent(); lqtToolStrip1.SaveAndCloseClick += new EventHandler(lqtToolStrip1_SaveAndCloseClick); lqtToolStrip1.SaveAndNewClick += new EventHandler(lqtToolStrip1_SaveAndNewClick); LoadSiteCtr(); SetRefSites(); }
private void sListView_DoubleClick(object sender, EventArgs e) { if (_sPlatformView.SelectedItems.Count > 0) { ForlabSite site = ((ARTSite)_sPlatformView.SelectedItems[0].Tag).Site; new SiteForm(site, _mdiparent).ShowDialog(); _forecast = null; _artSites = null; MorbidityForm.ReInitMorbidityFrm(ref _forecast, ref _invAssumption, ref _artSites); _behaviorVisted = false; AddSubItemToPlatformView(); } }
public string getValue(int Refsiteid) { ForlabSite site = DataRepository.GetSiteById(Refsiteid); if (site != null) { return(txtsitename.Text); } else { return(null); } }
private void butNewsite_Click(object sender, EventArgs e) { if (CreateOrEditSite != null) { ForlabSite site = new ForlabSite(); site.Region = _region; CreateOrUpdateEventArgs eArgs = new CreateOrUpdateEventArgs(site); CreateOrEditSite(this, eArgs); _region = DataRepository.GetRegionById(site.Region.Id);//b } DisplaySites(); }
private void butSelect_Click(object sender, EventArgs e) { int len = lvSiteAll.SelectedItems.Count; for (int i = 0; i < len; i++) { ForlabSite site = (ForlabSite)lvSiteAll.SelectedItems[i].Tag; SelectedSiteIds.Add(site.Id); SelectedSites.Add(site); } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); }
private void SaveInstrument() { instcount = 0; IList <SiteInstrument> resultin = new List <SiteInstrument>(); result = DataRepository.GetAllSite(); try { foreach (SiteInstrumentImportData rd in _siteinstrumentdata) { if (!rd.IsExist && !rd.HasError) { SiteInstrument sitein = new SiteInstrument(); ForlabSite site = DataRepository.GetSiteByName(rd.SiteName); if (site == null) { rd.HasError = true; } Instrument Inst = DataRepository.GetInstrumentByName(rd.InstrumentName); sitein.Site = site; sitein.Instrument = Inst; sitein.Quantity = rd.Quantity; sitein.TestRunPercentage = rd.PecentRun; // DataRepository.SaveOrUpdateSite(site); foreach (ForlabSite sitei in result) { if (sitei.SiteName == rd.SiteName && !sitei.SiteInstruments.Contains(sitein)) { sitein.Site = sitei; sitei.SiteInstruments.Add(sitein); instcount++; } } } } // SaveAll(); // MessageBox.Show(instcount + " Site Instrument are imported successfully.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Information); // this.DialogResult = System.Windows.Forms.DialogResult.OK; //this.Close(); } catch { MessageBox.Show("Error: Unable to import Site Instrument data.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { // DataRepository.CloseSession(); } }
private void butEditsite_Click(object sender, EventArgs e) { if (lsvGroups.SelectedItems.Count > 0 && _error == false) //b { if (CreateOrEditSite != null) { ForlabSite site = GetSelectedSite(); //b CreateOrUpdateEventArgs eArgs = new CreateOrUpdateEventArgs(site); //(GetSelectedSite());//b CreateOrEditSite(this, eArgs); _region = DataRepository.GetRegionById(site.Region.Id); //b } DisplaySites(); } }
public SitePane(ForlabSite site, bool enableCtr) { this._site = site; this._enableCtr = enableCtr; InitializeComponent(); lsvInstrument.AddNoneEditableColumn(0); lsvInstrument.AddNoneEditableColumn(1); //lsvInstrument.OnSubitemTextChanged += new EventHandler(lsvInstrument_OnSubitemTextChanged); lsvInstrument.SubitemTextChanged += new EventHandler <SubitemTextEventArgs>(lsvInstrument_OnSubitemTextChanged); SetControlState(); PopRegion(); PopSiteCategory(); BindSite(); }
private void butSave_Click(object sender, EventArgs e) { int count = 0; int error = 0; try { foreach (SiteImportData rd in _rdata) { if (!rd.IsExist && !rd.HasError) { ForlabSite site = new ForlabSite(); site.Region = rd.Region; site.SiteName = rd.SiteName; site.SiteLevel = rd.SiteLevel; site.SiteCategory = rd.Category; site.WorkingDays = rd.WorkingDays; site.CD4TestingDaysPerMonth = rd.Cd4Td; site.ChemistryTestingDaysPerMonth = rd.ChemTd; site.HematologyTestingDaysPerMonth = rd.HemaTd; site.ViralLoadTestingDaysPerMonth = rd.ViralTd; site.OtherTestingDaysPerMonth = rd.OtherTd; SiteStatus ss = new SiteStatus(); ss.OpenedFrom = rd.OpeningDate != null ? rd.OpeningDate.Value : DateTime.Now; site.SiteStatuses.Add(ss); count++; DataRepository.SaveOrUpdateSite(site); } else { error++; } } MessageBox.Show(count + " Sites are imported and saved successfully." + Environment.NewLine + error + " Sites Failed.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } catch { MessageBox.Show("Error: Unable to import Site data.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { DataRepository.CloseSession(); } }
public IList <ForlabSite> GetFSite(int fid) { string sql = string.Format("SELECT * FROM Site INNER JOIN ForecastSite ON ForecastSite.SiteId =Site.SiteID" + " WHERE (dbo.ForecastSite.ForecastInfoId ={0})", fid); ISession session = NHibernateHelper.OpenSession(); IList result = session.CreateSQLQuery(sql). AddScalar("SiteID", NHibernateUtil.Int32).List(); IList <ForlabSite> Sites = new List <ForlabSite>(); foreach (int i in result) { ForlabSite s = DataRepository.GetSiteById(i); Sites.Add(s); } return(Sites); }
private void butDeletesite_Click(object sender, EventArgs e) { ForlabSite site = this.GetSelectedSite(); if (site != null && MessageBox.Show("Are you sure you want to delete this site?", "Delete Site", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { DataRepository.DeleteSite(site); } catch (Exception ex) { FrmShowError frm = new FrmShowError(new ExceptionStatus() { message = "Site could not be deleted.", ex = ex }); frm.ShowDialog(); } } DisplaySites(); }
public SiteForm(ForlabSite site, Form mdiparent, bool reloadctr) : this(site, mdiparent) { this._reloadCtr = reloadctr; }
private bool ISValidReferralSite(string Referralsite, string siten, string platform, out ForlabSite refSite) { IList <ForlabSite> _referingSites = new List <ForlabSite>(); IList <ForlabSite> _validsites = new List <ForlabSite>(); refSite = null; bool isvalid = false; if (!String.IsNullOrEmpty(Referralsite)) { refSite = DataRepository.GetSiteByName(Referralsite); if (refSite != null) { if (refSite.SiteName != siten) { _validsites = DataRepository.GetAllSiteByRegionandPlatform(-1, LqtUtil.RemoveWhitespace(platform)); _referingSites = DataRepository.GetReferingSiteByPlatform(LqtUtil.RemoveWhitespace(platform)); if (_validsites.Contains(refSite) && !_referingSites.Contains(refSite)) { isvalid = true; } else { isvalid = false; } } else { isvalid = false; } } else { isvalid = false; } } else { isvalid = false; } return(isvalid); }
private void butSave_Click(object sender, EventArgs e) { int errorcount = 0; ForlabSite refSite = null; ListViewItem li = new ListViewItem(); string siteName; bool error = false; string refsite = ""; int sindex = 0, count = 0; try { foreach (RefSiteImportData rd in _rdata) { siteName = rd.SiteName; li = lvImport.FindItemWithText(rd.SiteName); if (rd.CD4RefSiteId != 0) { if (rd.CD4RefSiteId == -1) { refsite = li.SubItems[2].Text; if (!ISValidReferral(refsite, rd.SiteName, "CD4", out sindex)) { error = true; } else { rd.CD4RefSiteId = sindex; } } else { refSite = DataRepository.GetSiteById(rd.CD4RefSiteId); if (refSite != null) { if (!(ISValidReferralSite(refSite.SiteName, siteName, "CD4", out refSite)) || !(ISValidReferralSite(refSite.SiteName, siteName, "Flow Cytometry", out refSite))) { error = true; } } } sindex = 0; } if (rd.ChemistryRefSiteId != 0) { if (rd.ChemistryRefSiteId == -1) { refsite = li.SubItems[3].Text; if (!ISValidReferral(refsite, rd.SiteName, "Chemistry", out sindex)) { error = true; } else { rd.ChemistryRefSiteId = sindex; } } else { refSite = DataRepository.GetSiteById(rd.ChemistryRefSiteId); if (refSite != null) { if (!ISValidReferralSite(refSite.SiteName, siteName, "Chemistry", out refSite)) { error = true; } } } sindex = 0; } if (rd.HematologyRefSiteId != 0) { if (rd.HematologyRefSiteId == -1) { refsite = li.SubItems[4].Text; if (!ISValidReferral(refsite, rd.SiteName, "Hematology", out sindex)) { error = true; } else { rd.HematologyRefSiteId = sindex; } } else { refSite = DataRepository.GetSiteById(rd.HematologyRefSiteId); if (refSite != null) { if (!ISValidReferralSite(refSite.SiteName, siteName, "Hematology", out refSite)) { error = true; } } } sindex = 0; } if (rd.ViralLoadRefSiteId != 0) { if (rd.ViralLoadRefSiteId == -1) { refsite = li.SubItems[5].Text; if (!ISValidReferral(refsite, rd.SiteName, "ViralLoad", out sindex)) { error = true; } else { rd.ViralLoadRefSiteId = sindex; } } else { refSite = DataRepository.GetSiteById(rd.ViralLoadRefSiteId); if (refSite != null) { if (!ISValidReferralSite(refSite.SiteName, siteName, "ViralLoad", out refSite)) { error = true; } } } sindex = 0; } if (rd.OtheRefSiteId != 0) { if (rd.OtheRefSiteId == -1) { refsite = li.SubItems[6].Text; if (!ISValidReferral(refsite, rd.SiteName, "Other", out sindex)) { error = true; } else { rd.OtheRefSiteId = sindex; } } else { refSite = DataRepository.GetSiteById(rd.OtheRefSiteId); if (refSite != null) { if (!ISValidReferralSite(refSite.SiteName, siteName, "Other", out refSite)) { error = true; } } } sindex = 0; } if (!rd.IsExist && !rd.HasError && !error) { ForlabSite site = DataRepository.GetSiteByName(rd.SiteName, rd.Region.Id); site.CD4RefSite = rd.CD4RefSiteId; site.ChemistryRefSite = rd.ChemistryRefSiteId; site.HematologyRefSite = rd.HematologyRefSiteId; site.ViralLoadRefSite = rd.ViralLoadRefSiteId; site.OtherRefSite = rd.OtheRefSiteId; count++; DataRepository.SaveOrUpdateSite(site); } else { errorcount++; } error = false; } MessageBox.Show(count + " Referral Sites are imported and saved successfully." + Environment.NewLine + errorcount + " Referral Sites Failed.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } catch { MessageBox.Show("Error: Unable to import and save Referral Site data.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { DataRepository.CloseSession(); } }
private void butInSave_Click(object sender, EventArgs e) { SaveInstrument(); ListViewItem li = new ListViewItem(); string siteName; int count = 0, instPercent = 0; foreach (ForlabSite site in result) { siteName = site.SiteName; li = lvImport.FindItemWithText(site.SiteName); if (site.GetInstrumentByPlatform(ClassOfMorbidityTestEnum.CD4).Count > 0) //|| site.GetInstrumentByPlatform(ClassOfMorbidityTestEnum.FlowCytometry).Count > 0) { if (site.CD4TestingDaysPerMonth <= 0) { site.CD4TestingDaysPerMonth = 1; } // if (site.GetInstrumentByPlatform(ClassOfMorbidityTestEnum.CD4).Count > 0) instPercent = InstrumentUsage(site, ClassOfMorbidityTestEnum.CD4); //instrument percentage //else // instPercent = InstrumentUsage(site, ClassOfMorbidityTestEnum.FlowCytometry);//instrument percentage if (instPercent > 0) { count = count + instPercent; instPercent = 0; } } if (site.GetInstrumentByPlatform(ClassOfMorbidityTestEnum.Chemistry).Count > 0) { if (site.ChemistryTestingDaysPerMonth <= 0) { site.ChemistryTestingDaysPerMonth = 1; } instPercent = InstrumentUsage(site, ClassOfMorbidityTestEnum.Chemistry);//instrument percentage if (instPercent > 0) { count = count + instPercent; instPercent = 0; } } if (site.GetInstrumentByPlatform(ClassOfMorbidityTestEnum.Hematology).Count > 0) { if (site.HematologyTestingDaysPerMonth <= 0) { site.HematologyTestingDaysPerMonth = 1; } instPercent = InstrumentUsage(site, ClassOfMorbidityTestEnum.Hematology);//instrument percentage if (instPercent > 0) { count = count + instPercent; instPercent = 0; } } if (site.GetInstrumentByPlatform(ClassOfMorbidityTestEnum.ViralLoad).Count > 0) { if (site.ViralLoadTestingDaysPerMonth <= 0) { site.ViralLoadTestingDaysPerMonth = 1; } instPercent = InstrumentUsage(site, ClassOfMorbidityTestEnum.ViralLoad);//instrument percentage if (instPercent > 0) { count = count + instPercent; instPercent = 0; } } if (site.GetInstrumentByPlatform(ClassOfMorbidityTestEnum.OtherTest).Count > 0) { if (site.OtherTestingDaysPerMonth <= 0) { site.OtherTestingDaysPerMonth = 1; } instPercent = InstrumentUsage(site, ClassOfMorbidityTestEnum.OtherTest);//instrument percentage if (instPercent > 0) { count = count + instPercent; instPercent = 0; } } if (site.Id > siteIndex && sitelist) { site.Id = -1; } DataRepository.SaveOrUpdateSite(site); } totalResult = DataRepository.GetAllSite(); ForlabSite lastsite = DataRepository.GetSiteById(siteIndex); int index = totalResult.IndexOf(lastsite); if (!sitelist) { if (instcount - count > 0) { MessageBox.Show(instcount - count + " Site Instrument are imported and saved successfully.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No Data imported .", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if ((count - sitecount) <= 0) { MessageBox.Show("No Data imported .", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(count - sitecount + " Site Instrument are imported and saved successfully.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Information); } sitelist = false; instcount = 0; this.Close(); }
private void butInImport_Click(object sender, EventArgs e) { bool sitexist = false; int count = 0; if (string.IsNullOrEmpty(txtInFilename.Text.Trim())) { return; } if (!sitelist) { result = DataRepository.GetAllSite(); } if (result.Count > 0) { try { DataSet ds = LqtUtil.ReadExcelFile(txtInFilename.Text, 6); _siteinstrumentdata = GetInDataRow(ds); int[] percentage = new int[_siteinstrumentdata.Count]; bool haserror = false; lvInImport.BeginUpdate(); lvInImport.Items.Clear(); string errorString; foreach (SiteInstrumentImportData rd in _siteinstrumentdata) { string str; errorString = ""; ListViewItem li = new ListViewItem(rd.RowNo.ToString()); li.SubItems.Add(rd.RegionName); foreach (ForlabSite site in result) { if ((site.SiteName.ToLower() == rd.SiteName.ToLower()) && (site.Region.RegionName.ToLower() == rd.RegionName.ToLower())) { sitexist = true; break; } } if (!sitexist) { rd.HasError = true; if (rd.RegionName == "") { errorString = errorString + " Region Doesn't Exist";//14 may 14 } else { errorString = errorString + " Site Doesn't Exist In This Region";//14 may 14 } } sitexist = false; li.SubItems.Add(rd.SiteName); Instrument Inst = DataRepository.GetInstrumentByName(rd.InstrumentName); ForlabRegion Inregion = DataRepository.GetRegionByName(rd.RegionName); ForlabSite s = DataRepository.GetSiteByName(rd.SiteName, Inregion.Id); if (Inst != null) { li.SubItems.Add(Inst.TestingArea.AreaName); } else { haserror = true; rd.HasError = true; errorString = errorString + " Instrument Doesn't Exist"; //14 may 14 li.SubItems.Add(""); //? } count = 0; foreach (ListViewItem Item in lvInImport.Items) { if (Item.SubItems[1].Text.Trim().ToLower() == rd.RegionName.Trim().ToLower() && Item.SubItems[2].Text.Trim().ToLower() == rd.SiteName.Trim().ToLower() && Item.SubItems[4].Text.Trim().ToLower() == rd.InstrumentName.Trim().ToLower()) { rd.IsExist = true; str = "Duplicated"; } //if (rd.TestingArea == Item.SubItems[3].Text) //{ // try // { // percentage[count] = int.Parse(Item.SubItems[6].Text); // count++; // } // catch // { // } //} } //int sum = 0; //for (int i = 0; i < count; i++) //{ // sum = sum + percentage[i]; //} //if ((sum > 100 || sum < 100) && (sum!=0)) // rd.HasError = true; if (Inst != null && s != null) { foreach (SiteInstrument inst in s.SiteInstruments) { if (inst.Instrument == Inst) { rd.IsExist = true; } } } li.SubItems.Add(rd.InstrumentName); li.SubItems.Add(rd.Quantity.ToString()); li.SubItems.Add(rd.PecentRun.ToString()); str = rd.IsExist ? "Yes" : "No"; li.SubItems.Add(str); if (rd.HasError) { li.BackColor = Color.Red; haserror = true; if (rd.RegionName == "") { errorString = errorString + " Region Name Required";//14 may 14 } if (rd.SiteName == "") { errorString = errorString + " Site Name Required"; } if (rd.InstrumentName == "") { errorString = errorString + " Instrument Name Required";//14 may 14 } if (rd.SiteName == "") { errorString = errorString + " Site Name Required"; } } if (rd.IsExist) { li.BackColor = Color.Yellow; } li.SubItems.Add(errorString); lvInImport.Items.Add(li); } sort(); lvInImport.EndUpdate(); //lvInImport.BeginUpdate(); //lvInImport.Items.Clear(); //foreach (SiteInstrumentImportData rd in _siteinstrumentdata) //{ // string str; // ListViewItem li = new ListViewItem(rd.RowNo.ToString()); // li.SubItems.Add(rd.RegionName); // foreach (ForlabSite site in result) // { // if ((site.SiteName == rd.SiteName) && (site.Region.RegionName == rd.RegionName)) // { // sitexist = true; // break; // } // } // if (!sitexist) // rd.HasError = true; // sitexist = false; // li.SubItems.Add(rd.SiteName); // Instrument Inst = DataRepository.GetInstrumentByName(rd.InstrumentName); // ForlabSite s = DataRepository.GetSiteByName(rd.SiteName); // if (Inst != null) // li.SubItems.Add(Inst.TestingArea.AreaName); // else // { // haserror = true; // rd.HasError = true; // li.SubItems.Add(""); // } // count = 0; // foreach (ListViewItem Item in lvInImport.Items) // { // if (Item.SubItems[1].Text == rd.RegionName && Item.SubItems[2].Text == rd.SiteName && Item.SubItems[4].Text == rd.InstrumentName) // { // rd.IsExist = true; // str = "Duplicated"; // } // if (rd.TestingArea == Item.SubItems[3].Text) // { // try // { // percentage[count] = int.Parse(Item.SubItems[6].Text); // count++; // } // catch // { // } // } // } // int sum = 0; // for (int i = 0; i < count; i++) // { // sum = sum + percentage[i]; // } // if ((sum > 100 || sum < 100) && (sum != 0)) // rd.HasError = true; // if (Inst != null && s != null) // { // foreach (SiteInstrument inst in s.SiteInstruments) // { // if (inst.Instrument == Inst) // { // rd.IsExist = true; // } // } // } // li.SubItems.Add(rd.InstrumentName); // li.SubItems.Add(rd.Quantity.ToString()); // li.SubItems.Add(rd.PecentRun.ToString()); // str = rd.IsExist ? "Yes" : "No"; // li.SubItems.Add(str); // if (rd.HasError) // { // li.BackColor = Color.Cyan; // haserror = true; // } // if (rd.IsExist) // { // li.BackColor = Color.Red; // } // lvInImport.Items.Add(li); //} //lvInImport.EndUpdate(); // SaveInstrument(); butInClear.Enabled = true; // if (!haserror)//b jul 9 butInSave.Enabled = true; } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Importing", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Error:Importing", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void SaveOrUpdateSite(ForlabSite site) { DaoFactory.GetDaoFactory().CreateSiteDao().SaveOrUpdate(site); }
public static void DeleteSite(ForlabSite t) { DaoFactory.GetDaoFactory().CreateSiteDao().Delete(t); }
private IList <ReportedData> GetDataRow(DataSet ds) { //ArrayList errorList = new ArrayList(); //int count = 0; //try //{ string regionName; string siteName; string productName; string duration; decimal amount; int stockout; int instrumentDownTime;//b decimal adjusited; int rowno = 0; bool haserror; string rName = ""; string sName = ""; string pName = ""; ForlabRegion region = null; ForlabSite site = null; MasterProduct product = null; IList <ReportedData> rdlist = new List <ReportedData>(); foreach (DataRow dr in ds.Tables[0].Rows) { rowno++; haserror = false; regionName = Convert.ToString(dr[0]); //region name siteName = Convert.ToString(dr[1]); //site name productName = Convert.ToString(dr[2]); //product name duration = Convert.ToString(dr[3]); // reporting period(duration) try { amount = Convert.ToDecimal(dr[4]); //amount } catch { haserror = true; amount = 0; } try { stockout = Convert.ToInt32(dr[5]); //stock out } catch { haserror = true; stockout = 0; } try { instrumentDownTime = Convert.ToInt32(dr[6]); //instrumentDownTime } catch { haserror = true; instrumentDownTime = 0; } try { adjusited = Convert.ToDecimal(dr[7]); //adjusted } catch { haserror = true; adjusited = 0; } ReportedData rd = new ReportedData(rowno, regionName, siteName, productName, duration, amount, stockout, instrumentDownTime); if (rName != regionName) { if (!string.IsNullOrEmpty(regionName)) { region = DataRepository.GetRegionByName(regionName); } else { region = null; } rName = regionName; } if (region != null) { rd.Region = region; if (sName != siteName) { if (!string.IsNullOrEmpty(siteName)) { site = DataRepository.GetSiteByName(siteName, region.Id); } else { site = null; } sName = siteName; } if (site != null) { rd.Site = site; } else { haserror = true; } } else { haserror = true; } if (pName != productName) { if (!string.IsNullOrEmpty(productName)) { product = DataRepository.GetProductByName(productName); } else { product = null; } pName = productName; } if (product != null) { rd.Product = product; } else { haserror = true; } rd.HasError = haserror; rdlist.Add(rd); } //} //catch (Exception ex) //{ // //ShowError(ex.Message); //} return(rdlist); }
public void RebindSite(ForlabSite site) { this._site = site; BindSite(); }