Exemplo n.º 1
0
        protected void gvAddData_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string D_id    = (gvAddData.Rows[e.RowIndex].FindControl("hfDetailId") as HiddenField).Value;
            string c       = "select Bill_id from tmp_pk_detail where Detail_id ='" + D_id + "'";
            string bill_id = new SelectCommandBuilder().ExecuteDataTable(c).Rows[0][0].ToString();
            string sql1    = "delete from tmp_pk_detail where Detail_id ='" + D_id + "'";
            int    count   = new DeleteCommandBuilder().ExecuteNonQuery(sql1);
            string dsql    = "SELECT COUNT(*) AS COUNTa FROM tmp_pk_detail where Bill_id = '" + bill_id + "'";
            int    p       = Convert.ToInt32(new SelectCommandBuilder().ExecuteScalar(dsql));

            if (p == 0)
            {
                string sqlc = "delete from tmp_pk_bill where Bill_id = '" + bill_id + "'";
                count += new DeleteCommandBuilder().ExecuteNonQuery(sqlc);
            }
            if (count != 0)
            {
                string    sql = @"SELECT a.Bill_id,a.Detail_id,goods.goods_name,goods.spec,goods.cz, goods.ys,goods.goods_unit,a.pch,a.hwh as 'hwh',a.Qty,a.price,customer_name = (select cc.customer_name  
						from prd_dictate bb,batch aa,customer cc,xsht dd where aa.dictate_id = bb.dictate_id and aa.batch_id = a.batch_id and bb.order_id = dd.xsht_id and dd.customer_id = cc.customer_id )
                        FROM tmp_pk_detail a,goods,sccj WHERE ( goods.sccj_id *= sccj.sccj_id) and ( a.Goods_id = goods.goods_id )and  a.bill_id='" + ViewState["billId"].ToString().Trim() + "'";
                DataTable dt  = new SelectCommandBuilder().ExecuteDataTable(sql);
                aList.Clear();
                if (dt != null && dt.Rows.Count != 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        AddData a = new AddData()
                        {
                            id            = dt.Rows[i]["Detail_id"].ToString(),
                            pm            = dt.Rows[i]["goods_name"].ToString(),
                            spec          = dt.Rows[i]["spec"].ToString(),
                            cz            = dt.Rows[i]["cz"].ToString(),
                            ys            = dt.Rows[i]["ys"].ToString(),
                            goods_unit    = dt.Rows[i]["goods_unit"].ToString(),
                            pch           = dt.Rows[i]["pch"].ToString(),
                            hwh           = dt.Rows[i]["hwh"].ToString(),
                            pdsl          = dt.Rows[i]["qty"].ToString() == "" ? "0.00" : Convert.ToDecimal(dt.Rows[i]["qty"]).ToString("0.##"),
                            Price         = dt.Rows[i]["price"].ToString() == "" ? "0.00" : Convert.ToDecimal(dt.Rows[i]["price"]).ToString("0.##"),
                            total         = dt.Rows[i]["price"].ToString() == "" ? "0.00" : (Convert.ToDecimal(dt.Rows[i]["qty"]) * Convert.ToDecimal(dt.Rows[i]["price"])).ToString("0.##"),
                            customer_name = dt.Rows[i]["customer_name"].ToString()
                        };
                        aList.Add(a);
                    }
                }
                gvAddData.DataSource = aList;
                gvAddData.DataBind();
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "focus", "<script>alert('删除失败!')</script>");
            }
        }
