Beispiel #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                #region "Data Validation"
                if (FieldValidation() == false)
                {
                    return;
                }
                #endregion

                //DataTable theDT = (DataTable)ViewState["DrugData"]; //rupesh
                DataTable theDT = (DataTable)ViewState["MasterTable"];

                IDrugMst DrugManager = (IDrugMst)ObjectFactory.CreateInstance("BusinessProcess.Administration.BDrugMst, BusinessProcess.Administration");

                if (ViewState["Type"].ToString() == "Schedule")
                {
                    DataTable theNDT = (DataTable)DrugManager.CreateSchedule(txtAdd.Text.Trim(), Convert.ToInt32(Session["AppUserId"]));
                    if (theNDT.Rows[0][0].ToString() == "0")
                    {
                        IQCareMsgBox.Show("ScheduleExists", this);
                        return;
                    }
                    else
                    {
                        DataRow theDR = theDT.NewRow();
                        theDR[0] = theNDT.Rows[0][0];
                        theDR[1] = theNDT.Rows[0][1];
                        theDT.Rows.Add(theDR);
                        IQCareUtils theUtil = new IQCareUtils();
                        DataView    theDV   = theUtil.GridSort(theDT, "Name", "asc");
                        ViewState["DrugScheduleAvail"] = theUtil.CreateTableFromDataView(theDV);
                        lstAvailable.DataSource        = (DataTable)ViewState["DrugScheduleAvail"];
                        lstAvailable.DataBind();
                        txtAdd.Text = "";
                        ViewState["MasterTable"] = ViewState["DrugScheduleAvail"];
                    }
                }
            }
            catch (Exception err)
            {
                MsgBuilder theBuilder = new MsgBuilder();
                theBuilder.DataElements["MessageText"] = err.Message.ToString();
                IQCareMsgBox.Show("#C1", theBuilder, this);
            }
        }
