private void ClinicSearchTempQuery() { int EntityType = int.Parse(ddlEntityType.SelectedValue); using (EntityTempDBContext db = new EntityTempDBContext()) { if (txtEntityNameSe.Text == "" && ddlEntityType.SelectedIndex != 0) { var clinicdata = from clinic_tbl in db.EntityTemps where (clinic_tbl.Deleted == null || clinic_tbl.Deleted == false) && clinic_tbl.Status == null && clinic_tbl.EntityTypeID == EntityType select clinic_tbl; GridViewClinic.DataSource = clinicdata.ToList(); GridViewClinic.DataBind(); } else if (txtEntityNameSe.Text != "" && ddlEntityType.SelectedIndex != 0) { var clinicdata = from clinic_tbl in db.EntityTemps where (clinic_tbl.Deleted == null || clinic_tbl.Deleted == false) && clinic_tbl.Status == null && clinic_tbl.EntityTypeID == EntityType && clinic_tbl.EntityName.Contains(txtEntityNameSe.Text) select clinic_tbl; GridViewClinic.DataSource = clinicdata.ToList(); GridViewClinic.DataBind(); } else if (txtEntityNameSe.Text != "" && ddlEntityType.SelectedIndex == 0) { var clinicdata = from clinic_tbl in db.EntityTemps where (clinic_tbl.Deleted == null || clinic_tbl.Deleted == false) && clinic_tbl.Status == null && clinic_tbl.EntityName.Contains(txtEntityNameSe.Text) select clinic_tbl; GridViewClinic.DataSource = clinicdata.ToList(); GridViewClinic.DataBind(); } else if (txtEntityCodeSe.Text != "") { int EntCode = int.Parse(txtEntityCodeSe.Text); var clinicdata = from clinic_tbl in db.EntityTemps where (clinic_tbl.Deleted == null || clinic_tbl.Deleted == false) && clinic_tbl.Status == null && clinic_tbl.EntityID == EntCode select clinic_tbl; GridViewClinic.DataSource = clinicdata.ToList(); GridViewClinic.DataBind(); } else { ClinclblSaveStatus.Text = "Please Enter Entity Name or Type to Search"; } //GridViewClinic.Columns[2].Visible = false; //GridViewClinic.Columns[3].Visible = false; } }
protected void btnUpdate_Click(object sender, EventArgs e) { //ClinclblSaveStatus.Text = SelectedClinc.ToString(); if (txtEntityName.Text == "") { ClinclblSaveStatus.Text = "Please Fill a Entity Name"; lblNameReq.Visible = true; } else if (ddlEntityTypeID.SelectedIndex == 0) { ClinclblSaveStatus.Text = "Please Select Entity Type"; lbltypeReq.Visible = true; } else if (ddlAreaID.SelectedIndex == 0) { ClinclblSaveStatus.Text = "Please Select Brick"; lblAreaReq.Visible = true; } else { using (EntityTempDBContext entityUpdate = new EntityTempDBContext()) { int ID = int.Parse(txtEntityID.Text); EntityTemp updateEn = new EntityTemp(); updateEn.EntityID = ID; updateEn.EntityName = txtEntityName.Text; //updateEn.EntityCode = int.Parse(txtEntityCode.Text); updateEn.EntityAddress = txtEntityAddress.Text; updateEn.EntityTypeID = int.Parse(ddlEntityTypeID.SelectedValue); updateEn.Tel1 = txtTel1.Text; updateEn.Tel2 = txtTel2.Text; updateEn.Tel3 = txtTel3.Text; updateEn.Fax = txtFax.Text; updateEn.EntityEmailAddress = txtEntityEmailAddress.Text; updateEn.EntityWebSite = txtEntityWebSite.Text; updateEn.BrickID = int.Parse(ddlAreaID.SelectedValue); updateEn.BrickName = ddlAreaID.SelectedItem.ToString(); updateEn.Deleted = null; updateEn.EntryDate = DateTime.Now; updateEn.EntryEmployeeID = int.Parse(Session["EmployeeHRCodeFromAdmin"].ToString()); entityUpdate.EntityTemps.Add(updateEn); int roweffected = entityUpdate.SaveChanges(); if (roweffected > 0) { ClinclblSaveStatus.Text = "Updated"; using (EntityTempDBContext Refreshdb = new EntityTempDBContext()) { int code = int.Parse(txtEntityID.Text); var clinicdata = from clinic_tbl in Refreshdb.EntityTemps where (clinic_tbl.Deleted == null || clinic_tbl.Deleted == false) && clinic_tbl.EntityID == code select clinic_tbl; GridViewClinic.DataSource = clinicdata.ToList(); GridViewClinic.DataBind(); } //ClinicSearchQuery(); btnClinicSave.Visible = true; btnUpdate.Visible = false; clearFields(); } else { ClinclblSaveStatus.Text = "Error"; } } } }