예제 #1
0
 protected void txtBusquedaFormulario_OnDataSourceSelect(object sender, SearchBoxDataSourceSelectEventArgs e)
 {
     try
     {
         ObjectDataSource source    = (ObjectDataSource)e.DataSource;
         RadSearchBox     searchBox = (RadSearchBox)sender;
         if (e.SelectedContextItem.Key != IdAreaSeleccionada.ToString())
         {
             source.SelectParameters["idUsuarioSolicita"].DefaultValue = Session["IdUsuarioSolicita"].ToString();
             source.SelectParameters["idUsuarioLevanta"].DefaultValue  = ((Usuario)Session["UserData"]).Id.ToString();
             source.SelectParameters["idArea"].DefaultValue            = e.SelectedContextItem.Key;
             source.SelectParameters["keys"].DefaultValue = e.FilterString;
             source.DataBind();
         }
     }
     catch (Exception ex)
     {
         if (_lstError == null)
         {
             _lstError = new List <string>();
         }
         _lstError.Add(ex.Message);
         Alerta = _lstError;
     }
 }
    protected void gvCreateTOD_DataBound(object sender, EventArgs e)
    {
        if (gvCreateTOD.Rows.Count > 0)
        {
            TransferOrderHeader toh = null;
            string orderNumber      = Request.QueryString["OrderNum"];
            if (!string.IsNullOrEmpty(orderNumber))
            {
                toh = TransferOrderHeader.GetTransferOrderHeaderByOrderNum(int.Parse(orderNumber));
            }

            foreach (GridViewRow gvr in gvCreateTOD.Rows)
            {
                DropDownList     ddlUom  = (DropDownList)gvr.Cells[3].FindControl("ddlUom2");
                ObjectDataSource odsUom  = (ObjectDataSource)gvr.Cells[3].FindControl("odsUom");
                Label            lblGtin = (Label)gvr.Cells[1].FindControl("lblGtin");

                // District stock
                // HACK: If you see it, you know why it needs to be changed, if not...
                Label lblFromStock = (Label)gvr.FindControl("lblDistrictStock");
                var   bal          = GIIS.DataLayer.HealthFacilityBalance.GetHealthFacilityBalanceByHealthFacilityCode(toh.OrderFacilityFrom).Find(o => o.Gtin == lblGtin.Text);
                if (bal != null)
                {
                    lblFromStock.Text = String.Format("{0} {1}", bal.Balance, bal.GtinObject.BaseUom);
                }

                odsUom.SelectParameters.Clear();
                odsUom.SelectParameters.Add("gtin", lblGtin.Text);
                odsUom.DataBind();
                ddlUom.DataSourceID = "odsUom";
                ddlUom.DataBind();
            }
        }
    }
    protected void ddlHealthFacility_SelectedIndexChanged(object sender, EventArgs e)
    {
        int    id  = 0;
        string _id = Request.QueryString["appId"];

        if (!String.IsNullOrEmpty(_id))
        {
            int.TryParse(_id, out id);
            //VaccinationEvent o = VaccinationEvent.GetVaccinationEventById(id);
            int hfId = int.Parse(ddlHealthFacility.SelectedValue);
            if (hfId != -1)
            {
                bool isUsed = SystemModule.GetSystemModuleByName("StockManagement").IsUsed;
                if (isUsed)
                {
                    if (gvVaccinationEvent.Rows.Count > 0)
                    {
                        foreach (GridViewRow gvr in gvVaccinationEvent.Rows)
                        {
                            if (gvr.RowType == DataControlRowType.DataRow)
                            {
                                int vid                        = int.Parse(gvr.Cells[0].Text);
                                VaccinationEvent o             = VaccinationEvent.GetVaccinationEventById(vid);
                                DropDownList     ddlVaccineLot = (DropDownList)gvr.FindControl("ddlVaccineLot");
                                ObjectDataSource odsItemLot    = (ObjectDataSource)gvr.FindControl("odsItemLot");
                                string           hfcode        = HealthFacility.GetHealthFacilityById(int.Parse(ddlHealthFacility.SelectedValue)).Code;
                                odsItemLot.SelectParameters.Clear();
                                odsItemLot.SelectParameters.Add("itemId", o.Dose.ScheduledVaccination.ItemId.ToString());
                                odsItemLot.SelectParameters.Add("hfId", hfcode);
                                odsItemLot.DataBind();
                                ddlVaccineLot.DataBind();
                                if (ddlVaccineLot.Items.Count > 2)
                                {
                                    ddlVaccineLot.SelectedIndex = 2;
                                }
                                else
                                {
                                    ddlVaccineLot.SelectedIndex = 0;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
예제 #4
0
        /// <summary>
        /// Fills the specified gridview with a page of data.
        /// </summary>
        /// <param name="gv">The gridview.</param>
        /// <param name="list">The single page of data.</param>
        /// <param name="count">The total count (to work out number of pages).</param>
        /// <param name="pageSize">Size of the page.</param>
        public static void Fill(System.Web.UI.WebControls.GridView gv, IList <object> list, int count, int pageSize)
        {
            //create an ObjectDateSource object programmatically
            ObjectDataSource ods = new ObjectDataSource();

            ods.ID = "ods" + gv.ID;

            ods.EnablePaging               = gv.AllowPaging;
            ods.TypeName                   = "ObjectAdaptor"; //can be a common base class
            ods.SelectMethod               = "Select";
            ods.SelectCountMethod          = "Count";
            ods.StartRowIndexParameterName = "startRowIndex";
            ods.MaximumRowsParameterName   = "maximumRows";
            ods.EnableViewState            = false;
            //when creating, inject the data into the table adaptor
            ods.ObjectCreating += delegate(object sender, ObjectDataSourceEventArgs e)
            { e.ObjectInstance = new ObjectAdaptor(list, count); };
            ods.DataBind();

            gv.PageSize   = pageSize;
            gv.DataSource = ods;
            gv.DataBind();
        }
    protected void gvGtinValue_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Cells[0].Visible = false;

        TransferOrderHeader toh = null;
        string orderNumber      = Request.QueryString["OrderNum"];

        if (!string.IsNullOrEmpty(orderNumber))
        {
            toh = TransferOrderHeader.GetTransferOrderHeaderByOrderNum(int.Parse(orderNumber));
            if (toh.OrderStatus == 0)
            {
                e.Row.Cells[4].Visible = false;
            }
        }


        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label   lblOrderGtin = (Label)e.Row.FindControl("lblOrderGtin");
            TextBox txtValue     = (TextBox)e.Row.FindControl("txtValue");
            Label   lblId        = (Label)e.Row.FindControl("lblId");
            Label   lblId2       = (Label)e.Row.FindControl("lblId2");
            Label   lblItem      = (Label)e.Row.FindControl("lblItem");
            Label   lblFromStock = (Label)e.Row.FindControl("lblDistrictStock");

            DropDownList ddlUom = (DropDownList)e.Row.FindControl("ddlUom");
            DataTable    dt     = ItemManufacturer.GetUomFromGtin(lblOrderGtin.Text);
            // List<Uom> uomList = Uom.GetUomList();
            ddlUom.DataSource = dt;
            ddlUom.DataBind();


            //if (toh != null) // && toh.OrderStatus == 0)
            //    ddlUom.Enabled = true;
            //else ddlUom.Enabled = false;

            string id  = lblId.Text;
            int    id2 = int.Parse(lblId2.Text);

            TransferOrderDetail tod = TransferOrderDetail.GetTransferOrderDetailByOrderNumAndOrderDetail(int.Parse(id), id2);

            // lblFromStock.Text = GIIS.DataLayer.HealthFacilityBalance.GetHealthFacilityBalanceByHealthFacilityCode(toh.OrderFacilityFrom).Find(o=>o.Gtin == tod.OrderGtin).Balance.ToString();
            lblFromStock.Text += " " + tod.OrderUom;

            if (tod != null)
            {
                txtValue.Text        = tod.OrderQty.ToString();
                ddlUom.SelectedValue = tod.OrderUom;
                ddlUom.Enabled       = false;
            }


            DropDownList     ddlItemLot = (DropDownList)e.Row.FindControl("ddlItemLot");
            ObjectDataSource odsItemLot = (ObjectDataSource)e.Row.FindControl("odsItemLot");

            odsItemLot.SelectParameters.Clear();
            odsItemLot.SelectParameters.Add("gtin", lblOrderGtin.Text);
            odsItemLot.DataBind();
            ddlItemLot.DataSource = odsItemLot;
            ddlItemLot.DataBind();
            if (tod.OrderDetailStatus > 0)
            {
                ddlItemLot.SelectedValue = tod.OrderGtinLotnum;
            }
            if (tod.OrderDetailStatus == 3)
            {
                txtValue.Enabled   = false;
                ddlItemLot.Enabled = false;
            }
        }
    }
    protected void gvVaccinationEvent_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (!this.IsPostBack)
        {
            e.Row.Cells[0].Visible = false;
            VaccinationEvent o = (VaccinationEvent)e.Row.DataItem;
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                TextBox txtVaccinationDate = (TextBox)e.Row.FindControl("txtVaccinationDate");

                CheckBox     chkDoneStatus           = (CheckBox)e.Row.FindControl("chkStatus");
                DropDownList ddlNonvaccinationReason = (DropDownList)e.Row.FindControl("ddlNonvaccinationReason");

                DropDownList     ddlVaccineLot = (DropDownList)e.Row.FindControl("ddlVaccineLot");
                ObjectDataSource odsItemLot    = (ObjectDataSource)e.Row.FindControl("odsItemLot");
                if (ddlHealthFacility.SelectedIndex != 0)
                {
                    string hfcode = HealthFacility.GetHealthFacilityById(int.Parse(ddlHealthFacility.SelectedValue)).Code;
                    odsItemLot.SelectParameters.Clear();
                    odsItemLot.SelectParameters.Add("itemId", o.Dose.ScheduledVaccination.ItemId.ToString());
                    odsItemLot.SelectParameters.Add("hfId", hfcode);
                    odsItemLot.DataBind();
                    ddlVaccineLot.DataBind();
                    if (ddlVaccineLot.Items.Count > 2)
                    {
                        ddlVaccineLot.SelectedIndex = 2;
                    }
                    else
                    {
                        ddlVaccineLot.SelectedIndex = 0;
                    }
                }
                AjaxControlToolkit.CalendarExtender ceVaccinationDate  = (AjaxControlToolkit.CalendarExtender)e.Row.FindControl("ceVaccinationDate");
                RegularExpressionValidator          revVaccinationDate = (RegularExpressionValidator)e.Row.FindControl("revVaccinationDate");

                ConfigurationDate dateformat = ConfigurationDate.GetConfigurationDateById(int.Parse(Configuration.GetConfigurationByName("DateFormat").Value));
                ceVaccinationDate.Format                = dateformat.DateFormat;
                revVaccinationDate.ErrorMessage         = dateformat.DateFormat;
                revVaccinationDate.ValidationExpression = dateformat.DateExpresion;
                ceVaccinationDate.EndDate               = DateTime.Today.Date;
                ceVaccinationDate.StartDate             = o.Child.Birthdate;
                txtVaccinationDate.Text = DateTime.Today.ToString(dateformat.DateFormat);

                if (o.VaccinationStatus)
                {
                    chkDoneStatus.Checked           = true;
                    ddlVaccineLot.SelectedValue     = o.VaccineLotId.ToString();
                    txtVaccinationDate.Text         = o.VaccinationDate.ToString(dateformat.DateFormat);
                    ddlNonvaccinationReason.Visible = false;
                }
                else if (!o.VaccinationStatus && o.NonvaccinationReasonId != 0)
                {
                    chkDoneStatus.Checked                 = false;
                    ddlVaccineLot.SelectedIndex           = 0;
                    txtVaccinationDate.Text               = o.VaccinationDate.ToString(dateformat.DateFormat);
                    ddlNonvaccinationReason.Visible       = true;
                    ddlNonvaccinationReason.SelectedValue = o.NonvaccinationReasonId.ToString();
                }
            }
        }
    }