Exemple #1
0
        /// <summary>
        /// Saves the Facility Information
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            User user = new User();

            user.LoadByPrimaryKey(MainWindow.LoggedinId);
            if (_hospitalId == 0)
            {
                return;
            }

            if (XtraMessageBox.Show("Are You sure, You want to save the changes to Hospital General Info.?", "Confirmation",
                                    MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            if (user.UserName != "admin")
            {
                XtraMessageBox.Show("You have no privilege to change FE setting!", "Error");
                return;
            }
            switch (Convert.ToInt32(lookUpEdit1.EditValue))
            {
            case 1:
                VisibilitySetting.SetRegistryValue(VisibilitySetting.HANDLE_UNITS_KEY, 1);
                break;

            case 2:
                VisibilitySetting.SetRegistryValue(VisibilitySetting.HANDLE_UNITS_KEY, 2);
                break;

            case 3:
                VisibilitySetting.SetRegistryValue(VisibilitySetting.HANDLE_UNITS_KEY, 3);
                break;
            }


            _hospInfo.LoadByPrimaryKey(_hospitalId);
            _hospInfo.HospitalName = txtHospitalName.Text;

            //_hospInfo.HospitalContact = txtContactPerson.Text;
            _hospInfo.Telephone = txtPhone.Text;
            if (txtUserName.Text.IndexOf(';') != -1 || txtPassword.Text.IndexOf(';') != -1)
            {
                XtraMessageBox.Show("User name or password cannot contain the ';' character!", "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            _hospInfo.Description = txtUserName.Text + ";" + txtPassword.Text;
            //_hospInfo.DSUpdateFrequency = cboDSUpdateFrequency.EditValue.ToString();
            //_hospInfo.RRFStatusUpdateFrequency = cboHCTSUpdateFrequency.EditValue.ToString();
            //_hospInfo.RRFStatusFirstUpdateAfter = cboHCTSFirstUpdate.EditValue.ToString();


            _hospInfo.DSUpdateFrequency         = txtRegionZoneWoreda.Text; //columns doesnt  match
            _hospInfo.RRFStatusUpdateFrequency  = txtmonthstosupply.Text;   ////columns doesnt  match
            _hospInfo.RRFStatusFirstUpdateAfter = txtBirths.Text;           //columns doesnt  match
            _hospInfo.ScmsWSUserName            = txtSurvivingInfants.Text; //columns doesnt  match

            //_hospInfo.NormalFacility = (bool) chkNormal.EditValue;
            //_hospInfo.Region = Convert.ToInt32(cboRegion.SelectedValue);
            //_hospInfo.Woreda = Convert.ToInt32(cboWoreda.SelectedValue);
            //_hospInfo.Zone = Convert.ToInt32(cboZone.SelectedValue);

            if (txtFacilityID.Text != "")
            {
                _hospInfo.FacilityID = Convert.ToInt32(txtFacilityID.EditValue);
                //_hospInfo.ScmsWSUserName = txtmonthstosupply.Text;
                //_hospInfo.ScmsWSPassword = txtBirths.Text;
            }
            if (txtLogo.Text != "")
            {
                try
                {
                    string logo = txtLogo.Text;
                    int    le   = logo.LastIndexOf('\\') + 1;
                    logo = logo.Substring(le, logo.Length - le);
                    string dest = ReadApp.GetValue("logoPath", typeof(string)).ToString();
                    System.IO.File.Copy(txtLogo.Text, dest + logo);
                    _hospInfo.Logo = logo;
                }
                catch { }
            }

            _hospInfo.Save();
            XtraMessageBox.Show("Facility Setting Successfully Saved.", "Success",
                                MessageBoxButtons.OK);


            PopulateFields();
            this.Parent.Parent.Text = _hospInfo.HospitalName + " - Ethiopian Health Commodity Management Information System(HCMS)";
        }