Exemple #1
0
        protected void GrdImmunization_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //System.Data.DataTable theDT = new System.Data.DataTable();
            theImmunizationDT = ((DataTable)Session["ImmunizationGridData"]);
            int r = Convert.ToInt32(e.RowIndex.ToString());

            int Id = -1;

            try
            {
                if (theImmunizationDT.Rows.Count > 0)
                {
                    if (theImmunizationDT.Rows[r].HasErrors == false)
                    {
                        if ((theImmunizationDT.Rows[r]["ImmunizationId"] != null) && (theImmunizationDT.Rows[r]["ImmunizationId"] != DBNull.Value))
                        {
                            if (theImmunizationDT.Rows[r]["ImmunizationId"].ToString() != "")
                            {
                                Id = Convert.ToInt32(theImmunizationDT.Rows[r]["ImmunizationId"]);
                                theImmunizationDT.Rows[r].Delete();
                                theImmunizationDT.AcceptChanges();
                                Session["ImmunizationGridData"] = theImmunizationDT;
                                GrdImmunization.Columns.Clear();
                                BindGrid();
                                Refresh();
                                GrdImmunization.DataSource = (DataTable)Session["ImmunizationGridData"];
                                GrdImmunization.DataBind();
                                IQCareMsgBox.Show("DeleteSuccess", this);
                            }
                        }
                    }



                    if (((DataTable)Session["ImmunizationGridData"]).Rows.Count == 0)
                    {
                        btnAdd.Enabled = false;
                    }
                    else
                    {
                        btnAdd.Enabled = true;
                    }
                }
                else
                {
                    GrdImmunization.Visible = false;
                    //IQCareMsgBox.Show("DeleteSuccess", this);
                    Refresh();
                }
            }
            catch (Exception ex)
            {
                string str = ex.Message;
            }
        }
Exemple #2
0
        protected void btnAddPriorART_Click(object sender, EventArgs e)
        {
            int VisitId = Convert.ToInt32(Session["PatientVisitId"]) > 0 ? Convert.ToInt32(Session["PatientVisitId"]) : 0;

            if ((DataTable)Session["ImmunizationGridData"] == null)
            {
                theImmunizationDT.Columns.Add("ptn_pk", typeof(Int32));
                theImmunizationDT.Columns.Add("VisitId", typeof(Int32));
                theImmunizationDT.Columns.Add("ImmunizationId", typeof(Int32));
                theImmunizationDT.Columns.Add("Immunization", typeof(string));
                theImmunizationDT.Columns.Add("ImmunizationDate", typeof(string));
                DataRow theDR = theImmunizationDT.NewRow();
                theDR["ptn_pk"]           = Session["PatientId"];
                theDR["VisitId"]          = VisitId;
                theDR["Immunization"]     = ddlImmunization.SelectedItem.Text;
                theDR["ImmunizationDate"] = txtDate.Text;
                theDR["ImmunizationId"]   = ddlImmunization.SelectedValue;
                theImmunizationDT.Rows.Add(theDR);
                GrdImmunization.Columns.Clear();
                BindGrid();
                Refresh();
                GrdImmunization.DataSource = theImmunizationDT;
                GrdImmunization.DataBind();
                Session["ImmunizationGridData"] = theImmunizationDT;
            }
            else
            {
                theImmunizationDT = (DataTable)Session["ImmunizationGridData"];
                if (Convert.ToInt32(ViewState["UpdateFlag"]) == 1)
                {
                    DataRow[] rows = theImmunizationDT.Select("ImmunizationId=" + ViewState["SelectedImmunizationId"] + " and ImmunizationDate='" + ViewState["SelectedImmunizationDate"] + "'");
                    for (int i = 0; i < rows.Length; i++)
                    {
                        rows[i]["ptn_pk"]           = Session["PatientId"];
                        rows[i]["VisitId"]          = VisitId;
                        rows[i]["ImmunizationId"]   = ddlImmunization.SelectedValue;
                        rows[i]["Immunization"]     = ddlImmunization.SelectedItem.Text;
                        rows[i]["ImmunizationDate"] = txtDate.Text;
                        theImmunizationDT.AcceptChanges();
                    }
                    GrdImmunization.Columns.Clear();
                    BindGrid();
                    Refresh();
                    GrdImmunization.DataSource = theImmunizationDT;
                    GrdImmunization.DataBind();
                    Session["ImmunizationGridData"] = theImmunizationDT;
                    ViewState["UpdateFlag"]         = "0";
                }
                else
                {
                    DataRow theDR = theImmunizationDT.NewRow();
                    theDR["ptn_pk"]           = Session["PatientId"];
                    theDR["VisitId"]          = VisitId;
                    theDR["Immunization"]     = ddlImmunization.SelectedItem.Text;
                    theDR["ImmunizationDate"] = txtDate.Text;
                    theDR["ImmunizationId"]   = ddlImmunization.SelectedValue;
                    theImmunizationDT.Rows.Add(theDR);
                    GrdImmunization.Columns.Clear();
                    BindGrid();
                    Refresh();
                    GrdImmunization.DataSource = theImmunizationDT;
                    GrdImmunization.DataBind();
                    Session["ImmunizationGridData"] = theImmunizationDT;
                }
            }
        }