Ejemplo n.º 1
0
        protected void BtnAddRows_Click(object sender, EventArgs e)
        {
            DataTable DT = new DataTable();
            string    locationId;

            locationId = CheckLocationExist();

            if (locationId == string.Empty)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "alertScript", "alert('货位不存在。')", true);
                return;
            }

            if (ViewState[VS_LOCATION_TB] == null)
            {
                DataColumn col1 = new DataColumn("location_id");
                DataColumn col2 = new DataColumn("company_id");
                DataColumn col3 = new DataColumn("area");
                DataColumn col4 = new DataColumn("location");
                DataColumn col5 = new DataColumn("amount");
                DT.Columns.Add(col1);
                DT.Columns.Add(col2);
                DT.Columns.Add(col3);
                DT.Columns.Add(col4);
                DT.Columns.Add(col5);

                LblTotal.Text = "0";;
            }
            else
            {
                DT = (DataTable)ViewState[VS_LOCATION_TB];
            }

            DataRow[] Rows = DT.Select("location_id='" + locationId + "'");

            if (Rows.Length > 0)
            {
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "alertScript", "SetGVBoxHeight('gvbox','GVSubmitData');alert('此货位已经添加。');", true);
                return;
            }

            DataRow NewRow = DT.NewRow();

            NewRow["location_id"] = locationId;
            NewRow["company_id"]  = DdlCompany.SelectedValue;
            NewRow["area"]        = DDLArea.SelectedItem.Text;
            NewRow["location"]    = TxtLocationInput.Text;
            NewRow["amount"]      = TxtAmount.Text;

            DT.Rows.Add(NewRow);

            LblTotal.Text = Convert.ToString(Convert.ToDecimal(LblTotal.Text) + Convert.ToDecimal(TxtAmount.Text));

            ViewState[VS_LOCATION_TB] = DT;
            OKGrid.DataSource         = DT;
            OKGrid.DataKeyNames       = new string[] { "location_id" };
            OKGrid.DataBind();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "myscript", "SetGVBoxHeight('gvbox','GVSubmitData');", true);
        }
Ejemplo n.º 2
0
        protected void OKGrid_RowEditing(object sender, GridViewEditEventArgs e)
        {
            DataTable DT = (DataTable)ViewState[VS_LOCATION_TB];

            LblTotal.Text = Convert.ToString(decimal.Parse(LblTotal.Text) - decimal.Parse(DT.Rows[e.NewEditIndex]["amount"].ToString()));
            DT.Rows.RemoveAt(e.NewEditIndex);

            ViewState[VS_LOCATION_TB] = DT;
            OKGrid.DataSource         = DT;
            OKGrid.DataKeyNames       = new string[] { "location_id" };
            OKGrid.DataBind();
        }
Ejemplo n.º 3
0
 private void GVOKEmptyDataBind()
 {
     LblTotal.Text     = "0";
     OKGrid.DataSource = null;
     OKGrid.DataBind();
 }