Пример #1
0
    /// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        LWareSortBB wareSortBB = new LWareSortBB();
        DataSet ds = new DataSet();

        try
        {
            string strWhere = this.StrWhere;

            //货位分类编码
            if (this.tbWareSortNo.Text.Trim() != "")
            {
                strWhere += " and wareSortNo like '%" + this.tbWareSortNo.Text.Trim().Replace("'", "''") + "%'";
            }

            //货位分类名称
            if (this.tbWareSortNm.Text.Trim() != "")
            {
                strWhere += " and wareSortNm like '%" + this.tbWareSortNm.Text.Trim().Replace("'", "''") + "%'";
            }

            ds = wareSortBB.GetVList(strWhere);
            this.grid.DataSource = ds.Tables[0];
            this.grid.DataBind();

            //赋值记录条数、页面总数
            this.Label3.Text = ds.Tables[0].Rows.Count.ToString();
            this.Label2.Text = this.grid.PageCount.ToString();
            this.currPage.Text = (this.grid.PageIndex + 1).ToString();
        }
        finally
        {
            wareSortBB.Dispose();
        }
    }
Пример #2
0
    /// <summary>
    /// 数据保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string strInfo = "";

        if (!this.ValidateData(out strInfo))
        {
            strInfo = strInfo.Replace("\"", "'").Replace("\n", "");
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + strInfo + "');", true);
            return;
        }

        LWareSortData model = new LWareSortData();
        LWareSortBB wareSortBB = new LWareSortBB();

        try
        {
            if (this.State == "1")
            {
                this.SetModel(ref model);
                model.isrtDt = DateTime.Now.ToString();
                model.isrtEmpId = this.currentUser.empId;
                this.IdValue = wareSortBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                model = wareSortBB.GetModel(this.IdValue);
                this.SetModel(ref model);
                model.updtDt = DateTime.Now.ToString();
                model.updtEmpId = this.currentUser.empId;
                wareSortBB.ModifyRecord(model);
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            wareSortBB.Dispose();
        }

        Response.Redirect("LWareSortList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false);
    }
Пример #3
0
    /// <summary>
    /// 绑定货位分类下拉框
    /// </summary>
    public void BindWareSort(DropDownList ddlWareSort)
    {
        using (LWareSortBB wareSortBB = new LWareSortBB())
        {
            DataSet ds = new DataSet();
            ds = wareSortBB.GetList("isDel=0");

            ddlWareSort.DataTextField = "wareSortNm";
            ddlWareSort.DataValueField = "wareSortNo";
            ddlWareSort.DataSource = ds.Tables[0];
            ddlWareSort.DataBind();
            ddlWareSort.Items.Insert(0, new ListItem("-请选择-", ""));
        }
    }
Пример #4
0
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        LWareSortBB wareSortBB = new LWareSortBB();

        try
        {
            //获取选中的数据Id
            foreach (GridViewRow gvrow in this.grid.Rows)
            {
                CheckBox chkId = (CheckBox)gvrow.FindControl("chkId");
                if (chkId.Checked == true)
                {
                    retChecked = true;
                    int id = int.Parse(chkId.ValidationGroup);
                    LWareSortData wareSortModel = new LWareSortData();

                    wareSortModel = wareSortBB.GetModel(id);
                    wareSortModel.isDel = true;
                    wareSortModel.updtDt = System.DateTime.Now.ToString();
                    wareSortModel.updtEmpId = this.currentUser.empId;
                    wareSortBB.ModifyRecord(wareSortModel);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            wareSortBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }
Пример #5
0
    /// <summary>
    /// 验证页面信息
    /// </summary>
    /// <param name="strErrorInfo">错误提示信息</param>
    /// <returns></returns>
    private bool ValidateData(out string strErrorInfo)
    {
        LWareSortBB wareSortBB = new LWareSortBB();

        try
        {
            strErrorInfo = "";
            DataSet ds = new DataSet();

            if (this.tbWareSortNo.Text.Trim() == "")
            {
                strErrorInfo = "请首先填写货位分类编码!";
                this.tbWareSortNo.Focus();
                return false;
            }

            //判断货位分类编码是否重复
            ds = wareSortBB.GetList("wareSortNo='" + this.tbWareSortNo.Text.Trim().Replace("'", "''") + "' and id<>" + this.IdValue.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                strErrorInfo = "货位分类编码重复!";
                this.tbWareSortNo.Focus();
                return false;
            }

            if (this.tbWareSortNm.Text.Trim() == "")
            {
                strErrorInfo = "请首先填写货位分类名称!";
                this.tbWareSortNm.Focus();
                return false;
            }

            return true;
        }
        finally
        {
            wareSortBB.Dispose();
        }
    }
Пример #6
0
 /// <summary>
 /// 展示数据
 /// </summary>
 /// <param name="id">记录Id</param>
 private void ShowInfo(int id)
 {
     LWareSortBB wareSortBB = new LWareSortBB();
     vLWareSortData model = new vLWareSortData();
     try
     {
         model = wareSortBB.GetVModel(id);
         this.tbWareSortNo.Text = model.wareSortNo;
         this.tbWareSortNm.Text = model.wareSortNm;
     }
     finally
     {
         wareSortBB.Dispose();
     }
 }