protected void gvPersonalReimburseDetails_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     // 对数据列进行赋值
     if (e.Row.RowType == DataControlRowType.DataRow) {
         if ((e.Row.RowState & DataControlRowState.Edit) != DataControlRowState.Edit) {
             DataRowView drvDetail = (DataRowView)e.Row.DataItem;
             FormDS.FormPersonalReimburseDetailRow row = (FormDS.FormPersonalReimburseDetailRow)drvDetail.Row;
             TotalRMBFee = decimal.Round((TotalRMBFee + row.RMB), 2);
             TotalFee = decimal.Round((TotalFee + row.ApplyAmount), 2);
             //超费用标准
             Label lblRMB = (Label)e.Row.FindControl("lblRMB");
             decimal limit = new MasterDataBLL().GetLimitForOverStandard(0, int.Parse(ViewState["StaffLevelID"].ToString()), row.ManageExpenseItemID, row.RMB);
             if (limit != 0) {
                 lblRMB.Attributes.Add("title", PageUtility.TransferLanguage(this.Page, "超过费用标准 ¥" + limit, "Over Cost Standard ¥" + limit));
                 lblRMB.ForeColor = System.Drawing.Color.Red;
             }
         }
     }
     if (e.Row.RowType == DataControlRowType.Footer) {
         Label lblTotal = (Label)e.Row.FindControl("lblTotal");
         lblTotal.Text = TotalFee.ToString("N");
         Label lblTotalRMB = (Label)e.Row.FindControl("lblTotalRMB");
         lblTotalRMB.Text = TotalRMBFee.ToString("N");
     }
 }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        try {
            //��ȡURL���ݲ���
            string strMode = this.Request.QueryString["mode"] == null ? "" : this.Request.QueryString["mode"].ToString();
            string strID = this.Request.QueryString["id"] == null ? "" : this.Request.QueryString["id"].ToString();

            //���ÿؼ�״̬
            setControlStatus(strMode);

            // ��ȡҳ��������Ϣ
            if (!strMode.Equals("") && !strMode.Equals("add") && !strID.Equals("")) {
                MasterDataBLL bll = new MasterDataBLL();
                ERS.BulletinDataTable dt = bll.GetBulletinById(Convert.ToInt32(strID));
                if (dt != null && dt.Count > 0) {
                    ERS.BulletinRow dr = dt[0];
                    txtTitle.Text = dr.BulletinTitle.ToString();
                    lblCreator.Text = dr.Creator.ToString();
                    lblCreateTime.Text = dr.CreateTime.ToString();
                    txtContent.Text = dr.BulletinContent.ToString();
                }
            }
        } catch (Exception ex) {
            PageUtility.DealWithException(this, ex);
        }
    }
 //��ѯ�����������ô���
 public void InitCustomerTimesLimit()
 {
     ExpenseItemRemainTimes = new Dictionary<int, object[]>();
     int CustomerID = int.Parse(this.ViewState["CustomerID"].ToString());
     int SubCategoryID = int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString());
     DateTime Period = DateTime.Parse(this.ViewState["EndPeriod"].ToString());
     ERS.ExpenseItemDataTable ExpenseTable = new MasterDataBLL().GetExpenseItemBySubCateId(SubCategoryID);
     object[] tempArray;
     object[] tempArray1 = new object[2];
     foreach (ERS.ExpenseItemRow item in ExpenseTable.Rows) {
         if (item.IsInContract) {
             tempArray = this.SalesApplyBLL.GetCustomerTimesLimitByParameter(CustomerID, item.ExpenseItemID, Period.Year);
             if ((bool)tempArray[0]) {
                 tempArray1[0] = (bool)tempArray[0];
                 tempArray1[1] = int.Parse(tempArray[2].ToString());
                 ExpenseItemRemainTimes.Add(item.ExpenseItemID, tempArray1);
             } else {
                 tempArray1[0] = false;
                 tempArray1[1] = int.Parse(tempArray[2].ToString());
                 ExpenseItemRemainTimes.Add(item.ExpenseItemID, tempArray1);
             }
         }
     }
     this.ViewState["ExpenseItemRemainTimes"] = ExpenseItemRemainTimes;
 }
Exemple #4
0
 public string GetCompanyCode(object ID)
 {
     MasterDataBLL msdBLL = new MasterDataBLL();
     MasterData.VendorTypeRow vType = msdBLL.GetVendorTypeById((int)ID);
     MasterData.CompanyRow company = msdBLL.GetCompanyById(vType.CompanyID);
     return company.CompanyCode;
 }
Exemple #5
0
 public string GetCompanyID()
 {
     MasterDataBLL mdBLL = new MasterDataBLL();
     OUTreeBLL otBLL = new OUTreeBLL();
     AuthorizationDS.PositionRow rowPosition = (AuthorizationDS.PositionRow)Session["Position"];
     AuthorizationDS.OrganizationUnitRow rowOU = GetNearestCostCenter(rowPosition.OrganizationUnitId);
     MasterData.CostCenterRow rowCostCenter = mdBLL.GetCostCenterById(rowOU.CostCenterID);
     return rowCostCenter.CompanyID.ToString();
 }
Exemple #6
0
 protected bool IsBusinessProxy(int ProxyUserID, DateTime SubmitDate)
 {
     AuthorizationDS.StuffUserRow stuffUser = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
     ERS.ProxyReimburseDataTable tbProxy = new MasterDataBLL().GetProxyReimburseByParameter(ProxyUserID,stuffUser.StuffUserId , SubmitDate);
     if (tbProxy != null && tbProxy.Count > 0) {
         return true;
     }
     return false;
 }
 public string GetExpenseItemNameByID(object expenseItemID)
 {
     if (expenseItemID.ToString() != string.Empty) {
         int id = Convert.ToInt32(expenseItemID);
         ERS.ExpenseItemRow row = new MasterDataBLL().GetExpenseItemByID(id);
         return row.AccountingCode + "--" + row.ExpenseItemName;
     } else {
         return null;
     }
 }
 public string GetProductNameByID(object skuID)
 {
     if (skuID.ToString() != string.Empty) {
         int id = Convert.ToInt32(skuID);
         ERS.SKURow sku = new MasterDataBLL().GetSKUById(id);
         return sku.SKUNo + '-' + sku.SKUName + "-" + sku.Spec;
     } else {
         return null;
     }
 }
Exemple #9
0
        private void ImporterData(object source, System.Timers.ElapsedEventArgs e)
        {
            String FilePath = ConfigurationManager.AppSettings["ImporterService.FilePath"];
            String BakPath = ConfigurationManager.AppSettings["ImporterService.BakPath"];
            int hour = int.Parse(ConfigurationManager.AppSettings["ImporterService.hour"]);
            if (hour == DateTime.Now.Hour) {
                MasterDataBLL masterdatabll = new MasterDataBLL();
                LogBLL logbll = new LogBLL();
                DirectoryInfo mydir = new DirectoryInfo(FilePath);
                //0 SKU  1 Item 2 Customer
                FileSystemInfo[] SKUfile = mydir.GetFileSystemInfos("IIM*");
                if (SKUfile.Length > 0) {
                    ImportTxtData(0, SKUfile);
                } else {
                    int logId = logbll.InsertImportLog(0, "未找到文件", 1, 0, 0, 1);
                    logbll.InsertImportLogDetail(logId, 0, "未找到SKU文件!");
                }
                FileSystemInfo[] Itemfile = mydir.GetFileSystemInfos("HPC*");
                if (Itemfile.Length > 0) {
                    ImportTxtData(1, Itemfile);
                } else {
                    int logId = logbll.InsertImportLog(1, "未找到文件", 1, 0, 0, 1);
                    logbll.InsertImportLogDetail(logId, 0, "未找到Item文件!");
                }
                FileSystemInfo[] Customerfile = mydir.GetFileSystemInfos("RCM*");
                if (Customerfile.Length > 0) {
                    ImportTxtData(2, Customerfile);
                } else {
                    int logId = logbll.InsertImportLog(2, "未找到文件", 1, 0, 0, 1);
                    logbll.InsertImportLogDetail(logId, 0, "未找到Customer文件!");
                }

                //FileSystemInfo[] DeliveryGoods = mydir.GetFileSystemInfos("DeliveryGoods*");
                //if (DeliveryGoods.Length > 0) {
                //    ImportTxtData(3, Customerfile);
                //} else {
                //    int logId = logbll.InsertImportLog(3, "未找到文件", 1, 0, 0, 1);
                //    logbll.InsertImportLogDetail(logId, 0, "未找到Delivery Goods文件!");
                //}

                FileSystemInfo[] APHPayment = mydir.GetFileSystemInfos("APHPAY*");
                if (APHPayment.Length > 0) {
                    ImportTxtData(4, APHPayment);
                } else {
                    int logId = logbll.InsertImportLog(4, "未找到文件", 1, 0, 0, 1);
                    logbll.InsertImportLogDetail(logId, 0, "未找到APHPAY文件!");
                }

                foreach (FileSystemInfo file in mydir.GetFileSystemInfos()) {
                    File.Move(file.FullName, BakPath + file.Name);
                }
            }
        }
Exemple #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.Page.Title = "ϵͳ����";
     MasterDataBLL bll = new MasterDataBLL();
     ERS.BulletinRow bulletin = bll.GetBulletinById(int.Parse(Request["ObjectId"]))[0];
     this.BulletinTitleLabel.Text = bulletin.BulletinTitle;
     this.BulletinContentCtl.Text = bulletin.BulletinContent;
     this.CreateTimeLabel.Text = bulletin.CreateTime.ToString("yyyy-MM-dd");
     if (!bulletin.IsAttachFileNameNull())
         this.ViewUCFileUpload.AttachmentFileName = bulletin.AttachFileName;
     if (!bulletin.IsRealAttachFileNameNull())
         this.ViewUCFileUpload.RealAttachmentFileName = bulletin.RealAttachFileName;
 }
Exemple #11
0
    public bool IsSubmitValid()
    {
        if (this.VATRateDDL.SelectedValue != "0") {
            MasterData.VatTypeRow VATRate = new MasterDataBLL().GetVatTypeById(int.Parse(this.VATRateDDL.SelectedValue))[0];
            if (VATRate.HasTax && (this.AMTTaxCtl.Text == string.Empty || this.AMTTaxCtl.Text == "0")) {
                PageUtility.ShowModelDlg(this.Page, "请录入税金!", "please key in tax amount");
                return false;
            }
            if (!VATRate.HasTax && this.AMTTaxCtl.Text != string.Empty && this.AMTTaxCtl.Text != "0") {
                PageUtility.ShowModelDlg(this.Page, "您选择的税率类型没有税金!", "there is no tax regarding the VAT rate you selected");
                return false;
            }
        } else {
            PageUtility.ShowModelDlg(this.Page, "请选择税率类型!", "please select VAT Rate");
            return false;
        }
        if (this.UCExpectPaymentDateCtl.SelectedDate == "") {
            PageUtility.ShowModelDlg(this.Page, "请录入期望支付日期!", "please key in expect payment date ");
            return false;
        }

        if (this.gvDetails.Rows.Count == 0) {
            PageUtility.ShowModelDlg(this.Page, "必须录入费用明细信息","please key in detail info");
            return false;
        }
        //判断是否录入了发票
        MasterData.InvoiceStatusRow row = new InvoiceStatusTableAdapter().GetDataByID(int.Parse(this.InvoiceStatusDDL.SelectedValue))[0];
        if (row.NeedInvoice) {
            if (this.gvInvoice.Rows.Count == 0) {
                PageUtility.ShowModelDlg(this.Page, "请录入发票信息!", "please key in invoice info");
                return false;
            } else {
                if (decimal.Parse(this.ViewState["InvoiceFeeTotal"].ToString()) < decimal.Parse(this.ViewState["TotalApplyAmount"].ToString())) {
                    PageUtility.ShowModelDlg(this.Page, "发票金额不得小于支付金额!", "the amount of invoice should not be less than the payment");
                    return false;
                }
            }
        }
        if (this.PaymentTermCtl.Text == string.Empty) {
            PageUtility.ShowModelDlg(this.Page, "请录入账期!", "please key in payment terms");
            return false;
        }
        if (string.IsNullOrEmpty(this.RemarkCtl.Text)) {
            PageUtility.ShowModelDlg(this.Page, "请录入备注!", "please key in remark");
            return false;
        }
        return true;
    }
