Beispiel #1
0
        protected void LinkButton1_Click1(object sender, EventArgs e)
        {
            if (Session["Orders"] != null)
            {
                if (Session["DioSell_OrderFP"] != null)
                {
                    Sell_OrderFPService mailSer = new Sell_OrderFPService();
                    var model = mailSer.GetModel(Convert.ToInt32(Session["DioSell_OrderFP"]));
                    txtFPNo.Text     = model.FPNo;
                    txtPOName.Text   = model.POName;
                    txtPONo.Text     = model.PONo;
                    txtSupplier.Text = model.GuestName;

                    lblPID.Text = model.Id.ToString();

                    Sell_OrderFPsService sonSer = new Sell_OrderFPsService();
                    var sonList = sonSer.GetListArray(" ID=" + Session["DioSell_OrderFP"]);
                    List <Sell_OrderFPBacks> POOrders = new List <Sell_OrderFPBacks>();
                    foreach (var m in sonList)
                    {
                        Sell_OrderFPBacks fpModel = new Sell_OrderFPBacks();
                        fpModel.Good_Model         = m.Good_Model;
                        fpModel.GoodName           = m.GoodName;
                        fpModel.GoodNo             = m.GoodNo;
                        fpModel.GoodNum            = m.GoodNum;
                        fpModel.GoodPrice          = m.GoodPrice;
                        fpModel.GoodRemark         = model.Remark;
                        fpModel.GoodSellPrice      = m.GoodSellPrice;
                        fpModel.GoodSellPriceTotal = m.GoodSellPriceTotal;
                        fpModel.GoodSpec           = m.GoodSpec;
                        fpModel.GoodTypeSmName     = m.GoodTypeSmName;
                        fpModel.GoodUnit           = m.GoodUnit;
                        fpModel.GooId       = m.GooId;
                        fpModel.FPId        = m.Ids;
                        fpModel.SellOutPONO = "";
                        fpModel.Total       = m.Total;
                        POOrders.Add(fpModel);
                    }
                    Session["Orders"] = POOrders;
                    Session["Sell_OrderOutHousesViewSession"] = null;
                    gvList.DataSource = POOrders;
                    gvList.DataBind();
                }
            }
        }
        protected void gvMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "select")
            {
                var pono = DBHelp.ExeScalar("select pono from Sell_OrderFP where id=" + e.CommandArgument);
                CG_POOrderService orderSer = new CG_POOrderService();

                string sql = string.Format("select sum(Total) from Sell_OrderFP where pono='{0}' and Status='通过'", pono);
                try
                {
                    lblTotal.Text = DBHelp.ExeScalar(sql).ToString();
                }
                catch (Exception)
                {
                    lblTotal.Text = "0";
                }
                var list = orderSer.GetOrder_ToInvoice_1(string.Format(" PONo='{0}'", pono));
                if (list.Count > 0)
                {
                    lblPOTotal.Text = "项目(" + pono + ")---" + (list[0].POTotal - list[0].TuiTotal).ToString();
                }
                else
                {
                    lblPOTotal.Text = "0";
                }

                List <Sell_OrderFPs> orders = ordersSer.GetListArray(" 1=1 and Sell_OrderFPs.id=" + e.CommandArgument);

                ViewState["Orders"] = orders;
                gvList.DataSource   = orders;
                gvList.DataBind();
            }
            else if (e.CommandName == "ReEdit")
            {
                //是否是此单据的申请人
                var model = POSer.GetModel(Convert.ToInt32(e.CommandArgument));

                if (Session["currentUserId"].ToString() != model.CreateUserId.ToString())
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('必须由原单据申请人 重新发起,其他人不能重新提交编辑!');</script>");
                    return;
                }

                //首先单子要先通过

                if (model != null && model.Status == "执行中")
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据还在执行中不能编辑!');</script>");
                    return;
                }



                //string check = string.Format("select  count(*) from Sell_OrderFPBack  where FPNo in ( select FPNo from Sell_OrderFP where id={0})", model.Id);
                //if (Convert.ToInt32(DBHelp.ExeScalar(check)) > 0)
                //{
                //    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('发票签回单需要删除!');</script>");
                //    return;
                //}

                // check = string.Format("select count(*) from TB_ToInvoice  where FPId={0}", model.Id);
                //if (Convert.ToInt32(DBHelp.ExeScalar(check)) > 0)
                //{
                //    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据已经被用款单使用!');</script>");
                //    return;
                //}
                string type = "销售发票";
                if (model.NowGuid != "")
                {
                    type = "销售发票修改";
                }
                string sql = string.Format("select pro_Id from A_ProInfo where pro_Type='{0}'", type);

                string efromId = string.Format("select id from tb_EForm where alle_id={0} and proId=(select pro_Id from A_ProInfo where pro_Type='{1}')", e.CommandArgument, type);
                string url     = "~/JXC/WFSell_OrderFP.aspx?ProId=" + DBHelp.ExeScalar(sql) + "&allE_id=" + e.CommandArgument + "&EForm_Id=" + DBHelp.ExeScalar(efromId) + "&&ReAudit=true";
                Response.Redirect(url);
            }
            else if (e.CommandName == "Del")
            {
                //是否是此单据的申请人
                var model = POSer.GetModel(Convert.ToInt32(e.CommandArgument));

                if (Session["currentUserId"].ToString() != model.CreateUserId.ToString())
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('必须由原单据申请人 重新发起,其他人不能重新提交编辑!');</script>");
                    return;
                }

                //首先单子要先通过

                if (model != null && model.Status == "执行中")
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据还在执行中不能编辑!');</script>");
                    return;
                }
                string check = string.Format("select count(*) from TB_ToInvoice  where FPId={0}  AND State<>'不通过'", model.Id);
                if (Convert.ToInt32(DBHelp.ExeScalar(check)) > 0)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('有到款记录,请先删除到款!');</script>");
                    return;
                }

                check = string.Format(" select count(*) from TB_ToInvoice where FPNo = '{0}'  AND State<>'不通过'", model.FPNo);
                if (Convert.ToInt32(DBHelp.ExeScalar(check)) > 0)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('有到款记录,请先删除到款!');</script>");
                    return;
                }

                //string check = string.Format("select  count(*) from Sell_OrderFPBack  where FPNo in ( select FPNo from Sell_OrderFP where id={0})", model.Id);
                //if (Convert.ToInt32(DBHelp.ExeScalar(check)) > 0)
                //{
                //    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('发票签回单需要删除!');</script>");
                //    return;
                //}

                // check = string.Format("select count(*) from TB_ToInvoice  where FPId={0}", model.Id);
                //if (Convert.ToInt32(DBHelp.ExeScalar(check)) > 0)
                //{
                //    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据已经被用款单使用!');</script>");
                //    return;
                //}
                string type = "销售发票";
                if (model.NowGuid != "")
                {
                    type = "销售发票修改";
                }
                string sql     = string.Format("select pro_Id from A_ProInfo where pro_Type='{0}'", type);
                string efromId = string.Format("select id from tb_EForm where alle_id={0} and proId=(select pro_Id from A_ProInfo where pro_Type='{1}')", e.CommandArgument, type);
                var    id      = DBHelp.ExeScalar(efromId).ToString();
                var    aa      = DBHelp.ExeScalar(string.Format("select top 1 id from tb_EForm where allE_id={0} and proId=37", model.Id));
                if (aa != null && aa != DBNull.Value)
                {
                    id = aa.ToString();
                }
                string url = "~/JXC/WFSell_OrderFP.aspx?ProId=37&allE_id=" + e.CommandArgument + "&EForm_Id=" + id + "&&IsDelete=true";
                Response.Redirect(url);
            }
        }
        protected void gvMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "select")
            {
                var pono = DBHelp.ExeScalar("select pono from Sell_OrderFP where id=" + e.CommandArgument);
                CG_POOrderService orderSer = new CG_POOrderService();
                string            sql      = string.Format("select sum(Total) from Sell_OrderFP where pono='{0}' and Status='通过'", pono);
                try
                {
                    lblTotal.Text = DBHelp.ExeScalar(sql).ToString();
                }
                catch (Exception)
                {
                    lblTotal.Text = "0";
                }

                var list = orderSer.GetOrder_ToInvoice_1(string.Format(" PONo='{0}'", pono));
                if (list.Count > 0)
                {
                    lblPOTotal.Text = "项目(" + pono + ")---" + (list[0].POTotal - list[0].TuiTotal).ToString();
                }
                else
                {
                    lblPOTotal.Text = "0";
                }


                List <Sell_OrderFPs> orders = ordersSer.GetListArray(" 1=1 and Sell_OrderFPs.id=" + e.CommandArgument);

                ViewState["Orders"] = orders;
                gvList.DataSource   = orders;
                gvList.DataBind();
            }
            else if (e.CommandName == "ReEdit")
            {
                //是否是此单据的申请人
                var model = POSer.GetModel(Convert.ToInt32(e.CommandArgument));

                if (Session["currentUserId"].ToString() != model.CreateUserId.ToString())
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('必须由原单据申请人 重新发起,其他人不能重新提交编辑!');</script>");
                    return;
                }

                //首先单子要先通过

                if (model != null && model.Status == "通过")
                {
                }
                else
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据必须已经审批通过才能重新编辑!');</script>");
                    return;
                }

                string check = string.Format("select count(*) from TB_ToInvoice  where FPId={0}", model.Id);
                if (Convert.ToInt32(DBHelp.ExeScalar(check)) > 0)
                {
                    base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('此单据已经被用款单使用!');</script>");
                    return;
                }

                string sql = "select pro_Id from A_ProInfo where pro_Type='销售发票'";

                string efromId = string.Format("select id from tb_EForm where alle_id={0} and proId=(select pro_Id from A_ProInfo where pro_Type='销售发票')", e.CommandArgument);
                string url     = "~/JXC/WFSell_OrderFP.aspx?ProId=" + DBHelp.ExeScalar(sql) + "&allE_id=" + e.CommandArgument + "&EForm_Id=" + DBHelp.ExeScalar(efromId) + "&&ReAudit=true&Tui=true";
                Response.Redirect(url);


                //没有做过检验单
            }
        }