Beispiel #1
0
        public FrmSiteCat(SiteCategory scategory)
        {
            _scategory = scategory;

            InitializeComponent();

            if (_scategory.Id > 0)
                txtName.Text = _scategory.CategoryName;
        }
Beispiel #2
0
 public static void DeleteSiteCategory(SiteCategory sc)
 {
     DaoFactory.GetDaoFactory().CreateSiteCategoryDao().Delete(sc);
 }
Beispiel #3
0
 public static void SaveOrUpdateSiteCategory(SiteCategory sc)
 {
     DaoFactory.GetDaoFactory().CreateSiteCategoryDao().SaveOrUpdate(sc);
 }
Beispiel #4
0
        public LQTUserMessage SaveOrUpdateObject()
        {
            bool refSite = true;
            bool testDays = true;
            ForlabRegion region = LqtUtil.GetComboBoxValue<ForlabRegion>(comRegion);
            this.Focus();
            if (txtName.Text.Trim() == string.Empty)
                throw new LQTUserException("Site Name must not be empty.");
            if (LqtUtil.GetComboBoxValue<ForlabRegion>(comRegion) == null)
                throw new LQTUserException("A Region must be selected.");
            if (DataRepository.GetSiteByName(txtName.Text.Trim(), LqtUtil.GetComboBoxValue<ForlabRegion>(comRegion).Id) != null &&
                _site.Id <= 0)
                throw new LQTUserException("The Site Name already exists in the region.");
            if (txtworkingdays.Text.Trim() == string.Empty)
                throw new LQTUserException("General Working Days Can not be empty.");
            if (int.Parse(txtworkingdays.Text)>31)
                throw new LQTUserException("General Working Days Can not be greater than 31.");

            if (comsitelevel.Text.Trim() == string.Empty)
                throw new LQTUserException("Site Level Can not be empty.");

            if (comCategory.Text.Trim() == string.Empty)
                throw new LQTUserException("Site Category can not be empty. Please add site category first.");

            string test="";
            string wDays = "";
            bool workDays = false;
            _site.SiteName = txtName.Text.Trim();
            if (txtCd4Td.Text == "")
                txtCd4Td.Text = "0";

            if (int.Parse(txtCd4Td.Text) > int.Parse(txtworkingdays.Text))
            {
                testDays = false;
                test = test + "CD4, ";
            }
            else
                _site.CD4TestingDaysPerMonth = int.Parse(txtCd4Td.Text);
            if (txtChemTd.Text == "")
                txtChemTd.Text = "0";
            if (int.Parse(txtChemTd.Text) > int.Parse(txtworkingdays.Text))
            {
                testDays = false;
                test = test + "Chemistry, ";
            }
            else
                _site.ChemistryTestingDaysPerMonth = int.Parse(txtChemTd.Text);

            if (txthemaTd.Text == "")
                txthemaTd.Text = "0";
            if (int.Parse(txthemaTd.Text) > int.Parse(txtworkingdays.Text))
            {
                testDays = false;
                test = test + "Hematology, ";
            }
            else
            _site.HematologyTestingDaysPerMonth = int.Parse(txthemaTd.Text);
            if (txtViralTd.Text == "")
                txtViralTd.Text = "0";
            if (int.Parse(txtViralTd.Text) > int.Parse(txtworkingdays.Text))
            {
                testDays = false;
                test = test + "Viral Load, ";
            }
            else
            _site.ViralLoadTestingDaysPerMonth = int.Parse(txtViralTd.Text);
            if (txtOtherTd.Text == "")
                txtOtherTd.Text = "0";
            if (int.Parse(txtOtherTd.Text) > int.Parse(txtworkingdays.Text))
            {
                testDays = false;
                test = test + "Other: ";
            }
            else
            _site.OtherTestingDaysPerMonth = int.Parse(txtOtherTd.Text);
            _site.SiteLevel = comsitelevel.Text;

            //if (int.Parse(comCD4RefSite.Tag.ToString()) > 0 && int.Parse(txtCd4Td.Text) <= 0)//jul 5
            //{
            //    wDays = wDays + "CD4, ";
            //    workDays = true;
            //}
            //if (int.Parse(comChemistryRefSite.Tag.ToString()) > 0 && int.Parse(txtChemTd.Text) <= 0)
            //{
            //    wDays = wDays + "Chemistry, ";
            //    workDays = true;
            //}
            //if (int.Parse(comHematologyRefSite.Tag.ToString()) > 0 && int.Parse(txthemaTd.Text) <= 0)
            //{
            //    wDays = wDays + "Hematology, ";
            //    workDays = true;
            //}
            //if (int.Parse(comViralLoadRefSite.Tag.ToString()) > 0 && int.Parse(txtViralTd.Text) <= 0)
            //{
            //    wDays = wDays + "Viral Load, ";
            //    workDays = true;
            //}
            //if (int.Parse(comOtheRefSite.Tag.ToString()) > 0 && int.Parse(txtOtherTd.Text) <= 0)
            //{
            //    wDays = wDays + "Other: ";
            //    workDays = true;
            //}
            _site.CD4RefSite = int.Parse(comCD4RefSite.Tag.ToString());
            _site.ChemistryRefSite = int.Parse(comChemistryRefSite.Tag.ToString());
            _site.HematologyRefSite = int.Parse(comHematologyRefSite.Tag.ToString());
            _site.ViralLoadRefSite = int.Parse(comViralLoadRefSite.Tag.ToString());
            _site.OtherRefSite = int.Parse(comOtheRefSite.Tag.ToString());

            _site.WorkingDays = int.Parse(txtworkingdays.Text);
            //if (workDays)
            //{
            //    throw new LQTUserException(wDays + " Testing days has to be greater than 0.");
            //}
            if (testDays == false)
            {
                throw new LQTUserException(test+ " Testing Days Can't be Greater Than Working Days.");
            }
            if (refSite == false)
            {
                throw new LQTUserException("A Site Can't be Referral Site for Itself.");
            }
            if (_site.Region == null)
                _site.Region = LqtUtil.GetComboBoxValue<ForlabRegion>(comRegion);
            _site.SiteCategory = LqtUtil.GetComboBoxValue<SiteCategory>(comCategory);

            string siteCategory = _site.SiteCategory.CategoryName;//b
            SiteCategory sCatagory;//b
            if (!string.IsNullOrEmpty(siteCategory))//b
            {
                sCatagory = DataRepository.GetSiteCategoryByName(siteCategory);
                if (siteCategory == null)
                {
                    sCatagory = new SiteCategory();
                    sCatagory.CategoryName = siteCategory;
                    DataRepository.SaveOrUpdateSiteCategory(sCatagory);
                }
            }
            if (lsvInstrument.Items.Count > 0)//b
            {
                if (TestDaysCount()!="")
                {
                    throw new LQTUserException(TestDaysCount()+ " Testing days has to be greater than 0");
                }
                //if (WorkingDaysCount() != "")//dec19
                //{
                //    throw new LQTUserException(WorkingDaysCount() + " Testing days has to be 0");
                //}
                if (TestInstrumentPercentage()=="")//b
                {
                    AddDefaultStatus();
                    DataRepository.SaveOrUpdateSite(_site);
                    return new LQTUserMessage("Site was saved or updated successfully.");
                }
                else//b
                    //  return new LQTUserMessage("Site can not be  saved or updated");
                    throw new LQTUserException("The sum of % Tests Run for the " + TestInstrumentPercentage() + " must add up to 100%");

            }
            else
            {
                string workingtestDays = "";
                if (int.Parse(txtCd4Td.Text) > 0 )//&& comCD4RefSite.Tag.ToString() == "0")//add jul 5
                    workingtestDays = workingtestDays + "CD4, ";
                if (int.Parse(txtChemTd.Text) > 0)// && comChemistryRefSite.Tag.ToString() == "0")
                    workingtestDays = workingtestDays + "Chemistry, ";
                if (int.Parse(txthemaTd.Text) > 0)// && comHematologyRefSite.Tag.ToString() == "0")
                    workingtestDays = workingtestDays + "Hematology, ";
                if (int.Parse(txtViralTd.Text) > 0)// && comViralLoadRefSite.Tag.ToString() == "0")
                    workingtestDays = workingtestDays + "Viral Load, ";
                if (int.Parse(txtOtherTd.Text) > 0)// && comOtheRefSite.Tag.ToString() == "0")
                    workingtestDays = workingtestDays + "Other ";
                //if(workingtestDays!="")//dec 19
                //throw new LQTUserException(workingtestDays + " Testing days has to be 0");
                AddDefaultStatus();
                DataRepository.SaveOrUpdateSite(_site);

                return new LQTUserMessage("Site was saved or updated successfully.");
            }
        }