Exemple #12
0
 public bool IsSubmitValid()
 {
     if (this.VATRateDDL.SelectedValue != "0") {
         MasterData.VatTypeRow VATRate = new MasterDataBLL().GetVatTypeById(int.Parse(this.VATRateDDL.SelectedValue))[0];
         if (VATRate.HasTax && (this.AMTTaxCtl.Text == string.Empty || this.AMTTaxCtl.Text == "0")) {
             PageUtility.ShowModelDlg(this.Page, "请录入税金!", "please key in tax amount");
             return false;
         }
     } else {
         PageUtility.ShowModelDlg(this.Page, "请选择税率类型!", "please select VAT Rate");
         return false;
     }
     if (this.AmountCtl.Text == string.Empty) {
         PageUtility.ShowModelDlg(this.Page, "请录入本次支付金额!", "please key in payment amount");
         return false;
     }
     if (this.UCExpectPaymentDateCtl.SelectedDate == "") {
         PageUtility.ShowModelDlg(this.Page, "请录入期望支付日期!", "please key in expect payment date ");
         return false;
     }
     //判断是否录入了发票
     MasterData.InvoiceStatusRow row = new InvoiceStatusTableAdapter().GetDataByID(int.Parse(this.InvoiceStatusDDL.SelectedValue))[0];
     if (row.NeedInvoice) {
         if (this.gvInvoice.Rows.Count == 0) {
             PageUtility.ShowModelDlg(this.Page, "请录入发票信息!", "please key in invoice info");
             return false;
         } else {
             decimal AmountRMB = decimal.Round(decimal.Parse(this.ViewState["ExchangeRate"].ToString()) * decimal.Parse(this.AmountCtl.Text), 2);
             if (decimal.Parse(this.ViewState["InvoiceFeeTotal"].ToString()) < AmountRMB) {
                 PageUtility.ShowModelDlg(this.Page, "发票金额不得小于支付金额!", "the amount of invoice should not be less than the payment");
                 return false;
             }
         }
     }
     if (string.IsNullOrEmpty(RemarkCtl.Text)) {
         PageUtility.ShowModelDlg(this.Page, "请录入备注!", "please key in remark ");
         return false;
     }
     return true;
 }
Exemple #13
0
 public static bool CheckPeriod(int FormID)
 {
     FormDS.FormRow rowForm = new FormSaleBLL().GetFormByID(FormID)[0];
     DateTime Period = DateTime.Now;
     switch (rowForm.FormTypeID) {
         case (int)SystemEnums.FormType.FormMarketingApply:
             Period = new FormMarketingBLL().GetFormMarketingApplyByID(rowForm.FormID)[0].FPeriod;
             break;
         case (int)SystemEnums.FormType.RDApply:
             Period = new FormRDBLL().GetFormRDApplyByID(rowForm.FormID)[0].FPeriod;
             break;
         case (int)SystemEnums.FormType.SaleApply:
             Period = new FormSaleBLL().GetFormSaleApplyByID(rowForm.FormID)[0].FPeriod;
             break;
     }
     MasterData.PeriodSaleDataTable tbPeriodSale = new MasterDataBLL().GetPeriodSale();
     foreach (var rowPeriodSale in tbPeriodSale) {
         if (rowPeriodSale.PeriodSale == Period) {
             return false;
         }
     }
     return true;
 }
Exemple #14
0
    protected void NextButton_Click(object sender, EventArgs e)
    {
        if (PeriodDDL.SelectedValue == "0") {
            PageUtility.ShowModelDlg(this, "请选择费用期间!", "please select period");
            return;
        }
        if (string.IsNullOrEmpty(UCCustomer.CustomerID)) {
            PageUtility.ShowModelDlg(this, "请选择客户!", "please select customer");
            return;
        }
        if (BrandDDL.SelectedValue == "0") {
            PageUtility.ShowModelDlg(this, "请选择Brand!", "please select brand");
            return;
        }
        if (ddlExpenseCategory.SelectedValue == "0") {
            PageUtility.ShowModelDlg(this, "请选择费用大类!", "please select Expense Category");
            return;
        }
        if (ExpenseSubCategoryDDL.SelectedValue == "0") {
            PageUtility.ShowModelDlg(this, "请选择费用小类!", "please select Expense Sub Category");
            return;
        }
        MasterData.ExpenseSubCategoryRow subCategory = new MasterDataBLL().GetExpenseSubCategoryById(int.Parse(this.ExpenseSubCategoryDDL.SelectedValue));

        switch (subCategory.PageType) {
            case (int)SystemEnums.PageType.ActivityApply:
                this.Response.Redirect("~/FormSale/ActivityApply.aspx?PeriodSaleID=" + this.PeriodDDL.SelectedValue + "&CustomerID=" + this.UCCustomer.CustomerID + "&BrandID=" + BrandDDL.SelectedValue + "&ExpenseSubCategoryID=" + ExpenseSubCategoryDDL.SelectedValue + "&CurrencyID=" + this.CurrencyDDL.SelectedValue);
                break;
            case (int)SystemEnums.PageType.NoActivityApply:
                this.Response.Redirect("~/FormSale/NoActivityApply.aspx?PeriodSaleID=" + this.PeriodDDL.SelectedValue + "&CustomerID=" + this.UCCustomer.CustomerID + "&BrandID=" + BrandDDL.SelectedValue + "&ExpenseSubCategoryID=" + ExpenseSubCategoryDDL.SelectedValue + "&CurrencyID=" + this.CurrencyDDL.SelectedValue);
                break;
            case (int)SystemEnums.PageType.SaleSampleRequest:
                this.Response.Redirect("~/SampleRequest/SaleSampleRequestApply.aspx?PeriodSaleID=" + this.PeriodDDL.SelectedValue + "&CustomerID=" + this.UCCustomer.CustomerID + "&BrandID=" + BrandDDL.SelectedValue + "&ExpenseSubCategoryID=" + ExpenseSubCategoryDDL.SelectedValue + "&CurrencyID=" + this.CurrencyDDL.SelectedValue);
                break;
        }
    }
Exemple #15
0
    protected void odsExpenseDetails_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
    {
        DropDownList newExpenseItemDDL = (DropDownList)this.fvExpenseDetails.FindControl("newExpenseItemDDL");
        MasterData.ExpenseItemRow expenseItem = new MasterDataBLL().GetExpenseItemById(int.Parse(newExpenseItemDDL.SelectedValue));
        TextBox newShopNameCtl = (TextBox)this.fvExpenseDetails.FindControl("newShopNameCtl");
        if (expenseItem.NeedShopInfo && newShopNameCtl.Text == string.Empty) {
            PageUtility.ShowModelDlg(this.Page, "请录入门店信息", "please key in shop name");
            e.Cancel = true;
            return;
        }

        TextBox newAmountCtl = (TextBox)this.fvExpenseDetails.FindControl("newAmountCtl");
        e.InputParameters["AmountRMB"] = decimal.Round(decimal.Parse(newAmountCtl.Text) * decimal.Parse(this.ViewState["ExchangeRate"].ToString()), 2);
        if (this.ViewState["ObjectId"] != null) {
            e.InputParameters["FormSaleApplyID"] = int.Parse(this.ViewState["ObjectId"].ToString());
        }
    }
