Ejemplo n.º 1
0
        public view_Item GET(string strCriteria)
        {
            view_Item result     = null;
            var       strMessage = string.Empty;
            DataSet   ds         = null;

            if (SP_ITEM_SEL(strCriteria, ref ds, ref strMessage))
            {
                result = Helper.ToClassInstanceCollection <view_Item>(ds.Tables[0]).FirstOrDefault();
            }
            return(result);
        }
Ejemplo n.º 2
0
        private void BindGridView(int nPageNo)
        {
            InitcboYear();
            cItem   oItem       = new cItem();
            DataSet ds          = new DataSet();
            string  strMessage  = string.Empty;
            string  strCriteria = string.Empty;
            var     item        = new view_Item
            {
                item_year            = cboYear.SelectedValue,
                item_code            = txtitem_code.Text.Replace("'", "''").Trim(),
                item_name            = txtitem_name.Text.Replace("'", "''").Trim(),
                item_group_type      = cboItem_type.SelectedValue,
                item_group_code      = cboItemGroup.SelectedValue,
                item_group_detail_id = string.IsNullOrEmpty(cboItemGroupDetail.SelectedValue) ? 0 : int.Parse(cboItemGroupDetail.SelectedValue)
            };

            if (!item.item_year.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_year = '" + item.item_year + "') ";
            }
            if (!item.item_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_code like '%" + item.item_code + "%') ";
            }
            if (!item.item_name.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_name like '%" + item.item_name + "%') ";
            }
            if (!item.item_group_type.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_group_type = '" + item.item_group_type + "') ";
            }
            if (!item.item_group_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_group_code like '%" + item.item_group_code + "%') ";
            }
            if (item.item_group_detail_id > 0)
            {
                strCriteria = strCriteria + "  And  (item_group_detail_id = '" + item.item_group_detail_id + "') ";
            }
            if (RadioActive.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='Y') ";
            }
            else if (RadioCancel.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='N') ";
            }

            //if (DirectorLock == "N")
            //{
            //    strCriteria += " and lot_code in (''," + LotCodeList + ") ";
            //}

            try
            {
                if (!oItem.SP_ITEM_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    try
                    {
                        GridView1.PageIndex           = nPageNo;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                    catch
                    {
                        GridView1.PageIndex           = 0;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oItem.Dispose();
                ds.Dispose();
                if (GridView1.Rows.Count > 0)
                {
                    GridView1.TopPagerRow.Visible = true;
                }
            }
        }