コード例 #1
0
        private void PhValueUpdate(PhysiciansValueTempDBContext db, int ID, int i, double PHabit, double NoOfPat, int rec, bool deleted, double WT)
        {
            //PhysicianValueByLine updatePhVal = (from PhVal_tbl in db.PhysicianValueByLines where PhVal_tbl.Deleted == null && PhVal_tbl.AffiliationID == ID && PhVal_tbl.LineID == i select PhVal_tbl).FirstOrDefault();
            PhysicianValueByLineTemp updatePhVal = new PhysicianValueByLineTemp();

            updatePhVal.AffiliationID      = ID;
            updatePhVal.PrescriptionHappit = PHabit;
            updatePhVal.NoOfPatients       = NoOfPat;
            updatePhVal.RecID       = rec;
            updatePhVal.LineID      = i;
            updatePhVal.Deleted     = deleted;
            updatePhVal.WaitingTime = WT;
            using (SpecialtyPriorityDBContext SVdb = new SpecialtyPriorityDBContext())
            {
                int spcode = int.Parse(txtSpCode.Text);
                var SVData = (from SV_tbl in SVdb.SpecPriorityByLines where SV_tbl.LineID == i && SV_tbl.SpecialtyID == spcode select SV_tbl).FirstOrDefault();
                updatePhVal.SpecialtyValue = SVData.SpecValue / 10;
            }
            updatePhVal.TotalValue = updatePhVal.SpecialtyValue + updatePhVal.PrescriptionHappit + updatePhVal.NoOfPatients;

            if (updatePhVal.TotalValue >= 8)
            {
                updatePhVal.PhysicianClass = "A+";
            }
            if (updatePhVal.TotalValue < 8)
            {
                if (updatePhVal.TotalValue >= 4.5)
                {
                    updatePhVal.PhysicianClass = "A";
                }
                if (updatePhVal.TotalValue < 4.5)
                {
                    updatePhVal.PhysicianClass = "C";
                }
            }
            updatePhVal.LastModifierID       = int.Parse(Session["EmployeeHRCodeFromAdmin"].ToString());
            updatePhVal.LastModificationDate = DateTime.Now;
            updatePhVal.Status = false;
            updatePhVal.New    = false;
            db.PhysicianValueByLineTemps.Add(updatePhVal);
            int roweffected = db.SaveChanges();

            affiliationslblSaveStatus.Text = "Updated";
        }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            using (AffiliationTempDBContext newAff = new AffiliationTempDBContext())
            {
                AffiliationsTemp Aff = new AffiliationsTemp();

                using (PhysicianBDContext PHdb = new PhysicianBDContext())
                {
                    int PhyCode       = int.Parse(txtAffPhyCode.Text);
                    var PhysicianData = (from physicion_tbl in PHdb.Physicians where physicion_tbl.PhysicianID == PhyCode select physicion_tbl).FirstOrDefault();
                    txtAffiliationName.Text = PhysicianData.PhysicianName;
                    txtSpCode.Text          = (PhysicianData.SpecialtyID).ToString();
                }

                Aff.AffiliationName = txtAffiliationName.Text;
                Aff.PhysicianID     = int.Parse(txtAffPhyCode.Text);
                Aff.EntityID        = int.Parse(txtAffClinicCode.Text);
                Aff.BestTimeFrom    = txtBestTimeFrom.Text;
                Aff.BestTimeTo      = txtBestTimeTo.Text;
                Aff.Notes           = txtNotes.Text;
                Aff.New             = true;
                Aff.Status          = false;
                Aff.Deleted         = false;
                Aff.EntryEmployeeID = int.Parse(Session["EmployeeHRCodeFromAdmin"].ToString());
                Aff.EntryDate       = DateTime.Now;

                newAff.AffiliationsTemps.Add(Aff);
                int roweffected = newAff.SaveChanges();
                if (roweffected > 0)
                {
                    affiliationslblSaveStatus.Text = "Saved";
                    using (AffiliationTempDBContext db = new AffiliationTempDBContext())
                    {
                        int maxent = db.AffiliationsTemps.Max(en => en.ID);
                        txtAffID.Text = maxent.ToString();
                    }
                }
                else
                {
                    affiliationslblSaveStatus.Text = "Error";
                }
            }
            using (PhysiciansValueTempDBContext newPhVal = new PhysiciansValueTempDBContext())
            {
                int spcode = int.Parse(txtSpCode.Text);
                PhysicianValueByLineTemp PhyVal = new PhysicianValueByLineTemp();

                for (int i = 1; i <= 7; i++)
                {
                    PhyVal.AffiliationID = int.Parse(txtAffID.Text);
                    PhyVal.LineID        = i;

                    if (i == 1)
                    {
                        PhyVal.PrescriptionHappit = Double.Parse(ddlLine1.SelectedValue);
                        PhyVal.NoOfPatients       = Double.Parse(ddlNoPatients1.SelectedValue);
                        PhyVal.WaitingTime        = Double.Parse(ddlWT1.SelectedValue);
                    }
                    if (i == 2)
                    {
                        PhyVal.PrescriptionHappit = Double.Parse(ddlLine2.SelectedValue);
                        PhyVal.NoOfPatients       = Double.Parse(ddlNoPatients2.SelectedValue);
                        PhyVal.WaitingTime        = Double.Parse(ddlWT2.SelectedValue);
                    }
                    if (i == 3)
                    {
                        PhyVal.PrescriptionHappit = Double.Parse(ddlLine3.SelectedValue);
                        PhyVal.NoOfPatients       = Double.Parse(ddlNoPatients3.SelectedValue);
                        PhyVal.WaitingTime        = Double.Parse(ddlWT3.SelectedValue);
                    }
                    if (i == 4)
                    {
                        PhyVal.PrescriptionHappit = Double.Parse(ddlLine4.SelectedValue);
                        PhyVal.NoOfPatients       = Double.Parse(ddlNoPatients4.SelectedValue);
                        PhyVal.WaitingTime        = Double.Parse(ddlWT4.SelectedValue);
                    }
                    if (i == 5)
                    {
                        PhyVal.PrescriptionHappit = Double.Parse(ddlLine5.SelectedValue);
                        PhyVal.NoOfPatients       = Double.Parse(ddlNoPatients5.SelectedValue);
                        PhyVal.WaitingTime        = Double.Parse(ddlWT5.SelectedValue);
                    }
                    if (i == 6)
                    {
                        PhyVal.PrescriptionHappit = Double.Parse(ddlLine6.SelectedValue);
                        PhyVal.NoOfPatients       = Double.Parse(ddlNoPatients6.SelectedValue);
                        PhyVal.WaitingTime        = Double.Parse(ddlWT6.SelectedValue);
                    }
                    if (i == 7)
                    {
                        PhyVal.PrescriptionHappit = Double.Parse(ddlLine7.SelectedValue);
                        PhyVal.NoOfPatients       = Double.Parse(ddlNoPatients7.SelectedValue);
                        PhyVal.WaitingTime        = Double.Parse(ddlWT7.SelectedValue);
                    }
                    using (SpecialtyPriorityDBContext SVdb = new SpecialtyPriorityDBContext())
                    {
                        var SVData = (from SV_tbl in SVdb.SpecPriorityByLines where SV_tbl.LineID == i && SV_tbl.SpecialtyID == spcode select SV_tbl).FirstOrDefault();
                        PhyVal.SpecialtyValue = SVData.SpecValue / 10;
                    }
                    PhyVal.TotalValue = PhyVal.SpecialtyValue + PhyVal.PrescriptionHappit + PhyVal.NoOfPatients;

                    if (PhyVal.TotalValue >= 8)
                    {
                        PhyVal.PhysicianClass = "A+";
                    }
                    if (PhyVal.TotalValue < 8)
                    {
                        if (PhyVal.TotalValue >= 4.5)
                        {
                            PhyVal.PhysicianClass = "A";
                        }
                        if (PhyVal.TotalValue < 4.5)
                        {
                            PhyVal.PhysicianClass = "C";
                        }
                    }
                    PhyVal.LastModifierID       = int.Parse(Session["EmployeeHRCodeFromAdmin"].ToString());
                    PhyVal.CreateDate           = DateTime.Now;
                    PhyVal.CreatorID            = int.Parse(Session["EmployeeHRCodeFromAdmin"].ToString());
                    PhyVal.LastModificationDate = DateTime.Now;
                    PhyVal.New     = true;
                    PhyVal.Deleted = false;
                    PhyVal.Status  = false;
                    newPhVal.PhysicianValueByLineTemps.Add(PhyVal);
                    int roweffected = newPhVal.SaveChanges();
                    if (roweffected > 0)
                    {
                        affiliationslblSaveStatus.Text = "Saved";
                    }
                    else
                    {
                        affiliationslblSaveStatus.Text = "Error";
                    }
                }
            }
        }