protected void btnUpdate_Click(object sender, EventArgs e) { using (AffiliationTempDBContext db = new AffiliationTempDBContext()) { AffiliationsTemp updateAff = new AffiliationsTemp(); int ID = int.Parse(txtAffID.Text); //Affiliation updateAff = (from Aff_tbl in db.Affiliations where Aff_tbl.Deleted == null && Aff_tbl.AffiliationID == ID select Aff_tbl).FirstOrDefault(); updateAff.AffiliationID = ID; updateAff.AffiliationName = txtAffiliationName.Text; updateAff.PhysicianID = int.Parse(txtAffPhyCode.Text); updateAff.EntityID = int.Parse(txtAffClinicCode.Text); updateAff.BestTimeFrom = txtBestTimeFrom.Text; updateAff.BestTimeTo = txtBestTimeTo.Text; updateAff.Notes = txtNotes.Text; updateAff.EntryEmployeeID = int.Parse(Session["EmployeeHRCodeFromAdmin"].ToString()); updateAff.Deleted = false; updateAff.EntryDate = DateTime.Now; updateAff.Status = false; updateAff.New = false; db.AffiliationsTemps.Add(updateAff); int roweffected = db.SaveChanges(); affiliationslblSaveStatus.Text = "Updated"; } using (PhysiciansValueTempDBContext db = new PhysiciansValueTempDBContext()) { int ID = int.Parse(txtAffID.Text); for (int i = 1; i <= 7; i++) { if (i == 1) { PhValueUpdate(db, ID, i, double.Parse(ddlLine1.SelectedValue), double.Parse(ddlNoPatients1.SelectedValue), int.Parse(txtRecID1.Text), false, double.Parse(ddlWT1.SelectedValue)); } if (i == 2) { PhValueUpdate(db, ID, i, double.Parse(ddlLine2.SelectedValue), double.Parse(ddlNoPatients2.SelectedValue), int.Parse(txtRecID2.Text), false, double.Parse(ddlWT2.SelectedValue)); } if (i == 3) { PhValueUpdate(db, ID, i, double.Parse(ddlLine3.SelectedValue), double.Parse(ddlNoPatients3.SelectedValue), int.Parse(txtRecID3.Text), false, double.Parse(ddlWT3.SelectedValue)); } if (i == 4) { PhValueUpdate(db, ID, i, double.Parse(ddlLine4.SelectedValue), double.Parse(ddlNoPatients4.SelectedValue), int.Parse(txtRecID4.Text), false, double.Parse(ddlWT4.SelectedValue)); } if (i == 5) { PhValueUpdate(db, ID, i, double.Parse(ddlLine5.SelectedValue), double.Parse(ddlNoPatients5.SelectedValue), int.Parse(txtRecID5.Text), false, double.Parse(ddlWT5.SelectedValue)); } if (i == 6) { PhValueUpdate(db, ID, i, double.Parse(ddlLine6.SelectedValue), double.Parse(ddlNoPatients6.SelectedValue), int.Parse(txtRecID6.Text), false, double.Parse(ddlWT6.SelectedValue)); } if (i == 7) { PhValueUpdate(db, ID, i, double.Parse(ddlLine7.SelectedValue), double.Parse(ddlNoPatients7.SelectedValue), int.Parse(txtRecID7.Text), false, double.Parse(ddlWT7.SelectedValue)); } } } txtAffID.Text = ""; txtAffiliationName.Text = ""; txtBestTimeFrom.Text = ""; txtBestTimeTo.Text = ""; txtNotes.Text = ""; txtAffClinicCode.Text = ""; txtAffPhyCode.Text = ""; txtSpCode.Text = ""; ddlNoPatients1.SelectedIndex = 0; ddlNoPatients2.SelectedIndex = 0; ddlNoPatients3.SelectedIndex = 0; ddlNoPatients4.SelectedIndex = 0; ddlNoPatients5.SelectedIndex = 0; ddlNoPatients6.SelectedIndex = 0; ddlNoPatients7.SelectedIndex = 0; ddlLine1.SelectedIndex = 0; ddlLine2.SelectedIndex = 0; ddlLine3.SelectedIndex = 0; ddlLine4.SelectedIndex = 0; ddlLine5.SelectedIndex = 0; ddlLine6.SelectedIndex = 0; ddlLine7.SelectedIndex = 0; ddlWT1.SelectedIndex = 0; ddlWT2.SelectedIndex = 0; ddlWT3.SelectedIndex = 0; ddlWT4.SelectedIndex = 0; ddlWT5.SelectedIndex = 0; ddlWT6.SelectedIndex = 0; ddlWT7.SelectedIndex = 0; btnUpdate.Visible = false; btnSave.Visible = true; }
protected void btnDelete_Click(object sender, EventArgs e) { using (AffiliationTempDBContext db = new AffiliationTempDBContext()) { AffiliationsTemp updateAff = new AffiliationsTemp(); int ID = int.Parse(txtAffID.Text); //Affiliation updateAff = (from Aff_tbl in db.Affiliations where Aff_tbl.Deleted == null && Aff_tbl.AffiliationID == ID select Aff_tbl).FirstOrDefault(); updateAff.AffiliationID = ID; updateAff.AffiliationName = txtAffiliationName.Text; updateAff.PhysicianID = int.Parse(txtAffPhyCode.Text); updateAff.EntityID = int.Parse(txtAffClinicCode.Text); updateAff.BestTimeFrom = txtBestTimeFrom.Text; updateAff.BestTimeTo = txtBestTimeTo.Text; updateAff.Notes = txtNotes.Text; updateAff.Deleted = true; updateAff.EntryDate = DateTime.Now; updateAff.Status = false; updateAff.New = false; updateAff.EntryEmployeeID = int.Parse(Session["EmployeeHRCodeFromAdmin"].ToString()); db.AffiliationsTemps.Add(updateAff); int roweffected = db.SaveChanges(); affiliationslblSaveStatus.Text = "deleted"; } using (PhysiciansValueTempDBContext db = new PhysiciansValueTempDBContext()) { int ID = int.Parse(txtAffID.Text); for (int i = 1; i <= 7; i++) { if (i == 1) { PhValueUpdate(db, ID, i, double.Parse(ddlLine1.SelectedValue), double.Parse(ddlNoPatients1.SelectedValue), int.Parse(txtRecID1.Text), true, double.Parse(ddlWT1.SelectedValue)); } if (i == 2) { PhValueUpdate(db, ID, i, double.Parse(ddlLine2.SelectedValue), double.Parse(ddlNoPatients2.SelectedValue), int.Parse(txtRecID2.Text), true, double.Parse(ddlWT2.SelectedValue)); } if (i == 3) { PhValueUpdate(db, ID, i, double.Parse(ddlLine3.SelectedValue), double.Parse(ddlNoPatients3.SelectedValue), int.Parse(txtRecID3.Text), true, double.Parse(ddlWT3.SelectedValue)); } if (i == 4) { PhValueUpdate(db, ID, i, double.Parse(ddlLine4.SelectedValue), double.Parse(ddlNoPatients4.SelectedValue), int.Parse(txtRecID4.Text), true, double.Parse(ddlWT4.SelectedValue)); } if (i == 5) { PhValueUpdate(db, ID, i, double.Parse(ddlLine5.SelectedValue), double.Parse(ddlNoPatients5.SelectedValue), int.Parse(txtRecID5.Text), true, double.Parse(ddlWT5.SelectedValue)); } if (i == 6) { PhValueUpdate(db, ID, i, double.Parse(ddlLine6.SelectedValue), double.Parse(ddlNoPatients6.SelectedValue), int.Parse(txtRecID6.Text), true, double.Parse(ddlWT6.SelectedValue)); } if (i == 7) { PhValueUpdate(db, ID, i, double.Parse(ddlLine7.SelectedValue), double.Parse(ddlNoPatients7.SelectedValue), int.Parse(txtRecID7.Text), true, double.Parse(ddlWT7.SelectedValue)); } } } txtAffID.Text = ""; txtAffiliationName.Text = ""; txtBestTimeFrom.Text = ""; txtBestTimeTo.Text = ""; txtNotes.Text = ""; txtAffClinicCode.Text = ""; txtAffPhyCode.Text = ""; txtSpCode.Text = ""; ddlNoPatients1.SelectedIndex = 0; ddlNoPatients2.SelectedIndex = 0; ddlNoPatients3.SelectedIndex = 0; ddlNoPatients4.SelectedIndex = 0; ddlNoPatients5.SelectedIndex = 0; ddlNoPatients6.SelectedIndex = 0; ddlNoPatients7.SelectedIndex = 0; ddlLine1.SelectedIndex = 0; ddlLine2.SelectedIndex = 0; ddlLine3.SelectedIndex = 0; ddlLine4.SelectedIndex = 0; ddlLine5.SelectedIndex = 0; ddlLine6.SelectedIndex = 0; ddlLine7.SelectedIndex = 0; ddlWT1.SelectedIndex = 0; ddlWT2.SelectedIndex = 0; ddlWT3.SelectedIndex = 0; ddlWT4.SelectedIndex = 0; ddlWT5.SelectedIndex = 0; ddlWT6.SelectedIndex = 0; ddlWT7.SelectedIndex = 0; btnUpdate.Visible = false; btnSave.Visible = true; affiliationslblSaveStatus.Text = "Deleted"; //int ID = int.Parse(txtAffID.Text); //conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["AmounCrmConnectionString"].ToString()); //conn.Open(); //cmd = new SqlCommand("update Affiliations set Deleted=1 where AffiliationID=" + ID, conn); //int Affrows = cmd.ExecuteNonQuery(); //cmd = new SqlCommand("update PhysicianValueByLine set Deleted=1 where AffiliationID=" + ID, conn); //int PhValrows = cmd.ExecuteNonQuery(); //conn.Close(); //txtAffID.Text = ""; //txtAffiliationName.Text = ""; //txtBestTimeFrom.Text = ""; //txtBestTimeTo.Text = ""; //txtNotes.Text = ""; //txtAffClinicCode.Text = ""; //txtAffPhyCode.Text = ""; //txtSpCode.Text = ""; //ddlNoPatients1.SelectedIndex = 0; //ddlNoPatients2.SelectedIndex = 0; //ddlNoPatients3.SelectedIndex = 0; //ddlNoPatients4.SelectedIndex = 0; //ddlNoPatients5.SelectedIndex = 0; //ddlNoPatients6.SelectedIndex = 0; //ddlNoPatients7.SelectedIndex = 0; //ddlLine1.SelectedIndex = 0; //ddlLine2.SelectedIndex = 0; //ddlLine3.SelectedIndex = 0; //ddlLine4.SelectedIndex = 0; //ddlLine5.SelectedIndex = 0; //ddlLine6.SelectedIndex = 0; //ddlLine7.SelectedIndex = 0; //btnUpdate.Visible = false; //btnSave.Visible = true; //btnDelete.Visible = false; //affiliationslblSaveStatus.Text = "Deleted"; }
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"; } } } }