예제 #1
0
    /// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        LBOMBB bOMBB = new LBOMBB();
        DataSet ds = new DataSet();

        try
        {
            string wherestr = this.StrWhere;
            if (!string.IsNullOrEmpty(txtMaterialnm.Text))
            {
                wherestr += "  and  materialDesc='%"+txtMaterialnm.Text.Replace("'","''")+"%'";
            }
            if (!string.IsNullOrEmpty(txtMaterialno.Text))
            {
                wherestr += "  and  materialno like '%" + txtMaterialno.Text.Replace("'", "''") + "%'";
            }

            ds = bOMBB.GetVList(wherestr);
            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
        {
            bOMBB.Dispose();
        }
    }
예제 #2
0
 /// <summary>
 /// 展示数据
 /// </summary>
 /// <param name="id">记录Id</param>
 private void ShowInfo(int id)
 {
     LBOMBB bOMBB = new LBOMBB();
     vLBOMData model = new vLBOMData();
     try
     {
         model = bOMBB.GetVModel(id);
         this.materialNm.Text = model.materialDesc;
         this.materialNo.Text = model.materialNo;
     }
     finally
     {
         bOMBB.Dispose();
     }
 }
예제 #3
0
    /// <summary>
    /// 数据保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        LBOMData model = new LBOMData();
        LBOMBC bOMBC = new LBOMBC();
        LBOMBB bOMBB = new LBOMBB();
        try
        {

            #region 检查表单数据是否正确
            if (string.IsNullOrEmpty(materialNo.Text.Trim()))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "alertMsg", "alert(\"请选择物料!\");", true);
                return;
            }

            model = bOMBB.GetModel(materialNo.Text.Trim());
            int num = 0;
            foreach (DataRow dr in this.DtResult.Rows)
            {
                if (!int.TryParse(dr["num"].ToString(), out num))
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alertMsg", "alert(\"物料清单明细数量不能为0!\");", true);
                    return;
                }
                DataRow[] drs = this.DtResult.Select(" materialno='" + dr["materialno"].ToString() + "' and isdel=0");
                if (drs.Length > 1)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alertMsg", "alert(\"物料清单明细存在重复项!\");", true);
                    return;
                }
            }

            if (this.State == "1")
            {
                if (model != null)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alertMsg", "alert(\"物料清单已经存在!\");", true);
                    return;
                }
            #endregion
                model = new LBOMData();
                model.materialNo = materialNo.Text;
                model.isrtDt = DateTime.Now.ToString();
                model.isrtEmpId = this.currentUser.empId;
                this.State = "2";
            }
            else if (this.State == "2")
            {

                model.materialNo = materialNo.Text;
                model.updtDt = DateTime.Now.ToString();
                model.updtEmpId = this.currentUser.empId;

            }
            if (bOMBC.SaveBOMBill(model, this.DtResult))
            {
                this.IdValue = model.id;
                this.ClientScript.RegisterStartupScript(this.GetType(), "alertMsg", "alert(\"保存成功\");location.replace(\"LBOMList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main\");", true);

            }
            else
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "alertMsg", "alert(\"保存失败\");", true);
            }

        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            bOMBC.Dispose();
            bOMBB.Dispose();
        }

        // Response.Redirect("LBOMList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false);
    }
예제 #4
0
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        bool retChecked = false;
        LBOMBB bOMBB = new LBOMBB();
        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);
                    bOMBB.DeleteRecord(id);
                }
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            bOMBB.Dispose();
        }

        if (retChecked)
        {
            this.BindGrid();
        }
    }