//提交之后回主页面
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserId"] == null)
            {
                Response.Redirect("/LogIn.ashx");
                return;
            }

            ReqGUID = Request["GUID"];
            Label_GUID.Text = ReqGUID;
            AfterSaleServiceSystem.DAL.dsRepairSheetTableAdapters.tb_repairsheetTableAdapter sheetadp =
                new AfterSaleServiceSystem.DAL.dsRepairSheetTableAdapters.tb_repairsheetTableAdapter();
            System.Data.DataRowCollection RsRows = sheetadp.GetDataByGUID(ReqGUID).Rows;
            if (RsRows.Count > 0)
            {
                FormView_Report.ChangeMode(FormViewMode.Edit);
                FormView_Report.DefaultMode = FormViewMode.Edit;

                AfterSaleServiceSystem.DAL.dsRepairSheet.tb_repairsheetRow RsRow =
                  (AfterSaleServiceSystem.DAL.dsRepairSheet.tb_repairsheetRow)RsRows[0];
                SheetId = RsRow.id;

                tb_reportsTableAdapter reportAdp = new tb_reportsTableAdapter();
                AfterSaleServiceSystem.DAL.dsReports.tb_reportsDataTable dtReports = reportAdp.GetDataBysheetid(SheetId);
                if (dtReports.Rows.Count > 0)
                {
                    AfterSaleServiceSystem.DAL.dsReports.tb_reportsRow rRow =
                  (AfterSaleServiceSystem.DAL.dsReports.tb_reportsRow)dtReports[0];
                    ReportId = rRow.id;
                }
            }

            if (!IsPostBack)
            {
                if (RsRows.Count == 0)
                {
                    FormView_Report.ChangeMode(FormViewMode.Edit);

                    //新建一条记录
                    sheetadp.InsertNewSheet(ReqGUID, string.Empty, string.Empty, 0, 0, 0, 0);

                    RsRows = sheetadp.GetDataByGUID(ReqGUID).Rows;
                    if (RsRows.Count > 0)
                    {
                        AfterSaleServiceSystem.DAL.dsRepairSheet.tb_repairsheetRow RsRow =
                          (AfterSaleServiceSystem.DAL.dsRepairSheet.tb_repairsheetRow)RsRows[0];
                        SheetId = RsRow.id;

                        tb_reportsTableAdapter reportAdp = new tb_reportsTableAdapter();

                        int userID = 0;
                        if (Session["authorityid"].ToString() == "1")
                        {
                            userID = Convert.ToInt32(Session["UserId"]);
                        }

                        reportAdp.Insert(userID, SheetId, false, DateTime.Today,
                            string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty,
                            string.Empty, 0, 0, 0, 0, null, null, string.Empty, string.Empty, null);

                        AfterSaleServiceSystem.DAL.dsReports.tb_reportsDataTable dtReports = reportAdp.GetDataBysheetid(SheetId);
                        if (dtReports.Rows.Count > 0)
                        {
                            AfterSaleServiceSystem.DAL.dsReports.tb_reportsRow rRow =
                          (AfterSaleServiceSystem.DAL.dsReports.tb_reportsRow)dtReports[0];
                            ReportId = rRow.id;
                        }
                    }
                }

                #region 绑定代理商
                tb_customTableAdapter custom = new tb_customTableAdapter();
                AfterSaleServiceSystem.DAL.dsCustomer.tb_customDataTable customDt = custom.GetData();
                ddlCustom.DataTextField = "agent";
                ddlCustom.DataValueField = "id";
                ddlCustom.DataSource = customDt;
                ddlCustom.DataBind();
                BindCustom();
                #endregion
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserId"] == null)
            {
                Response.Redirect("/LogIn.ashx");
                return;
            }
            try
            {
                sheetid = Convert.ToInt32(Request["id"]);

                #region 绑定客户数据
                tb_repairsheetTableAdapter sheet = new tb_repairsheetTableAdapter();
                dsRepairSheet.tb_repairsheetDataTable sheetDt = sheet.GetDataByid(sheetid);
                if (sheetDt != null && sheetDt.Rows.Count > 0)
                {
                    dsRepairSheet.tb_repairsheetRow row = (dsRepairSheet.tb_repairsheetRow)sheetDt.Rows[0];
                    tb_customTableAdapter custom = new tb_customTableAdapter();
                    AfterSaleServiceSystem.DAL.dsCustomer.tb_customDataTable customDt = custom.GetDataByid(Convert.ToInt32(row.customid));
                    FormView_custom.DataSource = customDt;
                    FormView_custom.DataBind();
                }
                #endregion

            }
            catch (Exception)
            {
                //
                throw;
            }

            Label_No.Text = sheetid.ToString();

            tb_reportsTableAdapter reports = new tb_reportsTableAdapter();

            if (reports.GetDataBysheetid(sheetid).Rows.Count > 0)
            {
                FormView_report.DefaultMode = FormViewMode.Edit;
            }
            else
                FormView_report.DefaultMode = FormViewMode.Insert;
        }