Beispiel #5
0
        private IList<SiteImportData> GetDataRow(DataSet ds)
        {
            string regionName;
            string categoryName;
            string siteName;
            string siteLevel;
            DateTime? openDate;
            string rName = "";
            ForlabRegion region = null;
            string cName = "";
            SiteCategory siteCategory = null;
            int workingDays;

            int Cd4Td;
            int ChemTd;
            int hemaTd;
            int ViralTd;
            int OtherTd;

            int rowno = 0;
            bool haserror;
            IList<SiteImportData> rdlist = new List<SiteImportData>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string errorDescription = "";
                rowno++;
                haserror = false;
                regionName = Convert.ToString(dr[0]).Trim();   //region name
                categoryName = Convert.ToString(dr[1]).Trim();   //site category name
                siteName = Convert.ToString(dr[2]).Trim();   //short name
                siteLevel = Convert.ToString(dr[3]);//Site Level
                try
                {
                    workingDays = int.Parse(Convert.ToString(dr[4]));
                    if (workingDays > 31)
                    {
                        haserror = true;
                        errorDescription = errorDescription + " Working Days Can't Be More Than 31 Days";
                    }
                }
                catch
                {
                    workingDays = 22;
                }
                try
                {
                    Cd4Td = int.Parse(Convert.ToString(dr[5]));
                    if (Cd4Td > 31 || Cd4Td > workingDays)
                    {
                        haserror = true;
                        errorDescription = errorDescription + " CD4 Testing Days Can't Be More Than 31 Days or Working Days";//14 may 14
                    }
                }
                catch
                {
                    Cd4Td = 0;
                }
                try
                {
                    ChemTd = int.Parse(Convert.ToString(dr[6]));
                    if (ChemTd > 31 || ChemTd > workingDays)
                    {
                        haserror = true;
                        errorDescription = errorDescription + " Chemistry Testing Days Can't Be More Than 31 Days or Working Days";
                    }
                }
                catch
                {
                    ChemTd = 0;
                }
                try
                {
                    hemaTd = int.Parse(Convert.ToString(dr[7]));
                    if (hemaTd > 31 || hemaTd > workingDays)
                    {
                        haserror = true;
                        errorDescription = errorDescription + " Hematology Testing Days Can't Be More Than 31 Days or Working Days";
                    }
                }
                catch
                {
                    hemaTd = 0;
                }
                try
                {
                    ViralTd = int.Parse(Convert.ToString(dr[8]));
                    if (ViralTd > 31 || ViralTd > workingDays)
                    {
                        haserror = true;
                        errorDescription = errorDescription + " ViralLoad Testing Days Can't Be More Than 31 Days or Working Days";
                    }
                }
                catch
                {
                    ViralTd = 0;
                }
                try
                {
                    OtherTd = int.Parse(Convert.ToString(dr[9]));
                    if (OtherTd > 31 || OtherTd > workingDays)
                    {
                        haserror = true;
                        errorDescription = errorDescription + " Testing Days Can't Be More Than 31 Days or Working Days";
                    }
                }
                catch
                {
                    OtherTd = 0;
                }

                try
                {
                    openDate = Convert.ToDateTime(dr[10]);
                }
                catch
                {
                    openDate = null;
                }

                SiteImportData rd = new SiteImportData(rowno, regionName, categoryName, siteName, siteLevel, workingDays, Cd4Td, ChemTd, hemaTd, ViralTd, OtherTd, openDate);

                if (rName != regionName)
                {
                    if (!string.IsNullOrEmpty(regionName))
                        region = DataRepository.GetRegionByName(regionName);
                    else
                        region = null;
                    rName = regionName;
                }

                if (region != null)
                {
                    rd.Region = region;
                    if (!String.IsNullOrEmpty(siteName))
                        rd.IsExist = DataRepository.GetSiteByName(siteName, region.Id) != null;
                    else
                        haserror = true;
                }
                else
                    haserror = true;

                if (!string.IsNullOrEmpty(categoryName))
                {
                    siteCategory = DataRepository.GetSiteCategoryByName(categoryName);
                    if (siteCategory == null)
                    {
                        siteCategory = new SiteCategory();
                        siteCategory.CategoryName = categoryName;
                        DataRepository.SaveOrUpdateSiteCategory(siteCategory);
                    }
                }
                else
                    haserror = true;
                cName = categoryName;

                if (siteLevel != "")//14 may 14 null)//b
                {
                    string[] sitelevel = Enum.GetNames(typeof(SiteLevelEnum));
                    string sl = "";
                    bool level = false;
                    for (int i = 0; i < sitelevel.Length; i++)
                    {
                        sl = sitelevel[i].Replace('_', ' ');
                        if (siteLevel == sl)
                        {
                            rd.SiteLevel = siteLevel;
                            level = true;
                            break;
                        }

                    }
                    if (!level)
                    {
                        haserror = true;
                        errorDescription = errorDescription + " Is Not Valid Site Level";
                    }

                }
                else
                    haserror = true;
                rd.Category = siteCategory;
                rd.Cd4Td = Cd4Td;
                rd.ChemTd = ChemTd;
                rd.HemaTd = hemaTd;
                rd.ViralTd = ViralTd;
                rd.OtherTd = OtherTd;

                rd.HasError = haserror;
                rd.ErrorDescription = errorDescription;//14 may 14
                rdlist.Add(rd);

            }

            return rdlist;
        }