Exemplo n.º 2
0
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            if (gvEditData.SelectedIndex != -1)
            {
                string    sql = @"SELECT a.Bill_id,a.Detail_id,goods.goods_name,goods.spec,goods.cz, goods.ys,goods.goods_unit,a.pch,a.hwh as 'hwh',a.Qty,a.price,customer_name = (select cc.customer_name  
						from prd_dictate bb,batch aa,customer cc,xsht dd where aa.dictate_id = bb.dictate_id and aa.batch_id = a.batch_id and bb.order_id = dd.xsht_id and dd.customer_id = cc.customer_id )
                        FROM tmp_pk_detail a,goods,sccj WHERE ( goods.sccj_id *= sccj.sccj_id) and ( a.Goods_id = goods.goods_id )and  a.bill_id='" + ViewState["billId"].ToString().Trim() + "'";
                DataTable dt  = new SelectCommandBuilder().ExecuteDataTable(sql);
                aList.Clear();
                if (dt != null && dt.Rows.Count != 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        AddData a = new AddData()
                        {
                            id            = dt.Rows[i]["Detail_id"].ToString(),
                            pm            = dt.Rows[i]["goods_name"].ToString(),
                            spec          = dt.Rows[i]["spec"].ToString(),
                            cz            = dt.Rows[i]["cz"].ToString(),
                            ys            = dt.Rows[i]["ys"].ToString(),
                            goods_unit    = dt.Rows[i]["goods_unit"].ToString(),
                            pch           = dt.Rows[i]["pch"].ToString(),
                            hwh           = dt.Rows[i]["hwh"].ToString(),
                            pdsl          = dt.Rows[i]["qty"].ToString() == "" ? "0.00" : Convert.ToDecimal(dt.Rows[i]["qty"]).ToString("0.##"),
                            Price         = dt.Rows[i]["price"].ToString() == "" ? "0.00" : Convert.ToDecimal(dt.Rows[i]["price"]).ToString("0.##"),
                            total         = dt.Rows[i]["price"].ToString() == "" ? "0.00" : (Convert.ToDecimal(dt.Rows[i]["qty"]) * Convert.ToDecimal(dt.Rows[i]["price"])).ToString("0.##"),
                            customer_name = dt.Rows[i]["customer_name"].ToString()
                        };
                        aList.Add(a);
                    }
                }
                gvAddData.DataSource = aList;
                gvAddData.DataBind();
                txtPK_No.Text = gvEditData.SelectedRow.Cells[4].Text.Trim() == "&nbsp;" ? "" : gvEditData.SelectedRow.Cells[4].Text.Trim();
                gvAddData.Columns[11].Visible = false;
                gvAddData.Columns[12].Visible = true;
                tredit.Visible = false;
            }
        }