Beispiel #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                #region "Data Validation"
                if (FieldValidation() == false)
                {
                    return;
                }
                #endregion

                //DataTable theDT = (DataTable)ViewState["DrugData"]; //rupesh
                DataTable theDT = (DataTable)ViewState["MasterTable"];

                IDrugMst DrugManager = (IDrugMst)ObjectFactory.CreateInstance("BusinessProcess.Administration.BDrugMst, BusinessProcess.Administration");
                if (ViewState["Type"].ToString() == "Strength")
                {
                    DataTable theNDT = (DataTable)DrugManager.CreateStrength(txtAdd.Text.Trim(), Convert.ToInt32(Session["AppUserId"].ToString()));
                    if (theNDT.Rows[0][0].ToString() == "0")
                    {
                        IQCareMsgBox.Show("StrengthExists", this);
                        return;
                    }
                    else
                    {
                        DataRow theDR = theDT.NewRow();
                        theDR[0] = theNDT.Rows[0][0];
                        theDR[1] = theNDT.Rows[0][1];
                        theDT.Rows.Add(theDR);
                        IQCareUtils theUtil = new IQCareUtils();
                        DataView    theDV   = theUtil.GridSort(theDT, "StrengthName", "asc");
                        ViewState["DrugStrengthAvail"] = theUtil.CreateTableFromDataView(theDV);
                        lstAvailable.DataSource        = (DataTable)ViewState["DrugStrengthAvail"];
                        lstAvailable.DataBind();
                        txtAdd.Text = "";
                        ViewState["MasterTable"] = ViewState["DrugStrengthAvail"];
                    }
                }
                else if (ViewState["Type"].ToString() == "Frequency")
                {
                    DataTable theNDT = (DataTable)DrugManager.CreateFrequency(txtAdd.Text.Trim(), Convert.ToInt32(Session["AppUserId"]));
                    if (theNDT.Rows[0][0].ToString() == "0")
                    {
                        IQCareMsgBox.Show("FrequencyExists", this);
                        return;
                    }
                    else
                    {
                        DataRow theDR = theDT.NewRow();
                        theDR[0] = theNDT.Rows[0][0];
                        theDR[1] = theNDT.Rows[0][1];
                        theDT.Rows.Add(theDR);
                        IQCareUtils theUtil = new IQCareUtils();
                        DataView    theDV   = theUtil.GridSort(theDT, "Name", "asc");
                        ViewState["DrugFrequencyAvail"] = theUtil.CreateTableFromDataView(theDV);
                        lstAvailable.DataSource         = (DataTable)ViewState["DrugFrequencyAvail"];
                        lstAvailable.DataBind();
                        txtAdd.Text = "";
                        ViewState["MasterTable"] = ViewState["DrugFrequencyAvail"];
                    }
                }
                else if (ViewState["Type"].ToString() == "Schedule")
                {
                    DataTable theNDT = (DataTable)DrugManager.CreateSchedule(txtAdd.Text.Trim(), Convert.ToInt32(Session["AppUserId"]));
                    if (theNDT.Rows[0][0].ToString() == "0")
                    {
                        IQCareMsgBox.Show("ScheduleExists", this);
                        return;
                    }
                    else
                    {
                        DataRow theDR = theDT.NewRow();
                        theDR[0] = theNDT.Rows[0][0];
                        theDR[1] = theNDT.Rows[0][1];
                        theDT.Rows.Add(theDR);
                        IQCareUtils theUtil = new IQCareUtils();
                        DataView    theDV   = theUtil.GridSort(theDT, "Name", "asc");
                        ViewState["DrugScheduleAvail"] = theUtil.CreateTableFromDataView(theDV);
                        lstAvailable.DataSource        = (DataTable)ViewState["DrugScheduleAvail"];
                        lstAvailable.DataBind();
                        txtAdd.Text = "";
                        ViewState["MasterTable"] = ViewState["DrugScheduleAvail"];
                    }
                }
                else if (ViewState["Type"].ToString() == "Generic")
                {
                    //DataTable theDT = (DataTable)ViewState["DrugData"];
                    string theGenericAbbrv;
                    if (txtAbbv.Text == "")
                    {
                        theGenericAbbrv = "";
                    }
                    else
                    {
                        theGenericAbbrv = txtAbbv.Text;
                    }
                    int theDrgType = Convert.ToInt32(ViewState["DrugType"]);

                    DataSet theNDT = (DataSet)DrugManager.CreateGeneric(txtAdd.Text.Trim(), theGenericAbbrv, theDrgType, Convert.ToInt32(Session["AppUserId"]));
                    if (theNDT.Tables[0].Rows[0][0].ToString() == "0")
                    {
                        if (theDrgType == 37)
                        {
                            IQCareMsgBox.Show("GenericExists", this);
                            return;
                        }
                        else
                        {
                            IQCareMsgBox.Show("NonARVGenericExists", this);
                            return;
                        }
                    }

                    else
                    {
                        DataTable DT = new DataTable();
                        DT = theDT.Copy();
                        DataRow theDR = DT.NewRow();
                        theDR[0] = theNDT.Tables[0].Rows[0][0];
                        theDR[1] = theNDT.Tables[0].Rows[0][1];
                        theDR[2] = theNDT.Tables[0].Rows[0][2];
                        theDR[3] = theNDT.Tables[1].Rows[0][0];
                        DT.Rows.Add(theDR);

                        IQCareUtils theUtil = new IQCareUtils();
                        DataView    theDV   = theUtil.GridSort(DT, "GenericName", "asc");
                        DT = theUtil.CreateTableFromDataView(theDV);

                        ViewState["DrugData"] = DT;
                        theDV           = new DataView(DT);
                        theDV.RowFilter = "DrugTypeId=" + ViewState["DrugType"].ToString();
                        DT = theUtil.CreateTableFromDataView(theDV);
                        ViewState["MasterTable"] = DT;

                        lstAvailable.DataSource = DT;
                        lstAvailable.DataBind();
                        if (theDrgType == 37)
                        {
                            txtAbbv.Text = "";
                            txtAdd.Text  = "";
                        }
                        else
                        {
                            txtAdd.Text = "";
                        }
                    }
                }
            }
            catch (Exception err)
            {
                MsgBuilder theBuilder = new MsgBuilder();
                theBuilder.DataElements["MessageText"] = err.Message.ToString();
                IQCareMsgBox.Show("#C1", theBuilder, this);
            }
        }