コード例 #1
0
        protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#EAF1FD',this.style.fontWeight='';");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");

                TB_HouseGoods model = e.Row.DataItem as TB_HouseGoods;
                SumOrders.GoodNum += model.GoodNum;
                SumOrders.Total   += model.Total;
                if (model.GoodNum > model.SumKuXuCai)
                {
                    e.Row.BackColor = ColorTranslator.FromHtml("#FFF0F5");
                }
            }
            ImageButton btnEdit = e.Row.FindControl("btnEdit") as ImageButton;

            if (btnEdit != null)
            {
                string val = string.Format("javascript:window.showModalDialog('CG_Orders.aspx?index={0}',null,'dialogWidth:500px;dialogHeight:450px;help:no;status:no')", e.Row.DataItemIndex);
                btnEdit.Attributes.Add("onclick", val);
            }


            // 合计
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                setValue(e.Row.FindControl("lblGoodName") as Label, "合计");                                  //合计
                setValue(e.Row.FindControl("lblNum") as Label, SumOrders.GoodNum.ToString());               //数量
                setValue(e.Row.FindControl("lblTotal") as Label, string.Format("{0:n4}", SumOrders.Total)); //成本总额
            }
        }
コード例 #2
0
        private void Show()
        {
            SumOrders = new TB_HouseGoods();
            if (!string.IsNullOrEmpty(txtNum.Text))
            {
                try
                {
                    Convert.ToDecimal(txtNum.Text);
                }
                catch (Exception)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('数量格式有误!');</script>");

                    return;
                }
            }
            string sql = " 1=1 ";

            if (txtGoodAvgPrice.Text != "")
            {
                try
                {
                    if (Convert.ToDecimal(txtGoodAvgPrice.Text) <= 0)
                    {
                        base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('商品均价必须大于0!');</script>");

                        return;
                    }
                    sql += string.Format(" and GoodAvgPrice {0} {1}", ddlPrice.Text, txtGoodAvgPrice.Text);
                }
                catch (Exception)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('商品均价格式有误!');</script>");

                    return;
                }
            }


            if (txtZhuJi.Text != "")
            {
                //string goodName = txtZhuJi.Text.Replace(@"\", ",");

                string[] allList = txtZhuJi.Text.Split('\\');
                if (allList.Length != 7)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('商品格式不正确!');</script>");
                    return;
                }

                int goodId = goodsSer.GetGoodId(allList[1], allList[3], allList[4], allList[2], allList[5]);
                if (goodId == 0)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('你填写的商品不存在!');</script>");

                    return;
                }

                sql += string.Format(" and TB_HouseGoods.GoodId={0}", goodId);
            }

            if (!string.IsNullOrEmpty(txtNum.Text))
            {
                sql += string.Format(" and GoodNum{0}{1}", ddlFuHao.SelectedItem.Text, txtNum.Text);
            }
            if (ddlGoodSmType.Text != "" && ddlGoodType.Text != "")
            {
                sql += string.Format(" and GoodTypeSmName ='{0}' ", ddlGoodSmType.SelectedItem.Value);
            }
            else
            {
                if (ddlGoodSmType.Text != "" && ddlGoodType.Text == "")
                {
                    sql += string.Format(" and GoodTypeSmName ='{0}' ", ddlGoodSmType.SelectedItem.Value);
                }
                if (ddlGoodSmType.Text == "" && ddlGoodType.Text != "")
                {
                    sql += string.Format(" and  GoodTypeName ='{0}'", ddlGoodType.SelectedItem.Value);
                }
            }

            if (ddlHouse.Text != "" && ddlHouse.Text != "0")
            {
                sql += string.Format(" and HouseId ={0}", ddlHouse.SelectedItem.Value);
            }


            if (txtGoodNo.Text != "")
            {
                sql += string.Format(" and TB_Good.GoodNo like '%{0}%'", txtGoodNo.Text);
            }
            if (txtNameOrTypeOrSpec.Text != "" && txtNameOrTypeOrSpecTwo.Text != "")
            {
                sql += string.Format(" and ((GoodTypeSmName like '%{0}%' or GoodName  like '%{0}%' or GoodSpec like '%{0}%') or (GoodTypeSmName like '%{1}%' or GoodName  like '%{1}%' or GoodSpec like '%{1}%'))",
                                     txtNameOrTypeOrSpec.Text, txtNameOrTypeOrSpecTwo.Text);
            }
            else if (txtNameOrTypeOrSpec.Text != "" || txtNameOrTypeOrSpecTwo.Text != "")
            {
                var NameOrTypeOrSpec = "";
                if (txtNameOrTypeOrSpec.Text != "")
                {
                    NameOrTypeOrSpec = txtNameOrTypeOrSpec.Text;
                }
                if (txtNameOrTypeOrSpecTwo.Text != "")
                {
                    NameOrTypeOrSpec = txtNameOrTypeOrSpecTwo.Text;
                }

                sql += string.Format(" and (GoodTypeSmName like '%{0}%' or GoodName  like '%{0}%' or GoodSpec like '%{0}%')",
                                     NameOrTypeOrSpec);
            }


            if (txtNameOrTypeOrSpec1.Text != "" && txtNameOrTypeOrSpecTwo1.Text != "")
            {
                sql += string.Format(" and ((GoodTypeSmName like '%{0}%' or GoodName  like '%{0}%' or GoodSpec like '%{0}%') and (GoodTypeSmName like '%{1}%' or GoodName  like '%{1}%' or GoodSpec like '%{1}%'))",
                                     txtNameOrTypeOrSpec1.Text, txtNameOrTypeOrSpecTwo1.Text);
            }
            else if (txtNameOrTypeOrSpec1.Text != "" || txtNameOrTypeOrSpecTwo1.Text != "")
            {
                var NameOrTypeOrSpec = "";
                if (txtNameOrTypeOrSpec1.Text != "")
                {
                    NameOrTypeOrSpec = txtNameOrTypeOrSpec1.Text;
                }
                if (txtNameOrTypeOrSpecTwo1.Text != "")
                {
                    NameOrTypeOrSpec = txtNameOrTypeOrSpecTwo1.Text;
                }

                sql += string.Format(" and (GoodTypeSmName like '%{0}%' or GoodName  like '%{0}%' or GoodSpec like '%{0}%')",
                                     NameOrTypeOrSpec);
            }
            if (cbEmpty.Checked == false)
            {
                if (ddlArea.Text != "")
                {
                    sql += string.Format(" and GoodArea='{0}'", ddlArea.Text);
                }
                if (ddlNumber.Text != "")
                {
                    sql += string.Format(" and GoodNumber='{0}'", ddlNumber.Text);
                }
                if (ddlRow.Text != "")
                {
                    sql += string.Format(" and GoodRow='{0}'", ddlRow.Text);
                }
                if (ddlCol.Text != "")
                {
                    sql += string.Format(" and GoodCol='{0}'", ddlCol.Text);
                }
            }
            else
            {
                sql += string.Format(" and GoodAreaNumber=''");
            }

            if (txtCaiKuNum.Text != "")
            {
                if (CommHelp.VerifesToNum(txtCaiKuNum.Text) == false)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('采购需出格式出错!');</script>");
                    return;
                }
                sql += string.Format("and isnull(SumKuXuCai,0){0}{1}", ddlCaiKuNum.Text, txtCaiKuNum.Text);
            }

            if (txtZhiLiuNum.Text != "")
            {
                if (CommHelp.VerifesToNum(txtZhiLiuNum.Text) == false)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('滞留库存格式出错!');</script>");
                    return;
                }
                sql += string.Format("and (isnull(GoodNum,0)-isnull(SumKuXuCai,0)+isnull(CaiNotCheckNum,0)){0}{1}", ddlZhiLiuNum.Text, txtZhiLiuNum.Text);
            }

            List <TB_HouseGoods> gooQGooddList = this.houseSer.GetListArrayToInvoice(sql);

            lblHadInvoice.Text     = string.Format("{0:n2}", gooQGooddList.Sum(t => t.HadInvoice));
            lblNoInvoice.Text      = string.Format("{0:n2}", gooQGooddList.Sum(t => t.NoInvoice));
            this.gvList.DataSource = gooQGooddList;
            this.gvList.DataBind();
        }