Exemplo n.º 3
0
        protected void gvGoodsData_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (gvEditData.Rows.Count != 0)
            {
                AddData dataa = new AddData()
                {
                    id            = "",
                    pm            = this.gvGoodsData.SelectedRow.Cells[0].Text.Trim(),
                    spec          = this.gvGoodsData.SelectedRow.Cells[2].Text.Trim(),
                    cz            = this.gvGoodsData.SelectedRow.Cells[3].Text.Trim(),
                    ys            = this.gvGoodsData.SelectedRow.Cells[4].Text.Trim(),
                    goods_unit    = this.gvGoodsData.SelectedRow.Cells[5].Text.Trim(),
                    pch           = this.gvGoodsData.SelectedRow.Cells[6].Text == "&nbsp;" ? "" : this.gvGoodsData.SelectedRow.Cells[6].Text.Trim(),
                    hwh           = this.gvGoodsData.SelectedRow.Cells[7].Text == "&nbsp;" ? "" : this.gvGoodsData.SelectedRow.Cells[7].Text.Trim(),
                    pdsl          = this.gvGoodsData.SelectedRow.Cells[12].Text == "&nbsp;" ? "0" : Convert.ToDecimal(this.gvGoodsData.SelectedRow.Cells[12].Text).ToString("0.##"),
                    Price         = this.gvGoodsData.SelectedRow.Cells[10].Text == "&nbsp;" ? "0" : Convert.ToDecimal(this.gvGoodsData.SelectedRow.Cells[10].Text).ToString("0.##"),
                    total         = "0",
                    customer_name = this.gvGoodsData.SelectedRow.Cells[13].Text.Trim()
                };
                List <string>        sList = getBatch_id(dataa.pm, dataa.pch);
                InsertCommandBuilder ins   = new InsertCommandBuilder("tmp_pk_detail");
                string Bill_id             = ViewState["billId"].ToString();
                ins.InsertColumn("Bill_id", Bill_id);
                ins.InsertColumn("Batch_id", sList[1].Trim());
                ins.InsertColumn("goods_id", sList[0].Trim());
                ins.InsertColumn("Qty", dataa.pdsl);
                ins.InsertColumn("Pch", dataa.pch);
                string detail_id = new SelectCommandBuilder().ExecuteDataTable("SELECT MAX(Detail_id) AS maxId FROM tmp_pk_detail where bill_id = '" + Bill_id + "'").Rows[0][0].ToString();
                int    i         = Convert.ToInt32(detail_id.Substring(detail_id.Length - 4, 4));
                ins.InsertColumn("Detail_id", Bill_id + (i + 1).ToString().PadLeft(4, '0'));
                ins.InsertColumn("Price", dataa.Price);
                ins.InsertColumn("is_can_sale", "Y");
                ins.InsertColumn("hwh", dataa.hwh);
                ins.getInsertCommand();
                ins.ExecuteNonQuery();
                //string updateSQL = "update pre_pk_detail set pdsl =" + dataa.pdsl + ",detail_id = '" + Bill_id + (i + 1).ToString().PadLeft(4, '0') + "' WHERE (pk_id = '" + txtPK_Id.Text.Trim().ToUpper() + "') AND (batch_id = '" + lList[i].b_id + "') AND (stock_remain_id = '" + lList[i].s_id + "') ";
                //if (aList.Count==0)
                //{
                //    btnSelect_Click(sender, e);
                //}
                trgoods.Visible = false;
                AddData data1 = new AddData()
                {
                    id            = Bill_id + (i + 1).ToString().PadLeft(4, '0'),
                    pm            = this.gvGoodsData.SelectedRow.Cells[0].Text.Trim(),
                    spec          = this.gvGoodsData.SelectedRow.Cells[2].Text.Trim(),
                    cz            = this.gvGoodsData.SelectedRow.Cells[3].Text.Trim(),
                    ys            = this.gvGoodsData.SelectedRow.Cells[4].Text.Trim(),
                    goods_unit    = this.gvGoodsData.SelectedRow.Cells[5].Text.Trim(),
                    pch           = this.gvGoodsData.SelectedRow.Cells[6].Text == "&nbsp;" ? "" : this.gvGoodsData.SelectedRow.Cells[6].Text.Trim(),
                    hwh           = this.gvGoodsData.SelectedRow.Cells[7].Text == "&nbsp;" ? "" : this.gvGoodsData.SelectedRow.Cells[7].Text.Trim(),
                    pdsl          = this.gvGoodsData.SelectedRow.Cells[12].Text == "&nbsp;" ? "0" : Convert.ToDecimal(this.gvGoodsData.SelectedRow.Cells[12].Text).ToString("0.##"),
                    Price         = this.gvGoodsData.SelectedRow.Cells[10].Text == "&nbsp;" ? "0" : Convert.ToDecimal(this.gvGoodsData.SelectedRow.Cells[10].Text).ToString("0.##"),
                    total         = "0",
                    customer_name = this.gvGoodsData.SelectedRow.Cells[13].Text.Trim()
                };
                aList.Insert(0, data1);
                gvAddData.DataSource = aList;
                gvAddData.DataBind();
                return;
            }
            AddData data = new AddData()
            {
                id            = "",
                pm            = this.gvGoodsData.SelectedRow.Cells[1].Text.Trim(),
                spec          = this.gvGoodsData.SelectedRow.Cells[2].Text.Trim(),
                cz            = this.gvGoodsData.SelectedRow.Cells[3].Text.Trim(),
                ys            = this.gvGoodsData.SelectedRow.Cells[4].Text.Trim(),
                goods_unit    = this.gvGoodsData.SelectedRow.Cells[5].Text.Trim(),
                pch           = this.gvGoodsData.SelectedRow.Cells[6].Text == "&nbsp;" ? "" : this.gvGoodsData.SelectedRow.Cells[6].Text.Trim(),
                hwh           = this.gvGoodsData.SelectedRow.Cells[7].Text == "&nbsp;" ? "" : this.gvGoodsData.SelectedRow.Cells[7].Text.Trim(),
                pdsl          = this.gvGoodsData.SelectedRow.Cells[12].Text == "&nbsp;" ? "0" : Convert.ToDecimal(this.gvGoodsData.SelectedRow.Cells[12].Text).ToString("0.##"),
                Price         = this.gvGoodsData.SelectedRow.Cells[10].Text == "&nbsp;" ? "0" : Convert.ToDecimal(this.gvGoodsData.SelectedRow.Cells[10].Text).ToString("0.##"),
                total         = (Convert.ToDecimal(this.gvGoodsData.SelectedRow.Cells[12].Text == "&nbsp;" ? "0" : Convert.ToDecimal(this.gvGoodsData.SelectedRow.Cells[12].Text).ToString("0.##")) * Convert.ToDecimal(this.gvGoodsData.SelectedRow.Cells[10].Text == "&nbsp;" ? "0" : Convert.ToDecimal(this.gvGoodsData.SelectedRow.Cells[10].Text).ToString("0.##"))).ToString("0.##"),
                customer_name = this.gvGoodsData.SelectedRow.Cells[13].Text.Trim(),
                s_id          = this.gvGoodsData.SelectedRow.Cells[14].Text.Trim(),
                b_id          = this.gvGoodsData.SelectedRow.Cells[15].Text.Trim()
            };

            lList.Insert(0, data);
            gvAddData.DataSource = lList;
            gvAddData.DataBind();
            (gvAddData.Rows[0].Cells[7].FindControl("txtpdsl") as TextBox).Attributes.Add("onfocus", "this.select();");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "focus", "<script>document.all.gvAddData_ctl02_txtpdsl.focus()</script>");
            gvGoodsData.DataSource = null;
            gvGoodsData.DataBind();
            gvAddData.Columns[11].Visible = true;
            gvAddData.Columns[12].Visible = false;
            trgoods.Visible = false;
        }