Exemple #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!this.IsPostBack) {
            String title = this.GetLocalResourceObject("titleLabel.Text").ToString();
            PageUtility.SetContentTitle(this.Page, title);

            // 用户信息,职位信息
            AuthorizationDS.StuffUserRow stuffUser = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
            AuthorizationDS.PositionRow rowUserPosition = (AuthorizationDS.PositionRow)Session["Position"];

            if (new StuffUserBLL().GetCostCenterIDByPositionID(rowUserPosition.PositionId) == 0) {
                this.Session["ErrorInfor"] = "未找到成本中心,请联系管理员";
                Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
            }
            this.ViewState["StuffUserID"] = stuffUser.StuffUserId;
            this.ViewState["PositionID"] = rowUserPosition.PositionId;

            this.StuffNameCtl.Text = CommonUtility.GetStaffFullName(stuffUser);
            this.PositionNameCtl.Text = rowUserPosition.PositionName;
            this.DepartmentNameCtl.Text = new OUTreeBLL().GetOrganizationUnitById(rowUserPosition.OrganizationUnitId).OrganizationUnitName;
            this.ViewState["DepartmentID"] = rowUserPosition.OrganizationUnitId;
            this.StuffNoCtl.Text = stuffUser.IsStuffNoNull() ? "" : stuffUser.StuffNo;
            this.AttendDateCtl.Text = stuffUser.AttendDate.ToShortDateString();

            if (this.Request["RejectObjectID"] != null) {
                this.ViewState["RejectedObjectID"] = int.Parse(this.Request["RejectObjectID"].ToString());
            }

            if (Request["ObjectId"] != null) {
                this.ViewState["ObjectId"] = int.Parse(Request["ObjectId"]);
                if (this.Request["RejectObjectID"] == null) {
                    this.DeleteBtn.Visible = true;
                } else {
                    this.DeleteBtn.Visible = false;
                }
                PurchaseDS.FormPORow rowFormPO = this.FormPurchaseBLL.GetFormPOByID(int.Parse(this.ViewState["ObjectId"].ToString()));
                this.ViewState["ParentFormID"] = rowFormPO.ParentFormID;
                this.ViewState["Period"] = rowFormPO.FPeriod.ToShortDateString();
                this.PeriodCtl.Text = rowFormPO.FPeriod.ToString("yyyy-MM");
                this.ViewState["VendorID"] = rowFormPO.VendorID.ToString();
                this.ViewState["ItemCategoryID"] = rowFormPO.ItemCategoryID.ToString();
                this.ViewState["PurchaseBudgetTypeID"] = rowFormPO.PurchaseBudgetTypeID.ToString();
                this.ViewState["CurrencyID"] = rowFormPO.CurrencyID.ToString();

                this.PurchaseTypeDDL.SelectedValue = rowFormPO.PurchaseTypeID.ToString();
                this.ShippingTermDDL.SelectedValue = rowFormPO.ShippingTermID.ToString();
                this.PaymentTermCtl.Text = rowFormPO.IsPaymentTermsNull() ? "" : rowFormPO.PaymentTerms;
                if (!rowFormPO.IsCompanyIDNull()) {
                    this.CompanyDDL.SelectedValue = rowFormPO.CompanyID.ToString();
                }
                this.RemarkCtl.Text = rowFormPO.IsRemarkNull() ? "" : rowFormPO.Remark;
                if (!rowFormPO.IsAttachedFileNameNull())
                    this.UCFileUpload.AttachmentFileName = rowFormPO.AttachedFileName;
                if (!rowFormPO.IsRealAttachedFileNameNull())
                    this.UCFileUpload.RealAttachmentFileName = rowFormPO.RealAttachedFileName;

                this.RealDeliveryAddressCtl.Text = rowFormPO.IsRealDeliveryAddressNull() ? "" : rowFormPO.RealDeliveryAddress;

                new FormPODetailTableAdapter().FillByFormPOID(this.InnerDS.FormPODetail, rowFormPO.FormPOID);
            } else {
                this.DeleteBtn.Visible = false;
                if (Request["ParentFormID"] != null) {
                    this.ViewState["ParentFormID"] = Request["ParentFormID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到申请单,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["PeriodPurchaseID"] != null) {
                    DateTime Period = new MasterDataBLL().GetPeriodPurchaseById(int.Parse(Request["PeriodPurchaseID"].ToString())).PeriodPurchase;
                    this.ViewState["Period"] = Period.ToShortDateString();
                } else {
                    this.Session["ErrorInfor"] = "没有费用期间,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["VendorID"] != null) {
                    this.ViewState["VendorID"] = Request["VendorID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到Vendor,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["ItemCategoryID"] != null) {
                    this.ViewState["ItemCategoryID"] = Request["ItemCategoryID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到Item Category,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["PurchaseBudgetTypeID"] != null) {
                    this.ViewState["PurchaseBudgetTypeID"] = Request["PurchaseBudgetTypeID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到预算类型,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["CurrencyID"] != null) {
                    this.ViewState["CurrencyID"] = Request["CurrencyID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到币种,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }

                this.PeriodCtl.Text = DateTime.Parse(this.ViewState["Period"].ToString()).ToString("yyyy-MM");
                MasterData.VendorRow vendor = new MasterDataBLL().GetVendorByID(int.Parse(this.ViewState["VendorID"].ToString()));
                MasterData.PaymentTermRow paymentTerm = new MasterDataBLL().GetPaymentTermById(vendor.PaymentTermID)[0];
                if (paymentTerm != null && !paymentTerm.IsPaymentTermNameNull()) {
                    this.PaymentTermCtl.Text = paymentTerm.PaymentTermName;
                }
            }
            MasterData.VendorRow vendor1 = new VendorTableAdapter().GetDataByID(int.Parse(this.ViewState["VendorID"].ToString()))[0];
            this.VendorCodeCtl.Text = vendor1.VendorCode;
            this.VendorNameCtl.Text = vendor1.VendorName;
            this.VendorAddressCtl.Text = vendor1.VendorAddress;

            this.ItemCategoryCtl.Text = new ItemCategoryTableAdapter().GetDataByID(int.Parse(this.ViewState["ItemCategoryID"].ToString()))[0].ItemCategoryName;
            this.CurrencyCtl.Text = new CurrencyTableAdapter().GetDataByID(int.Parse(this.ViewState["CurrencyID"].ToString()))[0].CurrencyShortName;
            this.PurchaseBudgetTypeCtl.Text = new PurchaseBudgetTypeTableAdapter().GetDataByID(int.Parse(this.ViewState["PurchaseBudgetTypeID"].ToString()))[0].PurchaseBudgetTypeName;
            this.ViewState["ExchangeRate"] = new MasterDataBLL().GetExchangeRateByPeriod(int.Parse(ViewState["CurrencyID"].ToString()), DateTime.Parse(ViewState["Period"].ToString()));
            if (decimal.Parse(this.ViewState["ExchangeRate"].ToString()) == 0) {
                this.Session["ErrorInfor"] = "未找到汇率,请联系管理员";
                Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
            }
            this.ExchangeRateCtl.Text = this.ViewState["ExchangeRate"].ToString();

            //判断费用期间是否正确
            MasterDataBLL bll = new MasterDataBLL();
            if (!new MasterDataBLL().IsValidPeriodPurchase(DateTime.Parse(this.ViewState["Period"].ToString()))) {
                this.SubmitBtn.Visible = false;
                PageUtility.ShowModelDlg(this, "不允许申请本月项目,请删除草稿并联系财务部!");
                return;
            }
            //申请单编号和申请单金额
            PurchaseDS.FormRow applyFormRow = this.FormPurchaseBLL.GetFormByID(int.Parse(this.ViewState["ParentFormID"].ToString()))[0];
            this.ApplyFormNoCtl.Text = applyFormRow.FormNo;
            this.ViewState["ParentFormNo"] = applyFormRow.FormNo;
            string url = string.Empty;
            switch (applyFormRow.PageType) {
                case (int)SystemEnums.PageType.ActivityApply:
                    url = "/FormSale/ActivityApproval.aspx?ShowDialog=1&ObjectId=" + applyFormRow.FormID;
                    this.ViewState["POType"] = SystemEnums.POType.Sale;
                    this.ViewState["ApplyAmountRMB"] = new FormSaleBLL().GetFormSaleApplyByID(applyFormRow.FormID)[0].AmountRMB;
                    break;
                case (int)SystemEnums.PageType.NoActivityApply:
                    url = "/FormSale/NoActivityApproval.aspx?ShowDialog=1&ObjectId=" + applyFormRow.FormID;
                    this.ViewState["POType"] = SystemEnums.POType.Sale;
                    this.ViewState["ApplyAmountRMB"] = new FormSaleBLL().GetFormSaleApplyByID(applyFormRow.FormID)[0].AmountRMB;
                    break;
                case (int)SystemEnums.PageType.FormMarketingApply:
                    url = "/FormMarketing/MarketingApproval.aspx?ShowDialog=1&ObjectId=" + applyFormRow.FormID;
                    this.ViewState["POType"] = SystemEnums.POType.Marketing;
                    this.ViewState["ApplyAmountRMB"] = new FormMarketingBLL().GetFormMarketingApplyByID(applyFormRow.FormID)[0].AmountRMB;
                    break;
                case (int)SystemEnums.PageType.RDApply:
                    url = "/FormRD/RDApproval.aspx?ShowDialog=1&ObjectId=" + applyFormRow.FormID;
                    this.ViewState["POType"] = SystemEnums.POType.RD;
                    this.ViewState["ApplyAmountRMB"] = new FormRDBLL().GetFormRDApplyByID(applyFormRow.FormID)[0].AmountRMB;
                    break;
            }

            this.ApplyFormNoCtl.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + url + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
            this.ApplyAmountCtl.Text = this.ViewState["ApplyAmountRMB"].ToString();

        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!this.IsPostBack) {
            String title = this.GetLocalResourceObject("titleLabel.Text").ToString();
            PageUtility.SetContentTitle(this.Page, title);

            MasterDataBLL mdBLL = new MasterDataBLL();
            int formID = int.Parse(Request["ObjectId"]);
            this.ViewState["ObjectId"] = formID;
            FormDS.FormSalePaymentRow rowFormPayment = this.FormSaleBLL.GetFormSalePaymentByID(int.Parse(this.ViewState["ObjectId"].ToString()));

            FormDS.FormRow rowForm = this.FormSaleBLL.GetFormByID(formID)[0];
            if (rowForm.IsProcIDNull()) {
                ViewState["ProcID"] = "";
            } else {
                ViewState["ProcID"] = rowForm.ProcID;
            }

            this.FormNoCtl.Text = rowForm.FormNo;
            AuthorizationDS.StuffUserRow applicant = new AuthorizationBLL().GetStuffUserById(rowForm.UserID);
            this.StuffNameCtl.Text = CommonUtility.GetStaffFullName(applicant);
            this.PositionNameCtl.Text = new OUTreeBLL().GetPositionById(rowForm.PositionID).PositionName;
            if (new OUTreeBLL().GetOrganizationUnitById(rowForm.OrganizationUnitID) != null) {
                this.DepartmentNameCtl.Text = new OUTreeBLL().GetOrganizationUnitById(rowForm.OrganizationUnitID).OrganizationUnitName;
            }
            this.StuffNoCtl.Text = applicant.IsStuffNoNull() ? "" : applicant.StuffNo;
            this.AttendDateCtl.Text = applicant.AttendDate.ToShortDateString();

            this.ApplyFormNoCtl.Text = this.FormSaleBLL.GetFormByID(rowFormPayment.FormSaleApplyID)[0].FormNo;
            FormDS.FormSaleApplyRow rowFormApply = this.FormSaleBLL.GetFormSaleApplyByID(rowFormPayment.FormSaleApplyID)[0];
            this.PeriodCtl.Text = rowFormApply.FPeriod.ToString("yyyy-MM");

            MasterData.CustomerRow customer = mdBLL.GetCustomerById(rowFormApply.CustomerID)[0];
            this.CustomerNameCtl.Text = customer.CustomerName;
            this.CustomerChannelCtl.Text = mdBLL.GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelName;
            this.KATypeCtl.Text = customer.IsKaTypeNull() ? "" : customer.KaType;
            this.CustomerRegionCtl.Text = mdBLL.GetCustomerRegionById(customer.CustomerRegionID).CustomerRegionName;
            this.CityCtl.Text = customer.City;
            this.BrandCtl.Text = mdBLL.GetBrandById(rowFormApply.BrandID)[0].BrandName;
            MasterData.ExpenseSubCategoryRow rowExpenseSubCategory = mdBLL.GetExpenseSubCategoryById(rowFormApply.ExpenseSubCategoryID);
            this.ExpenseCategoryCtl.Text = mdBLL.GetExpenseCategoryById(rowExpenseSubCategory.ExpenseCategoryID).ExpenseCategoryName;
            this.ExpenseSubCategoryCtl.Text = rowExpenseSubCategory.ExpenseSubCategoryName;
            this.CurrencyCtl.Text = mdBLL.GetCurrencyByID(rowFormApply.CurrencyID).CurrencyShortName;
            this.ExchangeRateCtl.Text = rowFormApply.ExchangeRate.ToString();
            this.ShopNameCtl.Text = rowFormApply.IsShopNameNull() ? "" : rowFormApply.ShopName;
            this.ShopCountCtl.Text = rowFormApply.IsShopCountNull() ? "" : rowFormApply.ShopCount.ToString();
            this.ProjectNameCtl.Text = rowFormApply.IsProjectNameNull() ? "" : rowFormApply.ProjectName;
            this.CostCenterCtl.Text = CommonUtility.GetMAACostCenterFullName(rowForm.CostCenterID);
            if (!rowFormApply.IsActivityBeginDateNull()) {
                this.ActivityBeginCtl.Text = rowFormApply.ActivityBeginDate.ToString("yyyy-MM-dd");
            }
            if (!rowFormApply.IsActivityEndDateNull()) {
                this.ActivityEndCtl.Text = rowFormApply.ActivityEndDate.ToString("yyyy-MM-dd");
            }
            this.ProjectDescCtl.Text = rowFormApply.IsProjectDescNull() ? "" : rowFormApply.ProjectDesc;
            if (!rowFormApply.IsApplyFileNameNull())
                this.UCFileUpload.AttachmentFileName = rowFormApply.ApplyFileName;
            if (!rowFormApply.IsApplyRealFileNameNull())
                this.UCFileUpload.RealAttachmentFileName = rowFormApply.ApplyRealFileName;

            if (!rowFormPayment.IsRemarkNull()) {
                this.RemarkCtl.Text = rowFormPayment.Remark;
            }
            if (!rowFormPayment.IsAttachedFileNameNull()) {
                this.UCPaymentFile.AttachmentFileName = rowFormPayment.AttachedFileName;
            }
            if (!rowFormPayment.IsRealAttachedFileNameNull()) {
                this.UCPaymentFile.RealAttachmentFileName = rowFormPayment.RealAttachedFileName;
            }
            this.InvoiceStatusCtl.Text = new InvoiceStatusTableAdapter().GetDataByID(rowFormPayment.InvoiceStatusID)[0].Name;
            if (!rowFormPayment.IsVendorIDNull()) {
                MasterData.VendorRow vendor = mdBLL.GetVendorByID(rowFormPayment.VendorID);
                this.VendorCtl.Text = vendor.VendorName + "-" + vendor.VendorCode;
            }

            this.txtVatType.Text = mdBLL.GetVatTypeById(rowFormPayment.VatTypeID)[0].VatTypeName;
            //PO
            if (!rowFormPayment.IsFormPOIDNull()) {
                FormDS.FormRow rowFormPO = this.FormSaleBLL.GetFormByID(rowFormPayment.FormPOID)[0];
                this.hlPO.Text = rowFormPO.FormNo;
                this.hlPO.NavigateUrl = CommonUtility.GetPOPostBackUrl(rowFormPO.FormID);
            } else {
                this.hlPO.Text = "无";
            }
            //历史单据
            if (rowForm.IsRejectedFormIDNull()) {
                lblRejectFormNo.Text = "无";
            } else {
                FormDS.FormRow rejectedForm = this.FormSaleBLL.GetFormByID(rowForm.RejectedFormID)[0];
                this.lblRejectFormNo.Text = rejectedForm.FormNo;
                this.lblRejectFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/FormSale/NoActivityAdvancedPaymentApproval.aspx?ShowDialog=1&ObjectId=" + rejectedForm.FormID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
            }

            //明细
            this.odsInvoice.SelectParameters["FormID"].DefaultValue = rowFormPayment.FormSalePaymentID.ToString();
            this.odsPaymentDetails.SelectParameters["FormSalePaymentID"].DefaultValue = rowFormPayment.FormSalePaymentID.ToString();

            //审批页面处理&按钮处理
            AuthorizationDS.StuffUserRow stuffUser = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
            this.ViewState["StuffUserID"] = stuffUser.StuffUserId;
            if (rowForm.InTurnUserIds.Contains("P" + stuffUser.StuffUserId + "P")) {
                this.SubmitBtn.Visible = true;
                this.cwfAppCheck.IsView = false;
                this.ViewState["IsView"] = false;
            } else {
                this.SubmitBtn.Visible = false;
                this.cwfAppCheck.IsView = true;
                this.ViewState["IsView"] = true;
            }

            if (rowForm.StatusID == (int)SystemEnums.FormStatus.Rejected && stuffUser.StuffUserId == rowForm.UserID) {
                this.EditBtn.Visible = true;
                this.ScrapBtn.Visible = true;
            } else {
                this.EditBtn.Visible = false;
                this.ScrapBtn.Visible = false;
            }

            //如果是弹出,取消按钮不可见
            if (this.Request["ShowDialog"] != null) {
                if (this.Request["ShowDialog"].ToString() == "1") {
                    this.upButton.Visible = false;
                    this.Master.FindControl("divMenu").Visible = false;
                    this.Master.FindControl("tbCurrentPage").Visible = false;
                }
            }

            //判断财务摘要的显示问题
            if (!rowForm.IsFinanceRemarkNull()) {
                this.FinanceRemarkCtl.Text = rowForm.FinanceRemark;
            }
            int opViewId = BusinessUtility.GetBusinessOperateId(SystemEnums.BusinessUseCase.FinanceRemark, SystemEnums.OperateEnum.View);
            int opManageId = BusinessUtility.GetBusinessOperateId(SystemEnums.BusinessUseCase.FinanceRemark, SystemEnums.OperateEnum.Manage);
            AuthorizationDS.PositionRow ViewerPosition = (AuthorizationDS.PositionRow)this.Session["Position"];
            PositionRightBLL positionRightBLL = new PositionRightBLL();
            bool HasViewRight = positionRightBLL.CheckPositionRight(ViewerPosition.PositionId, opViewId);
            bool HasManageRight = positionRightBLL.CheckPositionRight(ViewerPosition.PositionId, opManageId);
            //如果没有权限则隐藏
            if (!HasViewRight && !HasManageRight) {
                this.FinanceRemarkTitleDIV.Visible = false;
                this.FinanceRemarkDIV.Visible = false;
                this.SaveBtn.Visible = false;
            }
            //如果没有填写的权限或者已经填写了,则隐藏保存按钮
            if (HasViewRight && (!HasManageRight || !rowForm.IsFinanceRemarkNull())) {
                this.FinanceRemarkCtl.ReadOnly = true;
                this.SaveBtn.Visible = false;
            }
            //如果不是审批中或者审批完成不能修改
            if (rowForm.StatusID != 1 && rowForm.StatusID != 2) {
                this.FinanceRemarkCtl.ReadOnly = true;
                this.SaveBtn.Visible = false;
            }

        }
        this.cwfAppCheck.FormID = (int)this.ViewState["ObjectId"];
        this.cwfAppCheck.ProcID = this.ViewState["ProcID"].ToString();
        this.cwfAppCheck.IsView = (bool)this.ViewState["IsView"];
    }
Exemple #18
0
        public void AddFormVendorApply(int? RejectedFormID, int UserID, int? ProxyStuffUserId, int? ProxyStuffPositionID, int OrganizationUnitID, int PositionID,
                 SystemEnums.FormType FormTypeID, SystemEnums.FormStatus StatusID, int VendorID, string VendorName, string VendorAddress, string City, string Country, string ContactName, int? VendorTypeID,
             string PhoneNumber, int OneTimeVendor, int HoldVendor, string PurchasingPostalCode, string AlphaSearchKey, string PurchasingContact, string PurchasingAddress,
            string PurchasingCity, string PurchasingPhoneNumber, int? BankCodeID, int? MethodPaymentID, int? PaymentTermID,
                 int? TransTypeID, int? VatTypeID, string BankName, string AccountNo, string BankNo, int? ACTypeID, string AttachmentFileName, string RealAttachmentFileName, string Remark, string ModifyReason, int ActionType)
        {
            SqlTransaction transaction = null;
            try {
                transaction = TableAdapterHelper.BeginTransaction(this.TAForm);
                TableAdapterHelper.SetTransaction(this.TAFormVendor, transaction);

                PurchaseDS.FormRow formRow = this.PurchaseDataSet.Form.NewFormRow();
                if (RejectedFormID != null) {
                    formRow.RejectedFormID = RejectedFormID.GetValueOrDefault();
                }
                formRow.UserID = UserID;
                UtilityBLL utility = new UtilityBLL();

                string formTypeString = utility.GetFormTypeString((int)FormTypeID);
                formRow.FormNo = utility.GetFormNo(formTypeString);

                if (ProxyStuffUserId != null) {
                    formRow.ProxyUserID = ProxyStuffUserId.GetValueOrDefault();
                }
                if (ProxyStuffPositionID != null) {
                    formRow.ProxyPositionID = ProxyStuffPositionID.GetValueOrDefault();
                }
                formRow.InTurnUserIds = "P";//待改动
                formRow.InTurnPositionIds = "P";//待改动
                formRow.OrganizationUnitID = OrganizationUnitID;
                formRow.PositionID = PositionID;
                formRow.FormTypeID = (int)FormTypeID;
                formRow.StatusID = (int)StatusID;
                formRow.SubmitDate = DateTime.Now;
                formRow.LastModified = DateTime.Now;
                formRow.PageType = (int)SystemEnums.PageType.VendorApply;
                this.PurchaseDataSet.Form.AddFormRow(formRow);
                this.TAForm.Update(formRow);

                //处理申请表的内容
                PurchaseDS.FormVendorDataTable tbFormVendor = new PurchaseDS.FormVendorDataTable();
                PurchaseDS.FormVendorRow FormVendorRow = tbFormVendor.NewFormVendorRow();

                FormVendorRow.FormVendorID = formRow.FormID;
                if (ActionType != 1 && VendorID > 0) {
                    FormVendorRow.VendorID = VendorID;
                    FormVendorRow.VendorCode = new MasterDataBLL().GetVendorByID(VendorID).VendorCode;
                }
                FormVendorRow.VendorName = VendorName;
                FormVendorRow.VendorAddress = VendorAddress;
                FormVendorRow.City = City;

                FormVendorRow.Postal = Country;
                FormVendorRow.ContactName = ContactName;
                if (VendorTypeID != null) {
                    FormVendorRow.VendorTypeID = VendorTypeID.GetValueOrDefault();
                }
                FormVendorRow.PhoneNumber = PhoneNumber;
                FormVendorRow.OneTimeVendor = OneTimeVendor == 1;
                FormVendorRow.HoldVendor = HoldVendor == 1;
                FormVendorRow.PurchaseingPostalCode = PurchasingPostalCode;
                FormVendorRow.AlphaSearchKey = AlphaSearchKey;
                FormVendorRow.PurchasingContact = PurchasingContact;
                FormVendorRow.PurchasingAddress = PurchasingAddress;
                FormVendorRow.PurchasingCity = PurchasingCity;
                FormVendorRow.PurchasePhoneNumber = PurchasingPhoneNumber;
                if (BankCodeID != null && BankCodeID != 0) {
                    FormVendorRow.BankCodeID = BankCodeID.GetValueOrDefault();
                    MasterData.BankCodeRow rowBankCode = new MasterDataBLL().GetBankCodeById(BankCodeID.GetValueOrDefault())[0];
                    FormVendorRow.BankCode = rowBankCode.BankCode + rowBankCode.Description;
                }
                if (MethodPaymentID != null) {
                    FormVendorRow.MethodPaymentID = MethodPaymentID.GetValueOrDefault();
                }
                if (PaymentTermID != null) {
                    FormVendorRow.PaymentTermID = PaymentTermID.GetValueOrDefault();
                }
                if (TransTypeID != null) {
                    FormVendorRow.TransTypeID = TransTypeID.GetValueOrDefault();
                }
                if (VatTypeID != null) {
                    FormVendorRow.VATTypeID = VatTypeID.GetValueOrDefault();
                }
                FormVendorRow.BankName = BankName;
                FormVendorRow.AccountNo = AccountNo;
                FormVendorRow.BankNo = BankNo;
                if (ACTypeID != null) {
                    FormVendorRow.ACTypeID = ACTypeID.GetValueOrDefault();
                }
                FormVendorRow.AttachmentFileName = AttachmentFileName;
                FormVendorRow.RealAttachmentFileName = RealAttachmentFileName;
                FormVendorRow.Remark = Remark;
                FormVendorRow.ModifyReason = ModifyReason;
                FormVendorRow.ActionType = ActionType;

                tbFormVendor.AddFormVendorRow(FormVendorRow);
                this.TAFormVendor.Update(tbFormVendor);

                // 正式提交或草稿
                if (StatusID == SystemEnums.FormStatus.Awaiting) {

                    Dictionary<string, object> dic = new Dictionary<string, object>();
                    dic["ActionType"] = FormVendorRow.ActionType;
                    APResult result = new APFlowBLL().CreateProcess(new APParameter(formRow.FormID, formRow.FormNo, formRow.OrganizationUnitID, formRow.UserID, (int)StatusID, formRow.FormTypeID, formRow.PositionID, dic));
                    if (result != null) {
                        formRow.InTurnPositionIds = result.InTurnPositionIds;
                        formRow.InTurnUserIds = result.InTurnUserIds;
                        formRow.SubmitDate = result.ApprovedDate.GetValueOrDefault();
                        formRow.StatusID = result.StatusID;
                        formRow.ProcID = result.ProcID;
                        this.TAForm.Update(formRow);
                    }
                }

                //作废之前的单据
                if (RejectedFormID != null) {
                    PurchaseDS.FormRow oldRow = TAForm.GetDataByID(RejectedFormID.GetValueOrDefault())[0];
                    if (oldRow.StatusID == (int)SystemEnums.FormStatus.Rejected) {
                        new APFlowBLL().ScrapForm(oldRow.FormID);
                    }
                }
                transaction.Commit();
            } catch (Exception ex) {
                transaction.Rollback();
                throw new ApplicationException(ex.Message);
            } finally {
                transaction.Dispose();
            }
        }
Exemple #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!this.IsPostBack) {
            String title = this.GetLocalResourceObject("titleLabel.Text").ToString();
            PageUtility.SetContentTitle(this.Page, title);

            // 用户信息,职位信息
            AuthorizationDS.StuffUserRow stuffUser = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
            AuthorizationDS.PositionRow rowUserPosition = (AuthorizationDS.PositionRow)Session["Position"];
            this.ViewState["StuffUserID"] = stuffUser.StuffUserId;
            this.ViewState["PositionID"] = rowUserPosition.PositionId;

            this.StuffNameCtl.Text = CommonUtility.GetStaffFullName(stuffUser);
            this.PositionNameCtl.Text = rowUserPosition.PositionName;
            this.DepartmentNameCtl.Text = new OUTreeBLL().GetOrganizationUnitById(rowUserPosition.OrganizationUnitId).OrganizationUnitName;
            this.ViewState["DepartmentID"] = rowUserPosition.OrganizationUnitId;
            this.StuffNoCtl.Text = stuffUser.IsStuffNoNull() ? "" : stuffUser.StuffNo;
            this.AttendDateCtl.Text = stuffUser.AttendDate.ToShortDateString();

            if (this.Request["RejectObjectID"] != null) {
                this.ViewState["RejectedObjectID"] = int.Parse(this.Request["RejectObjectID"].ToString());
            }
            //如果是草稿进行赋值
            MasterDataBLL MasterDataBLL = new MasterDataBLL();
            if (Request["ObjectId"] != null) {
                this.ViewState["ObjectId"] = int.Parse(Request["ObjectId"]);
                if (this.Request["RejectObjectID"] == null) {
                    this.DeleteBtn.Visible = true;
                } else {
                    this.DeleteBtn.Visible = false;
                }
                OpenForm(int.Parse(this.ViewState["ObjectId"].ToString()));
            } else {
                this.DeleteBtn.Visible = false;
                if (Request["PeriodSaleID"] != null) {
                    DateTime FPeriod = MasterDataBLL.GetPeriodSaleById(int.Parse(Request["PeriodSaleID"].ToString())).PeriodSale;
                    this.ViewState["FPeriod"] = new MasterDataBLL().GetPeriodSaleById(int.Parse(Request["PeriodSaleID"].ToString())).PeriodSale.ToShortDateString();
                } else {
                    this.Session["ErrorInfor"] = "没有费用期间,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["CustomerID"] != null) {
                    this.ViewState["CustomerID"] = Request["CustomerID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到客户,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["BrandID"] != null) {
                    this.ViewState["BrandID"] = Request["BrandID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到Brand,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["ExpenseSubCategoryID"] != null) {
                    this.ViewState["ExpenseSubCategoryID"] = Request["ExpenseSubCategoryID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到费用小类,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["CurrencyID"] != null) {
                    this.ViewState["CurrencyID"] = Request["CurrencyID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到币种,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }

                this.PeriodCtl.Text = DateTime.Parse(this.ViewState["FPeriod"].ToString()).ToString("yyyy-MM");

                MasterData.CustomerRow customer = MasterDataBLL.GetCustomerById(int.Parse(this.ViewState["CustomerID"].ToString()))[0];
                this.txtCustomerCode.Text = customer.CustomerNo;
                this.CustomerNameCtl.Text = customer.CustomerName;
                ViewState["CustomerChannelID"] = customer.CustomerChannelID.ToString();
                this.CustomerChannelCtl.Text = MasterDataBLL.GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelName;
                this.KATypeCtl.Text = customer.IsKaTypeNull() ? "" : customer.KaType;
                this.CustomerRegionCtl.Text = MasterDataBLL.GetCustomerRegionById(customer.CustomerRegionID).CustomerRegionName;
                this.CityCtl.Text = customer.City;
                this.BrandCtl.Text = MasterDataBLL.GetBrandById(int.Parse(this.ViewState["BrandID"].ToString()))[0].BrandName;
                MasterData.ExpenseSubCategoryRow rowExpenseSubCategory = MasterDataBLL.GetExpenseSubCategoryById(int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()));
                this.ExpenseCategoryCtl.Text = MasterDataBLL.GetExpenseCategoryById(rowExpenseSubCategory.ExpenseCategoryID).ExpenseCategoryName;
                this.ExpenseSubCategoryCtl.Text = rowExpenseSubCategory.ExpenseSubCategoryName;
                this.CurrencyCtl.Text = new CurrencyTableAdapter().GetDataByID(int.Parse(this.ViewState["CurrencyID"].ToString()))[0].CurrencyShortName;

            }
            this.ExpenseSubCategoryID.Value = this.ViewState["ExpenseSubCategoryID"].ToString();
            this.BrandID.Value = this.ViewState["BrandID"].ToString();
            this.ViewState["ExchangeRate"] = new MasterDataBLL().GetExchangeRateByPeriod(int.Parse(ViewState["CurrencyID"].ToString()), DateTime.Parse(ViewState["FPeriod"].ToString()));
            if (decimal.Parse(this.ViewState["ExchangeRate"].ToString()) == 0) {
                this.Session["ErrorInfor"] = "未找到汇率,请联系管理员";
                Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
            }
            this.ExchangeRateCtl.Text = this.ViewState["ExchangeRate"].ToString();

            //判断费用期间是否正确
            MasterDataBLL bll = new MasterDataBLL();
            if (!new MasterDataBLL().IsValidPeriodSale(DateTime.Parse(this.ViewState["FPeriod"].ToString()))) {
                this.SubmitBtn.Visible = false;
                PageUtility.ShowModelDlg(this, "不允许申请本月项目,请删除草稿并联系财务部!");
                return;
            }

            //预算信息
            this.ViewState["ExpenseCategoryID"] = new MasterDataBLL().GetExpenseSubCategoryById(int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString())).ExpenseCategoryID.ToString();
            decimal[] calculateAssistant = new decimal[6];
            calculateAssistant = new BudgetBLL().GetSalesBudgetByParameter(rowUserPosition.PositionId, DateTime.Parse(ViewState["FPeriod"].ToString()), int.Parse(this.ViewState["ExpenseCategoryID"].ToString()), int.Parse(ViewState["CustomerChannelID"].ToString()), int.Parse(this.ViewState["BrandID"].ToString()));
            this.TotalBudgetCtl.Text = calculateAssistant[0].ToString("N");
            this.ApprovedAmountCtl.Text = calculateAssistant[1].ToString("N");
            this.ApprovingAmountCtl.Text = calculateAssistant[2].ToString("N");
            this.CompletedAmountCtl.Text = calculateAssistant[3].ToString("N");
            this.ReimbursedAmountCtl.Text = calculateAssistant[4].ToString("N");
            this.RemainBudgetCtl.Text = calculateAssistant[5].ToString("N");

        }
        //查看预算权限
        int opViewId = BusinessUtility.GetBusinessOperateId(SystemEnums.BusinessUseCase.ViewBudget, SystemEnums.OperateEnum.Manage);
        AuthorizationDS.PositionRow position = (AuthorizationDS.PositionRow)this.Session["Position"];
        bool HasManageRight = new PositionRightBLL().CheckPositionRight(position.PositionId, opViewId);
        this.divBudgetInfo.Visible = HasManageRight;
        this.divBudgetInfoTitle.Visible = HasManageRight;
    }
Exemple #20
0
    protected void OpenForm(int formID)
    {
        FormDS.FormRow rowForm = this.FormSaleBLL.GetFormByID(formID)[0];
        FormDS.FormSaleApplyRow rowFormApply = this.FormSaleBLL.GetFormSaleApplyByID(formID)[0];
        MasterDataBLL MasterDataBLL = new MasterDataBLL();
        //赋值
        this.ViewState["FPeriod"] = rowFormApply.FPeriod.ToShortDateString();
        this.PeriodCtl.Text = rowFormApply.FPeriod.ToString("yyyy-MM");
        this.ViewState["CustomerID"] = rowFormApply.CustomerID.ToString();
        this.ViewState["BrandID"] = rowFormApply.BrandID.ToString();
        this.ViewState["ExpenseSubCategoryID"] = rowFormApply.ExpenseSubCategoryID.ToString();
        this.ViewState["CurrencyID"] = rowFormApply.CurrencyID.ToString();

        MasterData.CustomerRow customer = MasterDataBLL.GetCustomerById(rowFormApply.CustomerID)[0];
        this.txtCustomerCode.Text = customer.CustomerNo;
        this.CustomerNameCtl.Text = customer.CustomerName;
        this.ViewState["CustomerChannelID"] = customer.CustomerChannelID.ToString();
        this.CustomerChannelCtl.Text = MasterDataBLL.GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelName;
        this.KATypeCtl.Text = customer.IsKaTypeNull() ? "" : customer.KaType;
        this.CustomerRegionCtl.Text = MasterDataBLL.GetCustomerRegionById(customer.CustomerRegionID).CustomerRegionName;
        this.CityCtl.Text = customer.City;
        this.BrandCtl.Text = MasterDataBLL.GetBrandById(rowFormApply.BrandID)[0].BrandName;
        MasterData.ExpenseSubCategoryRow rowExpenseSubCategory = MasterDataBLL.GetExpenseSubCategoryById(rowFormApply.ExpenseSubCategoryID);
        this.ExpenseCategoryCtl.Text = MasterDataBLL.GetExpenseCategoryById(rowExpenseSubCategory.ExpenseCategoryID).ExpenseCategoryName;
        this.ExpenseSubCategoryCtl.Text = rowExpenseSubCategory.ExpenseSubCategoryName;
        this.CurrencyCtl.Text = new CurrencyTableAdapter().GetDataByID(rowFormApply.CurrencyID)[0].CurrencyShortName;

        this.ShopNameCtl.Text = rowFormApply.IsShopNameNull() ? "" : rowFormApply.ShopName;
        this.ShopCountCtl.Text = rowFormApply.IsShopCountNull() ? "" : rowFormApply.ShopCount.ToString();
        this.ProjectNameCtl.Text = rowFormApply.IsProjectNameNull() ? "" : rowFormApply.ProjectName;
        if (!rowForm.IsCostCenterIDNull()) {
            this.CostCenterDDL.SelectedValue = rowForm.CostCenterID.ToString();
        }
        this.ProjectDescCtl.Text = rowFormApply.IsProjectDescNull() ? "" : rowFormApply.ProjectDesc;
        if (!rowFormApply.IsApplyFileNameNull())
            this.UCFileUpload.AttachmentFileName = rowFormApply.ApplyFileName;
        if (!rowFormApply.IsApplyRealFileNameNull())
            this.UCFileUpload.RealAttachmentFileName = rowFormApply.ApplyRealFileName;
        //促销信息
        this.DisplayTypeDDL.SelectedValue = rowFormApply.DisplayTypeID.ToString();
        this.DisplayAreaCtl.Text = rowFormApply.IsDisplayAreaNull() ? "" : rowFormApply.DisplayArea.ToString();
        this.DMDDL.SelectedValue = rowFormApply.IsDM ? "1" : "0";
        this.DiscountTypeDDL.SelectedValue = rowFormApply.DiscountTypeID.ToString();

        if (!rowFormApply.IsActivityBeginDateNull()) {
            this.UCActivityBegin.SelectedDate = rowFormApply.ActivityBeginDate.ToString("yyyy-MM-dd");
        }
        if (!rowFormApply.IsActivityEndDateNull()) {
            this.UCActivityEnd.SelectedDate = rowFormApply.ActivityEndDate.ToString("yyyy-MM-dd");
        }

        if (!rowFormApply.IsDeliveryBeginDateNull()) {
            this.UCDeliveryBegin.SelectedDate = rowFormApply.DeliveryBeginDate.ToString("yyyy-MM-dd");
        }
        if (!rowFormApply.IsDeliveryEndDateNull()) {
            this.UCDeliveryEnd.SelectedDate = rowFormApply.DeliveryEndDate.ToString("yyyy-MM-dd");
        }

        // 打开明细表
        FormSaleSKUDetailTableAdapter taSKUDetail = new FormSaleSKUDetailTableAdapter();
        taSKUDetail.FillByFormSaleApplyID(this.InnerDS.FormSaleSKUDetail, formID);
        FormSaleExpenseDetailTableAdapter taExpenseDetail = new FormSaleExpenseDetailTableAdapter();
        taExpenseDetail.FillByFormSaleApplyID(this.InnerDS.FormSaleExpenseDetail, formID);
        //如果打开的是有pricediscount的单据,应该在明细中先删除,然后再保存时再添加

        for (int index = 0; index < this.InnerDS.FormSaleExpenseDetail.Count; index++) {
            MasterData.ExpenseItemRow expenseItem = new MasterDataBLL().GetExpenseItemById(this.InnerDS.FormSaleExpenseDetail[index].ExpenseItemID);
            if (expenseItem.IsPriceDiscount) {
                this.InnerDS.FormSaleExpenseDetail.Rows[index].Delete();
            }
        }
    }
Exemple #21
0
    protected void odsSKUDetails_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
        DropDownList SKUDDL = (DropDownList)this.gvSKUDetails.Rows[this.gvSKUDetails.EditIndex].FindControl("SKUDDL");
        MasterData.CustomerRow customer = new CustomerTableAdapter().GetDataByID(int.Parse(this.ViewState["CustomerID"].ToString()))[0];

        decimal deliveryPrice = new MasterDataBLL().GetSKUPriceByParameter(int.Parse(SKUDDL.SelectedValue), customer.CustomerTypeID, customer.CustomerChannelID);
        if (deliveryPrice == 0) {
            PageUtility.ShowModelDlg(this.Page, "没有找到该产品供货价,请联系管理员", "can't find the delivery price for this SKU");
            e.Cancel = true;
            return;
        } else {
            e.InputParameters["SKUID"] = SKUDDL.SelectedValue;
            e.InputParameters["DeliveryPrice"] = deliveryPrice;
        }

        TextBox DiscountCtl = (TextBox)this.gvSKUDetails.Rows[this.gvSKUDetails.EditIndex].FindControl("DiscountCtl");
        TextBox DiscountCampbellCtl = (TextBox)this.gvSKUDetails.Rows[this.gvSKUDetails.EditIndex].FindControl("DiscountCampbellCtl");
        TextBox PriceDiscountAmountCtl = (TextBox)this.gvSKUDetails.Rows[this.gvSKUDetails.EditIndex].FindControl("PriceDiscountAmountCtl");
        TextBox RemarkCtl = (TextBox)this.gvSKUDetails.Rows[this.gvSKUDetails.EditIndex].FindControl("RemarkCtl");
        decimal discount = 0;
        decimal discountCampbell = 0;
        decimal priceDiscount = 0;
        if (DiscountCtl.Text != string.Empty) {
            discount = decimal.Parse(DiscountCtl.Text);
        }
        if (DiscountCampbellCtl.Text != string.Empty) {
            discountCampbell = decimal.Parse(DiscountCampbellCtl.Text);
        }
        if (PriceDiscountAmountCtl.Text != string.Empty) {
            priceDiscount = decimal.Parse(PriceDiscountAmountCtl.Text);
        }
        //add 20130807
        if (!string.IsNullOrEmpty(PriceDiscountAmountCtl.Text.Trim()) && priceDiscount != 0 && string.IsNullOrEmpty(RemarkCtl.Text.Trim())) {
            PageUtility.ShowModelDlg(this.Page, "请在备注中填写,折扣让利费用计算公式", "please input in the remark box, price discount amount calculated formula");
            e.Cancel = true;
            return;
        }
        //end
        if (!((discount == 0 && discountCampbell == 0 && priceDiscount == 0) || (discount != 0 && discountCampbell != 0 && priceDiscount != 0))) {
            PageUtility.ShowModelDlg(this.Page, "折扣比例和折扣让利费用应该同时有值", "discount and price discount fee should have value at the same time");
            e.Cancel = true;
            return;
        } else {
            e.InputParameters["PriceDiscountAmountRMB"] = decimal.Round(priceDiscount * decimal.Parse(this.ViewState["ExchangeRate"].ToString()), 2);
        }
    }
Exemple #22
0
    public void SaveDataToDB(string FullPath, string FileName, string excelFileExtension)
    {
        SqlTransaction transaction = null;
        try {
            DataTable dt = null;
            dt = this.GetDataSet(FullPath, excelFileExtension).Tables[0];
            if (dt.Rows.Count <= 1) {
                PageUtility.ShowModelDlg(this.Page, "�ļ���û���κμ�¼��������ѡ��");
                return;
            }
            ShopTableAdapter TAShop = new ShopTableAdapter();
            ImportLogTableAdapter TAImportLog = new ImportLogTableAdapter();
            ImportLogDetailTableAdapter TAImportLogDetail = new ImportLogDetailTableAdapter();
            MasterDataBLL mdBLL = new MasterDataBLL();

            transaction = TableAdapterHelper.BeginTransaction(TAShop);
            TableAdapterHelper.SetTransaction(TAImportLog, transaction);
            TableAdapterHelper.SetTransaction(TAImportLogDetail, transaction);
            //�洢log��Ϣ
            ImportDS.ImportLogDataTable logTable = new ImportDS.ImportLogDataTable();
            ImportDS.ImportLogRow logRow = logTable.NewImportLogRow();

            int stuffUserID = ((AuthorizationDS.StuffUserRow)Session["StuffUser"]).StuffUserId;
            string fullname = this.fileUpLoad.PostedFile.FileName.ToString();
            string tmpFile = fullname.Remove(0, fullname.LastIndexOf("\\") + 1);
            logRow.FileName = tmpFile;
            logRow.ImportDate = DateTime.Now;
            logRow.ImportUserID = stuffUserID;
            logRow.ImportType = 4;
            logRow.TotalCount = dt.Rows.Count - 1;
            logRow.SuccessCount = dt.Rows.Count - 1;
            logRow.FailCount = 0;
            logTable.AddImportLogRow(logRow);
            TAImportLog.Update(logTable);

            //����ÿ����ϸ
            ERS.ShopDataTable tbShop = new ERS.ShopDataTable();
            ImportDS.ImportLogDetailDataTable ImportLogDetailTable = new ImportDS.ImportLogDetailDataTable();
            int row_count = dt.Rows.Count;
            string errorInfor = string.Empty;
            //  int expenseTypeID = int.Parse(ExpenseTypeDDL.SelectedValue);
            //��ʼ����ÿ����ϸ
            for (int i = 1; i <= row_count - 1; i++) {
                if (CheckData(dt.Rows[i]) != null) {
                    errorInfor = "��" + (i + 1) + "����" + CheckData(dt.Rows[i]);
                    ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                    ImportDetailRow.LogID = logRow.LogID;
                    ImportDetailRow.Line = i + 1;
                    ImportDetailRow.Error = errorInfor;
                    ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                    logRow.FailCount = logRow.FailCount + 1;
                    logRow.SuccessCount = logRow.SuccessCount - 1;
                    TAImportLog.Update(logRow);
                    continue;
                } else {
                    DataRow row = dt.Rows[i];
                    string ShopName = row[0].ToString().Trim();
                    string ShopNo = row[1].ToString().Trim();
                    string CustomerName = row[2].ToString().Trim();
                    string ShopLevelName = row[3].ToString().Trim();
                    string Address = row[4].ToString().Trim();
                    string Contacter = row[5].ToString().Trim();
                    string Telephone = row[6].ToString().Trim();
                    string Email = row[7].ToString().Trim();

                    ERS.CustomerDataTable tbCustomer = mdBLL.GetCustomerByCustomerName(CustomerName);

                    if (tbCustomer == null || tbCustomer.Count == 0) {
                        errorInfor = "��" + (i + 1) + "���д���Ҳ����ͻ���" + CustomerName + "��";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    ERS.ShopLevelDataTable tbShopLevel = mdBLL.GetShopLevelByShopLevelName(ShopLevelName);

                    if (tbShopLevel == null || tbShopLevel.Count == 0) {
                        errorInfor = "��" + (i + 1) + "���д���Ҳ����ŵ�ȼ���" + ShopLevelName + "��";
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }
                    int iCount =(int) new ShopTableAdapter().SearchNameByIns(ShopName, tbCustomer[0].CustomerID, tbShopLevel[0].ShopLevelID);
                    if (iCount > 0) {
                        errorInfor = string.Format("��" + (i + 1) + "���д��ͬһ�ͻ���ͬһ�ŵ�ȼ�({0})���ŵ�����({1})�����ظ���",tbShopLevel[0].ShopLevelName,ShopName);
                        ImportDS.ImportLogDetailRow ImportDetailRow = ImportLogDetailTable.NewImportLogDetailRow();
                        ImportDetailRow.LogID = logRow.LogID;
                        ImportDetailRow.Line = i + 1;
                        ImportDetailRow.Error = errorInfor;
                        ImportLogDetailTable.AddImportLogDetailRow(ImportDetailRow);
                        logRow.FailCount = logRow.FailCount + 1;
                        logRow.SuccessCount = logRow.SuccessCount - 1;
                        TAImportLog.Update(logRow);
                        continue;
                    }

                    ERS.ShopRow rowShop = tbShop.NewShopRow();

                    //string ShopName = row[0].ToString().Trim();
                    //string ShopNo = row[1].ToString().Trim();
                    //string CustomerNo = row[2].ToString().Trim();
                    //string CustomerName = row[3].ToString().Trim();
                    //string ShopLevelName = row[4].ToString().Trim();
                    //string Address = row[5].ToString().Trim();
                    //string Contacter = row[6].ToString().Trim();
                    //string Telephone = row[7].ToString().Trim();
                    //string Email = row[8].ToString().Trim();

                    rowShop.ShopName = ShopName;
                    rowShop.ShopNo = ShopNo;
                    rowShop.CustomerID = tbCustomer[0].CustomerID;
                    rowShop.ShopLevelID = tbShopLevel[0].ShopLevelID;
                    rowShop.Address = Address;
                    rowShop.Contacter = Contacter;
                    rowShop.Tel = Telephone;
                    rowShop.Email = Email;
                    rowShop.IsActive = true;

                    tbShop.AddShopRow(rowShop);
                    TAShop.Update(rowShop);
                }
            }
            TAImportLog.Update(logRow);
            TAImportLogDetail.Update(ImportLogDetailTable);

            transaction.Commit();
            string returnString = "�ɹ�����" + logRow.SuccessCount.ToString() + "����Ϣ";
            PageUtility.ShowModelDlg(this.Page, returnString);
        } catch (Exception ex) {
            if (transaction != null) {
                transaction.Rollback();
            } PageUtility.ShowModelDlg(this.Page, "Save Fail!" + ex.ToString());
        } finally {
            if (transaction != null) {
                transaction.Dispose();
            }
        }
    }
    protected void CreateBtn_Click(object sender, EventArgs e)
    {
        string strFormID = string.Empty;
        string strFormNo = string.Empty;
        bool isSameCustID = true;
        bool isSameBrandID = true;
        bool isSameYear = true;
        bool isSameSubCategoryID = true;
        bool isSameCurrencyID = true;
        bool isSameCostCenter = true;
        int custID = 0;
        int brandID = 0;
        int year = 0;
        int subCategoryID = 0;
        int currencyID = 0;
        int pageType = 0;
        decimal NeedCreatePOAmount = Convert.ToDecimal(ConfigurationManager.AppSettings["NeedCreatePOAmount"]);
        int costCenterID = 0;
        String NeedPOFormNo = string.Empty;

        MasterDataBLL masterBLL = new MasterDataBLL();
        FormPurchaseBLL purchaseBLL = new FormPurchaseBLL();
        string intFormID = string.Empty;
        foreach (GridViewRow row in this.gvApplyList.Rows) {
            CheckBox CheckCtl = (CheckBox)row.FindControl("CheckCtl");
            if (CheckCtl.Checked) {
                QueryDS.FormSaleApplyViewRow formApply = new FormQueryBLL().GetFormSaleApplyViewByID((int)this.gvApplyList.DataKeys[row.RowIndex].Value);
                FormDS.FormRow form = new FormSaleBLL().GetFormByID((int)this.gvApplyList.DataKeys[row.RowIndex].Value)[0];
                intFormID = formApply.FormID.ToString();
                pageType = formApply.PageType;
                if (custID == 0) {
                    custID = formApply.CustomerID;
                } else {
                    if (custID != formApply.CustomerID) {
                        isSameCustID = false;
                        break;
                    }
                }
                if (brandID == 0) {
                    brandID = formApply.BrandID;
                } else {
                    if (brandID != formApply.BrandID) {
                        isSameBrandID = false;
                        break;
                    }
                }
                if (year == 0) {
                    year = formApply.FPeriod.AddMonths(5).Year;
                } else {
                    if (year != formApply.FPeriod.AddMonths(5).Year) {
                        isSameYear = false;
                        break;
                    }
                }
                if (subCategoryID == 0) {
                    subCategoryID = formApply.ExpenseSubCategoryID;
                } else {
                    if (subCategoryID != formApply.ExpenseSubCategoryID) {
                        isSameSubCategoryID = false;
                        break;
                    }
                }
                if (currencyID == 0) {
                    currencyID = formApply.CurrencyID;
                } else {
                    if (currencyID != formApply.CurrencyID) {
                        isSameCurrencyID = false;
                        break;
                    }
                }
                if (strFormID == string.Empty) {
                    strFormID = this.gvApplyList.DataKeys[row.RowIndex].Value.ToString();
                } else {
                    strFormID = strFormID + "," + this.gvApplyList.DataKeys[row.RowIndex].Value.ToString();
                }
                if (strFormNo == string.Empty) {
                    strFormNo = "P" + form.FormNo + "P";
                } else {
                    strFormNo = strFormNo + "P" + form.FormNo + "P";
                }
                if (costCenterID == 0) {
                    costCenterID = formApply.CostCenterID;
                } else {
                    if (costCenterID != formApply.CostCenterID) {
                        isSameCostCenter = false;
                        break;
                    }
                }

                //�жϽ�����X����Ҫ�½�PO
                MasterData.ExpenseCategoryRow ecr = masterBLL.GetExpenseCategoryById(masterBLL.GetExpenseSubCategoryById(formApply.ExpenseSubCategoryID).ExpenseCategoryID);
                if (formApply.AmountRMB > NeedCreatePOAmount && ecr.NeedPO) {
                    if (purchaseBLL.QueryPOCountByParentFormID(formApply.FormID) <= 0) {
                        NeedPOFormNo += formApply.FormNo + ",";
                    }
                }
            }
        }

        if (strFormID == string.Empty) {
            PageUtility.ShowModelDlg(this, "��ѡ�����뵥!");
            return;
        }

        if (!isSameCustID) {
            PageUtility.ShowModelDlg(this, "��ѡ����ͬ�ͻ������뵥!");
            return;
        }
        if (!isSameBrandID) {
            PageUtility.ShowModelDlg(this, "��ѡ����ͬBrand�����뵥!");
            return;
        }
        if (!isSameYear) {
            PageUtility.ShowModelDlg(this, "��ѡ��ͬһ������뵥!");
            return;
        }
        if (!isSameSubCategoryID) {
            PageUtility.ShowModelDlg(this, "��ѡ��ͬһ����С������뵥!");
            return;
        }
        if (!isSameCurrencyID) {
            PageUtility.ShowModelDlg(this, "��ѡ��ͬһ���ֵ����뵥!");
            return;
        }
        if (!isSameCostCenter) {
            PageUtility.ShowModelDlg(this, "��ѡ��ͬһ�ɱ����ĵ����뵥!");
            return;
        }
        if (NeedPOFormNo != string.Empty) {
            PageUtility.ShowModelDlg(this, string.Format("���뵥{0}������{1}����Ҫ����PO��", NeedPOFormNo, NeedCreatePOAmount));
            return;
        }

        string url = string.Empty;

        if (pageType == (int)SystemEnums.PageType.ActivityApply) {
            if (this.ViewState["SearchCondition"] != null) {
                url = "~/FormSale/ActivitySettlementApply.aspx?FormApplyIds=" + strFormID +
                     "&CustomerID=" + custID.ToString() + "&BrandID=" + brandID.ToString() + "&ExpenseSubCategoryID=" + subCategoryID + "&CurrencyID=" + currencyID+"&CostCenterID="+costCenterID + "&FormApplyNos=" + strFormNo + "&Source=" + HttpUtility.UrlEncode("~/FormSale/SaleApplySelectList.aspx?" + this.ViewState["SearchCondition"].ToString());
            } else {
                url = "~/FormSale/ActivitySettlementApply.aspx?FormApplyIds=" + strFormID +
                     "&CustomerID=" + custID.ToString() + "&BrandID=" + brandID.ToString() + "&ExpenseSubCategoryID=" + subCategoryID + "&CurrencyID=" + currencyID + "&CostCenterID=" + costCenterID + "&FormApplyNos=" + strFormNo + "&Source=" + HttpUtility.UrlEncode("~/FormSale/SaleApplySelectList.aspx");
            }
        } else {
            if (this.ViewState["SearchCondition"] != null) {
                url = "~/FormSale/NoActivitySettlementApply.aspx?FormApplyIds=" + strFormID +
                     "&CustomerID=" + custID.ToString() + "&BrandID=" + brandID.ToString() + "&ExpenseSubCategoryID=" + subCategoryID + "&CurrencyID=" + currencyID + "&CostCenterID=" + costCenterID + "&FormApplyNos=" + strFormNo + "&Source=" + HttpUtility.UrlEncode("~/FormSale/SaleApplySelectList.aspx?" + this.ViewState["SearchCondition"].ToString());
            } else {
                url = "~/FormSale/NoActivitySettlementApply.aspx?FormApplyIds=" + strFormID +
                     "&CustomerID=" + custID.ToString() + "&BrandID=" + brandID.ToString() + "&ExpenseSubCategoryID=" + subCategoryID + "&CurrencyID=" + currencyID + "&CostCenterID=" + costCenterID + "&FormApplyNos=" + strFormNo + "&Source=" + HttpUtility.UrlEncode("~/FormSale/SaleApplySelectList.aspx");
            }
        }
        Response.Redirect(url);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!this.IsPostBack) {
            String title = this.GetLocalResourceObject("titleLabel.Text").ToString();
            PageUtility.SetContentTitle(this.Page, title);

            MasterDataBLL mdBLL = new MasterDataBLL();
            int formID = int.Parse(Request["ObjectId"]);
            this.ViewState["ObjectId"] = formID;
            FormDS.FormSalePaymentRow rowFormPayment = this.FormSaleBLL.GetFormSalePaymentByID(int.Parse(this.ViewState["ObjectId"].ToString()));

            FormDS.FormRow rowForm = this.FormSaleBLL.GetFormByID(formID)[0];
            if (rowForm.IsProcIDNull()) {
                ViewState["ProcID"] = "";
            } else {
                ViewState["ProcID"] = rowForm.ProcID;
            }

            this.FormNoCtl.Text = rowForm.FormNo;
            AuthorizationDS.StuffUserRow applicant = new AuthorizationBLL().GetStuffUserById(rowForm.UserID);
            this.StuffNameCtl.Text = CommonUtility.GetStaffFullName(applicant);
            this.PositionNameCtl.Text = new OUTreeBLL().GetPositionById(rowForm.PositionID).PositionName;
            if (new OUTreeBLL().GetOrganizationUnitById(rowForm.OrganizationUnitID) != null) {
                this.DepartmentNameCtl.Text = new OUTreeBLL().GetOrganizationUnitById(rowForm.OrganizationUnitID).OrganizationUnitName;
            }
            this.AttendDateCtl.Text = applicant.AttendDate.ToShortDateString();

            FormDS.FormSaleSettlementRow rowFormSettlement = this.FormSaleBLL.GetFormSaleSettlementByID(rowFormPayment.FormSaleSettlementID);
            FormDS.FormRow settlementForm = this.FormSaleBLL.GetFormByID(rowFormPayment.FormSaleSettlementID)[0];

            MasterData.CustomerRow customer = mdBLL.GetCustomerById(rowFormSettlement.CustomerID)[0];
            this.CustomerNameCtl.Text = customer.CustomerName;
            this.CustomerChannelCtl.Text = mdBLL.GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelName;
            this.CustomerRegionCtl.Text = mdBLL.GetCustomerRegionById(customer.CustomerRegionID).CustomerRegionName;
            this.CityCtl.Text = customer.City;
            this.BrandCtl.Text = mdBLL.GetBrandById(rowFormSettlement.BrandID)[0].BrandName;
            MasterData.ExpenseSubCategoryRow rowExpenseSubCategory = mdBLL.GetExpenseSubCategoryById(rowFormSettlement.ExpenseSubCategoryID);
            this.ExpenseCategoryCtl.Text = mdBLL.GetExpenseCategoryById(rowExpenseSubCategory.ExpenseCategoryID).ExpenseCategoryName;
            this.ExpenseSubCategoryCtl.Text = rowExpenseSubCategory.ExpenseSubCategoryName;
            this.CurrencyCtl.Text = mdBLL.GetCurrencyByID(rowFormSettlement.CurrencyID).CurrencyShortName;
            this.CostCenterCtl.Text = CommonUtility.GetMAACostCenterFullName(rowForm.CostCenterID);

            this.SettlementRemarkCtl.Text = rowFormSettlement.IsRemarkNull() ? "" : rowFormSettlement.Remark;
            if (!rowFormSettlement.IsAttachedFileNameNull())
                this.UCSettlementFile.AttachmentFileName = rowFormSettlement.AttachedFileName;
            if (!rowFormSettlement.IsRealAttachedFileNameNull())
                this.UCSettlementFile.RealAttachmentFileName = rowFormSettlement.RealAttachedFileName;

            if (!rowFormPayment.IsRemarkNull()) {
                this.RemarkCtl.Text = rowFormPayment.Remark;
            }
            if (!rowFormPayment.IsAttachedFileNameNull()) {
                this.UCPaymentFile.AttachmentFileName = rowFormPayment.AttachedFileName;
            }
            if (!rowFormPayment.IsRealAttachedFileNameNull()) {
                this.UCPaymentFile.RealAttachmentFileName = rowFormPayment.RealAttachedFileName;
            }
            this.PaymentTypeCtl.Text = new MasterDataBLL().GetPaymentTypeById(rowFormPayment.PaymentTypeID).PaymentTypeName;
            if (!rowFormPayment.IsVendorIDNull()) {
                MasterData.VendorRow vendor = new MasterDataBLL().GetVendorByID(rowFormPayment.VendorID);
                this.VendorCtl.Text = vendor.VendorName + "-" + vendor.VendorCode;
            }

            this.SettlementFormNoCtl.Text = settlementForm.FormNo;
            this.SettlementFormNoCtl.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/FormSale/SettlementApproval.aspx?ShowDialog=1&ObjectId=" + rowFormPayment.FormSaleSettlementID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";

            //历史单据
            if (rowForm.IsRejectedFormIDNull()) {
                lblRejectFormNo.Text = "无";
            } else {
                FormDS.FormRow rejectedForm = this.FormSaleBLL.GetFormByID(rowForm.RejectedFormID)[0];
                this.lblRejectFormNo.Text = rejectedForm.FormNo;
                this.lblRejectFormNo.NavigateUrl = "javascript:window.showModalDialog('" + System.Configuration.ConfigurationManager.AppSettings["WebSiteUrl"] + "/FormSale/PaymentFreeGoodsApproval.aspx?ShowDialog=1&ObjectId=" + rejectedForm.FormID + "','', 'dialogWidth:1000px;dialogHeight:750px;resizable:yes;')";
            }

            //费用合计信息
            ApplyAmountRMBCtl.Text = rowFormSettlement.IsApplyAmountRMBNull() ? "" : rowFormSettlement.ApplyAmountRMB.ToString();
            ForecastOrderAmountCtl.Text = rowFormSettlement.IsForecastOrderAmountNull() ? "" : rowFormSettlement.ForecastOrderAmount.ToString();
            CostBenefitRateCtl.Text = rowFormSettlement.IsCostBenefitRateNull() ? "" : rowFormSettlement.CostBenefitRate.ToString();
            AmountRMBCtl.Text = rowFormSettlement.AmountRMB.ToString();
            ActualOrderAmountCtl.Text = rowFormSettlement.IsActualOrderAmountNull() ? "" : rowFormSettlement.ActualOrderAmount.ToString();
            ActualCostBenefitRateCtl.Text = rowFormSettlement.IsActualCostBenefitRateNull() ? "" : rowFormSettlement.ActualCostBenefitRate.ToString();

            //判断是Activity还是NoActivity,如果NoActivity那么需要隐藏
            if (settlementForm.PageType == (int)SystemEnums.PageType.NoActivitySettlementApply) {
                this.FeeSumTR.Visible = false;
                this.SKUDiv.Visible = false;
                this.gvSKUDetails.Visible = false;
            }

            //明细
            this.odsFreeGoods.SelectParameters["FormSalePaymentID"].DefaultValue = rowFormPayment.FormSalePaymentID.ToString();
            this.odsSKUDetails.SelectParameters["FormSaleSettlementID"].DefaultValue = rowFormPayment.FormSaleSettlementID.ToString();
            this.odsPaymentDetails.SelectParameters["FormSalePaymentID"].DefaultValue = rowFormPayment.FormSalePaymentID.ToString();

            //审批页面处理&按钮处理
            AuthorizationDS.StuffUserRow stuffUser = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
            this.ViewState["StuffUserID"] = stuffUser.StuffUserId;
            if (rowForm.InTurnUserIds.Contains("P" + stuffUser.StuffUserId + "P")) {
                this.SubmitBtn.Visible = true;
                this.cwfAppCheck.IsView = false;
                this.ViewState["IsView"] = false;
            } else {
                this.SubmitBtn.Visible = false;
                this.cwfAppCheck.IsView = true;
                this.ViewState["IsView"] = true;
            }

            if (rowForm.StatusID == (int)SystemEnums.FormStatus.Rejected && stuffUser.StuffUserId == rowForm.UserID) {
                this.EditBtn.Visible = true;
                this.ScrapBtn.Visible = true;
            } else {
                this.EditBtn.Visible = false;
                this.ScrapBtn.Visible = false;
            }

            //如果是弹出,取消按钮不可见
            if (this.Request["ShowDialog"] != null) {
                if (this.Request["ShowDialog"].ToString() == "1") {
                    this.upButton.Visible = false;
                    this.Master.FindControl("divMenu").Visible = false;
                    this.Master.FindControl("tbCurrentPage").Visible = false;
                }
            }
            //单据打印
            this.ucPrint.FormID = rowForm.FormID;

            FormDS.FormDeliveryGoodsDataTable tbDelivery= new FormSaleBLL().GetFormDeliveryGoodByFormID(formID);
            if (tbDelivery.Count > 0) {
                this.gvDeliveryInfo.DataSource = tbDelivery;
                this.gvDeliveryInfo.DataBind();
            } else {
                this.divDeliveryInfo.Visible = false;
                this.gvDeliveryInfo.Visible = false;
            }

            //发货完成按钮权限
            int opManageId = BusinessUtility.GetBusinessOperateId(SystemEnums.BusinessUseCase.DeliveryComplete, SystemEnums.OperateEnum.Other);
            AuthorizationDS.PositionRow position = (AuthorizationDS.PositionRow)this.Session["Position"];
            PositionRightBLL positionRightBLL = new PositionRightBLL();
            if (positionRightBLL.CheckPositionRight(position.PositionId, opManageId) && (rowFormPayment.IsIsDeliveryCompleteNull() || rowFormPayment.IsDeliveryComplete == false)) {
                this.DeliveryCompleteBtn.Visible = false;
            }
        }
        this.cwfAppCheck.FormID = (int)this.ViewState["ObjectId"];
        this.cwfAppCheck.ProcID = this.ViewState["ProcID"].ToString();
        this.cwfAppCheck.IsView = (bool)this.ViewState["IsView"];
    }
Exemple #25
0
 public static string GetMAACostCenterFullName(int CostCenterID)
 {
     MasterData.CostCenterRow cc = new MasterDataBLL().GetCostCenterById(CostCenterID);
     return new MasterDataBLL().GetCompanyById(cc.CompanyID).CompanyCode + "-" + cc.CostCenterName + "-" + cc.CostCenterCode;
 }
Exemple #26
0
 public void UpdateFormReimburseSKUDetail(int FormReimburseSKUDetailID, int SKUID, decimal UnitPrice, decimal Quantity, string Remark)
 {
     FormDS.FormReimburseSKUDetailRow rowDetail = this.FormDataSet.FormReimburseSKUDetail.FindByFormReimburseSKUDetailID(FormReimburseSKUDetailID);
     if (rowDetail == null)
         return;
     rowDetail.SKUID = SKUID;
     ERS.SKURow sku = new MasterDataBLL().GetSKUById(SKUID);
     rowDetail.PackageQuantity = sku.PackageQuantity;
     rowDetail.UnitPrice = UnitPrice;
     rowDetail.Quantity = Quantity;
     rowDetail.Amount = UnitPrice * Quantity;
     rowDetail.Remark = Remark;
 }
Exemple #27
0
    protected void OpenForm(int formID)
    {
        FormDS.FormRow rowForm = this.FormSaleBLL.GetFormByID(formID)[0];
        FormDS.FormSaleApplyRow rowFormApply = this.FormSaleBLL.GetFormSaleApplyByID(formID)[0];
        MasterDataBLL MasterDataBLL = new MasterDataBLL();
        //赋值
        this.ViewState["FPeriod"] = rowFormApply.FPeriod.ToShortDateString();
        this.PeriodCtl.Text = rowFormApply.FPeriod.ToString("yyyy-MM");
        this.ViewState["CustomerID"] = rowFormApply.CustomerID.ToString();
        this.ViewState["BrandID"] = rowFormApply.BrandID.ToString();
        this.ViewState["ExpenseSubCategoryID"] = rowFormApply.ExpenseSubCategoryID.ToString();
        this.ViewState["CurrencyID"] = rowFormApply.CurrencyID.ToString();

        MasterData.CustomerRow customer = MasterDataBLL.GetCustomerById(rowFormApply.CustomerID)[0];
        this.txtCustomerNo.Text = customer.CustomerNo;
        this.CustomerNameCtl.Text = customer.CustomerName;
        this.ViewState["CustomerChannelID"] = customer.CustomerChannelID.ToString();
        this.CustomerChannelCtl.Text = MasterDataBLL.GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelName;
        this.KATypeCtl.Text = customer.IsKaTypeNull() ? "" : customer.KaType;
        this.CustomerRegionCtl.Text = MasterDataBLL.GetCustomerRegionById(customer.CustomerRegionID).CustomerRegionName;
        this.CityCtl.Text = customer.City;
        this.BrandCtl.Text = MasterDataBLL.GetBrandById(rowFormApply.BrandID)[0].BrandName;
        MasterData.ExpenseSubCategoryRow rowExpenseSubCategory = MasterDataBLL.GetExpenseSubCategoryById(rowFormApply.ExpenseSubCategoryID);
        this.ExpenseCategoryCtl.Text = MasterDataBLL.GetExpenseCategoryById(rowExpenseSubCategory.ExpenseCategoryID).ExpenseCategoryName;
        this.ExpenseSubCategoryCtl.Text = rowExpenseSubCategory.ExpenseSubCategoryName;
        this.CurrencyCtl.Text = new CurrencyTableAdapter().GetDataByID(rowFormApply.CurrencyID)[0].CurrencyShortName;

        this.ShopNameCtl.Text = rowFormApply.IsShopNameNull() ? "" : rowFormApply.ShopName;
        this.ShopCountCtl.Text = rowFormApply.IsShopCountNull() ? "" : rowFormApply.ShopCount.ToString();
        this.ProjectNameCtl.Text = rowFormApply.IsProjectNameNull() ? "" : rowFormApply.ProjectName;
        if (!rowForm.IsCostCenterIDNull()) {
            this.CostCenterDDL.SelectedValue = rowForm.CostCenterID.ToString();
        }
        if (!rowFormApply.IsActivityBeginDateNull()) {
            this.UCActivityBegin.SelectedDate = rowFormApply.ActivityBeginDate.ToString("yyyy-MM-dd");
        }
        if (!rowFormApply.IsActivityEndDateNull()) {
            this.UCActivityEnd.SelectedDate = rowFormApply.ActivityEndDate.ToString("yyyy-MM-dd");
        }
        this.ProjectDescCtl.Text = rowFormApply.IsProjectDescNull() ? "" : rowFormApply.ProjectDesc;
        if (!rowFormApply.IsApplyFileNameNull())
            this.UCFileUpload.AttachmentFileName = rowFormApply.ApplyFileName;
        if (!rowFormApply.IsApplyRealFileNameNull())
            this.UCFileUpload.RealAttachmentFileName = rowFormApply.ApplyRealFileName;

        // 打开明细表
        new FormSaleExpenseDetailTableAdapter().FillByFormSaleApplyID(this.InnerDS.FormSaleExpenseDetail, formID);
    }
Exemple #28
0
    protected void odsExpenseDetails_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
        DropDownList ExpenseItemDDL = (DropDownList)this.gvExpenseDetails.Rows[this.gvExpenseDetails.EditIndex].FindControl("ExpenseItemDDL");
        MasterData.ExpenseItemRow expenseItem = new MasterDataBLL().GetExpenseItemById(int.Parse(ExpenseItemDDL.SelectedValue));
        TextBox txtShopName = (TextBox)this.gvExpenseDetails.Rows[this.gvExpenseDetails.EditIndex].FindControl("txtShopName");
        if (expenseItem.NeedShopInfo && txtShopName.Text == string.Empty) {
            PageUtility.ShowModelDlg(this.Page, "请录入门店信息", "please key in shop name");
            e.Cancel = true;
            return;
        }

        TextBox txtAmount = (TextBox)this.gvExpenseDetails.Rows[this.gvExpenseDetails.EditIndex].FindControl("txtAmount");
        e.InputParameters["AmountRMB"] = decimal.Round(decimal.Parse(txtAmount.Text) * decimal.Parse(this.ViewState["ExchangeRate"].ToString()), 2);
    }
Exemple #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!this.IsPostBack) {
            String title = this.GetLocalResourceObject("titleLabel.Text").ToString();
            PageUtility.SetContentTitle(this.Page, title);

            // 用户信息,职位信息
            AuthorizationDS.StuffUserRow stuffUser = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
            AuthorizationDS.PositionRow rowUserPosition = (AuthorizationDS.PositionRow)Session["Position"];
            this.ViewState["StuffUserID"] = stuffUser.StuffUserId;
            this.ViewState["PositionID"] = rowUserPosition.PositionId;

            this.StuffNameCtl.Text = CommonUtility.GetStaffFullName(stuffUser);
            this.PositionNameCtl.Text = rowUserPosition.PositionName;
            this.DepartmentNameCtl.Text = new OUTreeBLL().GetOrganizationUnitById(rowUserPosition.OrganizationUnitId).OrganizationUnitName;
            this.ViewState["DepartmentID"] = rowUserPosition.OrganizationUnitId;
            this.StuffNoCtl.Text = stuffUser.IsStuffNoNull() ? "" : stuffUser.StuffNo;
            this.AttendDateCtl.Text = stuffUser.AttendDate.ToShortDateString();

            if (this.Request["RejectObjectID"] != null) {
                this.ViewState["RejectedObjectID"] = int.Parse(this.Request["RejectObjectID"].ToString());
            }
            //如果是草稿进行赋值
            if (Request["ObjectId"] != null) {
                this.ViewState["ObjectId"] = int.Parse(Request["ObjectId"]);
                if (this.Request["RejectObjectID"] == null) {
                    this.DeleteBtn.Visible = true;
                } else {
                    this.DeleteBtn.Visible = false;
                }
                OpenForm(int.Parse(this.ViewState["ObjectId"].ToString()));
            } else {
                this.DeleteBtn.Visible = false;
                if (Request["PeriodSaleID"] != null) {
                    DateTime FPeriod = new MasterDataBLL().GetPeriodSaleById(int.Parse(Request["PeriodSaleID"].ToString())).PeriodSale;
                    this.ViewState["FPeriod"] = new MasterDataBLL().GetPeriodSaleById(int.Parse(Request["PeriodSaleID"].ToString())).PeriodSale.ToShortDateString();
                } else {
                    this.Session["ErrorInfor"] = "没有费用期间,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["BrandID"] != null) {
                    this.ViewState["BrandID"] = Request["BrandID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到Brand,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["CustomerChannelID"] != null) {
                    this.ViewState["CustomerChannelID"] = Request["CustomerChannelID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到Brand,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["CurrencyID"] != null) {
                    this.ViewState["CurrencyID"] = Request["CurrencyID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到币种,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["ExpenseSubCategoryID"] != null) {
                    this.ViewState["ExpenseSubCategoryID"] = Request["ExpenseSubCategoryID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到费用大类,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }

                this.PeriodCtl.Text = DateTime.Parse(this.ViewState["FPeriod"].ToString()).ToString("yyyy-MM");
                this.CustomerChannelCtl.Text = new CustomerChannelTableAdapter().GetDataByID(int.Parse(ViewState["CustomerChannelID"].ToString()))[0].CustomerChannelName;
                this.BrandCtl.Text = new BrandTableAdapter().GetDataByID(int.Parse(this.ViewState["BrandID"].ToString()))[0].BrandName;
                this.CurrencyCtl.Text = new CurrencyTableAdapter().GetDataByID(int.Parse(this.ViewState["CurrencyID"].ToString()))[0].CurrencyShortName;
                this.ExpenseSubCategoryCtl.Text = new MasterDataBLL().GetExpenseSubCategoryById(int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString())).ExpenseSubCategoryName;
            }
            this.hdnBrandID.Value = this.ViewState["BrandID"].ToString();
            this.ExpenseSubCategoryID.Value = this.ViewState["ExpenseSubCategoryID"].ToString();
            this.ViewState["ExchangeRate"] = new MasterDataBLL().GetExchangeRateByPeriod(int.Parse(ViewState["CurrencyID"].ToString()), DateTime.Parse(ViewState["FPeriod"].ToString()));
            if (decimal.Parse(this.ViewState["ExchangeRate"].ToString()) == 0) {
                this.Session["ErrorInfor"] = "未找到汇率,请联系管理员";
                Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
            }
            this.ExchangeRateCtl.Text = this.ViewState["ExchangeRate"].ToString();

            //判断费用期间是否正确
            MasterDataBLL bll = new MasterDataBLL();
            if (!new MasterDataBLL().IsValidPeriodSale(DateTime.Parse(this.ViewState["FPeriod"].ToString()))) {
                this.SubmitBtn.Visible = false;
                PageUtility.ShowModelDlg(this, "不允许申请本月项目,请删除草稿并联系财务部!");
                return;
            }

            //预算信息
            decimal[] calculateAssistant = new decimal[6];
            calculateAssistant = new BudgetBLL().GetRDBudgetByParameter(rowUserPosition.PositionId, DateTime.Parse(ViewState["FPeriod"].ToString()), int.Parse(ViewState["CustomerChannelID"].ToString()), int.Parse(this.ViewState["BrandID"].ToString()), int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()));
            this.TotalBudgetCtl.Text = calculateAssistant[0].ToString("N");
            this.ApprovedAmountCtl.Text = calculateAssistant[1].ToString("N");
            this.ApprovingAmountCtl.Text = calculateAssistant[2].ToString("N");
            this.ReimbursedAmountCtl.Text = calculateAssistant[3].ToString("N");
            this.RemainBudgetCtl.Text = calculateAssistant[4].ToString("N");
        }
        //隐藏预算信息,若需要则隐藏
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
        if (!this.IsPostBack) {
            String title = this.GetLocalResourceObject("titleLabel.Text").ToString();
            PageUtility.SetContentTitle(this.Page, title);

            // 用户信息,职位信息
            AuthorizationDS.StuffUserRow stuffUser = (AuthorizationDS.StuffUserRow)Session["StuffUser"];
            AuthorizationDS.PositionRow rowUserPosition = (AuthorizationDS.PositionRow)Session["Position"];
            this.ViewState["StuffUserID"] = stuffUser.StuffUserId;
            this.ViewState["PositionID"] = rowUserPosition.PositionId;

            this.StuffNameCtl.Text = CommonUtility.GetStaffFullName(stuffUser);
            this.PositionNameCtl.Text = rowUserPosition.PositionName;
            this.DepartmentNameCtl.Text = new OUTreeBLL().GetOrganizationUnitById(rowUserPosition.OrganizationUnitId).OrganizationUnitName;
            this.ViewState["DepartmentID"] = rowUserPosition.OrganizationUnitId;
            this.AttendDateCtl.Text = stuffUser.AttendDate.ToShortDateString();
            this.StuffNoCtl.Text = stuffUser.IsStuffNoNull() ? "" : stuffUser.StuffNo;
            if (this.Request["RejectObjectID"] != null) {
                this.ViewState["RejectedObjectID"] = int.Parse(this.Request["RejectObjectID"].ToString());
            }
            //如果是草稿进行赋值
            if (Request["ObjectId"] != null) {
                this.ViewState["ObjectId"] = int.Parse(Request["ObjectId"]);
                if (this.Request["RejectObjectID"] == null) {
                    this.DeleteBtn.Visible = true;
                } else {
                    this.DeleteBtn.Visible = false;
                }
                FormDS.FormRow rowForm = this.FormSaleBLL.GetFormByID(int.Parse(this.ViewState["ObjectId"].ToString()))[0];
                FormDS.FormSaleSettlementRow rowFormSettlement = this.FormSaleBLL.GetFormSaleSettlementByID(int.Parse(this.ViewState["ObjectId"].ToString()));
                //赋值
                this.ViewState["CustomerID"] = rowFormSettlement.CustomerID.ToString();
                this.ViewState["BrandID"] = rowFormSettlement.BrandID.ToString();
                this.ViewState["ExpenseSubCategoryID"] = rowFormSettlement.ExpenseSubCategoryID.ToString();
                this.ViewState["CurrencyID"] = rowFormSettlement.CurrencyID.ToString();
                this.ViewState["FormApplyNos"] = rowFormSettlement.FormApplyNos;
                this.ViewState["FormApplyIds"] = rowFormSettlement.FormApplyIds;
                this.ViewState["CostCenterID"] = rowForm.CostCenterID.ToString();

                if (!rowFormSettlement.IsRemarkNull()) {
                    this.RemarkCtl.Text = rowFormSettlement.Remark;
                }
                if (!rowFormSettlement.IsAttachedFileNameNull()) {
                    this.UCSettlementFile.AttachmentFileName = rowFormSettlement.AttachedFileName;
                }
                if (!rowFormSettlement.IsRealAttachedFileNameNull()) {
                    this.UCSettlementFile.RealAttachmentFileName = rowFormSettlement.RealAttachedFileName;
                }
                this.PaymentTypeDDL.SelectedValue = rowFormSettlement.PaymentTypeID.ToString();
                //处理明细
                new FormSettlementSKUDetailTableAdapter().FillByFormSaleSettlementID(this.InnerDS.FormSettlementSKUDetail, rowFormSettlement.FormSaleSettlementID);
                new FormSettlementExpenseDetailTableAdapter().FillCurrentDataByFormSaleSettlementID(this.InnerDS.FormSettlementExpenseDetail, rowFormSettlement.FormSaleSettlementID);
            } else {
                this.DeleteBtn.Visible = false;
                if (Request["FormApplyIds"] != null) {
                    this.ViewState["FormApplyIds"] = Request["FormApplyIds"];
                } else {
                    this.Session["ErrorInfor"] = "没有选择申请单,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["CustomerID"] != null) {
                    this.ViewState["CustomerID"] = Request["CustomerID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到客户,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["BrandID"] != null) {
                    this.ViewState["BrandID"] = Request["BrandID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到Brand,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["ExpenseSubCategoryID"] != null) {
                    this.ViewState["ExpenseSubCategoryID"] = Request["ExpenseSubCategoryID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到费用小类,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["CurrencyID"] != null) {
                    this.ViewState["CurrencyID"] = Request["CurrencyID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到币种,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["CostCenterID"] != null) {
                    this.ViewState["CostCenterID"] = Request["CostCenterID"];
                } else {
                    this.Session["ErrorInfor"] = "未找到成本中心,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                if (Request["FormApplyNos"] != null) {
                    this.ViewState["FormApplyNos"] = Request["FormApplyNos"];
                } else {
                    this.Session["ErrorInfor"] = "没有选择申请单,请联系管理员";
                    Response.Redirect("~/ErrorPage/SystemErrorPage.aspx");
                }
                //处理明细
                new FormSettlementSKUDetailTableAdapter().FillByApplyIds(this.InnerDS.FormSettlementSKUDetail, this.ViewState["FormApplyIds"].ToString());
                new FormSettlementExpenseDetailTableAdapter().FillByApplyIds(this.InnerDS.FormSettlementExpenseDetail, this.ViewState["FormApplyIds"].ToString());
            }
            MasterDataBLL mdBLL = new MasterDataBLL();
            MasterData.CustomerRow customer = mdBLL.GetCustomerById(int.Parse(this.ViewState["CustomerID"].ToString()))[0];
            this.CustomerNameCtl.Text = customer.CustomerName;
            ViewState["CustomerChannelID"] = customer.CustomerChannelID.ToString();
            this.CustomerChannelCtl.Text = mdBLL.GetCustomerChannelById(customer.CustomerChannelID)[0].CustomerChannelName;
            this.CustomerRegionCtl.Text = mdBLL.GetCustomerRegionById(customer.CustomerRegionID).CustomerRegionName;
            this.KATypeCtl.Text = customer.IsKaTypeNull() ? "" : customer.KaType;
            this.CityCtl.Text = customer.City;
            this.BrandCtl.Text = mdBLL.GetBrandById(int.Parse(this.ViewState["BrandID"].ToString()))[0].BrandName;
            MasterData.ExpenseSubCategoryRow rowExpenseSubCategory = mdBLL.GetExpenseSubCategoryById(int.Parse(this.ViewState["ExpenseSubCategoryID"].ToString()));
            this.ExpenseCategoryCtl.Text = mdBLL.GetExpenseCategoryById(rowExpenseSubCategory.ExpenseCategoryID).ExpenseCategoryName;
            this.ExpenseSubCategoryCtl.Text = rowExpenseSubCategory.ExpenseSubCategoryName;
            this.CurrencyCtl.Text = new CurrencyTableAdapter().GetDataByID(int.Parse(this.ViewState["CurrencyID"].ToString()))[0].CurrencyShortName;
        }
    }