SGGL_SHJ/SGGL/FineUIPro.Web/PHTGL/InvoiceManage/InvoiceOrderDetail.aspx.cs

224 lines
8.1 KiB
C#
Raw Normal View History

2024-03-11 23:25:08 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
2024-05-12 20:12:30 +08:00
using System.Security.Policy;
2024-03-11 23:25:08 +08:00
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
2024-05-12 20:12:30 +08:00
using Org.BouncyCastle.Asn1.Ocsp;
2024-03-11 23:25:08 +08:00
namespace FineUIPro.Web.PHTGL.InvoiceManage
{
public partial class InvoiceOrderDetail : PageBase
{
public string InvoiceId {
get
{
return (string)ViewState["InvoiceId"];
}
set
{
ViewState["InvoiceId"] = value;
}
}
public string Type
{
get
{
return (string)ViewState["Type"];
}
set
{
ViewState["Type"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InvoiceId = Request.QueryString["InvoiceId"];
2024-05-12 20:12:30 +08:00
Type = Request.QueryString["Type"];
if (string.IsNullOrEmpty(Type)) //用于取出Type参数的值OA跳转
{
Uri uri = new Uri(Request.UrlReferrer.ToString());
2024-03-11 23:25:08 +08:00
2024-05-12 20:12:30 +08:00
// 获取Type参数的值
Type = HttpUtility.ParseQueryString(uri.Query).Get("Type");
}
2024-03-11 23:25:08 +08:00
Model.PHTGL_Invoice table = new Model.PHTGL_Invoice();
table.ProjectId = this.CurrUser.LoginProjectId;
table.InvoiceId=InvoiceId;
var invoiceModel = BLL.PhtglInvoiceService.GetPHTGL_InvoiceById(InvoiceId);
var ContractModel = BLL.ContractService.GetContractById(invoiceModel.ContractId);
if (invoiceModel != null)
{
txtProjectName.Text=ProjectService.GetProjectNameByProjectId(invoiceModel.ProjectId);
txtContractNum.Text= ContractModel?.ContractNum;
txtSellerName.Text=invoiceModel.SellerName;
txtOrderInDate.SelectedDate=invoiceModel.OrderInDate;
txtInvoiceDate.Text=invoiceModel.InvoiceDate;
txtOrderCode.Text=invoiceModel.OrderCode;
txtInvoiceNumber.Text=invoiceModel.InvoiceNumber;
txtOrderOutDate.SelectedDate=invoiceModel.OrderOutDate;
txtMaterialRequisitionUnit.Text=invoiceModel.MaterialRequisitionUnit;
}
BindGrid();
BindApproveData();
if (Type=="0")
{
Grid1.Title = "入库单列表";
PanelOrderIn.Hidden = false;
}
else if (Type=="1")
{
PanelOrderOut.Hidden = false;
Grid1.Title = "出库单列表";
}
if (invoiceModel.CreateUser== this.CurrUser.PersonId) //创建人
{
TbCreate.Hidden = false;
if (invoiceModel.State> PhtglInvoiceService.StateCreate)
{
Form_approve.Hidden = false;
}
}
if (PHTGL_ApproveService.IsApprovingMan(InvoiceId, this.CurrUser.PersonId)) //判断当前人是否审批人
{
TbApprove.Hidden = false;
Form_approve.Hidden = false;
}
}
}
public void BindApproveData()
{
var approveModel = PHTGL_ApproveService.GetAllApproveData(InvoiceId, Type=="0"? "Invoice_Input" : "Invoice_Output");
if (approveModel != null)
{
Grid2.DataSource = approveModel;
Grid2.DataBind();
}
}
public void BindGrid()
{
var invoiceDetail = PhtglInvoicedetailService.GetPHTGL_InvoiceDetailByInvoiceId(InvoiceId);
Grid1.DataSource = invoiceDetail;
Grid1.DataBind();
txtSumUnitPrice.Text= invoiceDetail.Sum(p=>p.UnitPrice).ToString();
txtSumTax.Text=invoiceDetail.Sum(p=>p.Tax).ToString();
txtSumAmount.Text=invoiceDetail.Sum(p=>p.Amount).ToString();
txtAmountInWords.Text = Funs.NumericCapitalization(invoiceDetail.Sum(p => p.Amount)??0);
}
protected void Grid1_OnRowCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName=="delete")
{
PhtglInvoicedetailService.DeletePHTGL_InvoiceDetailById(e.RowID);
BindGrid();
}
}
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
if (Type=="1")
{
Grid1.FindColumn("btnDelete").Hidden = true;
}
}
protected string GetTaxRate(object eval)
{
string result="";
if (eval!=null)
{
decimal taxRate = Convert.ToDecimal(eval);
string percentage = string.Format("{0:P0}", taxRate);
result= percentage.Replace("%", "");
}
return result;
}
protected string GetNoTaxPrice(object amount, object tax)
{
//获取amount-tax 的值
string result="";
if (amount != null && tax != null)
{
decimal amountValue = Convert.ToDecimal(amount);
decimal taxValue = Convert.ToDecimal(tax);
decimal noTaxPrice = amountValue - taxValue;
result= noTaxPrice.ToString();
}
return result;
}
protected void btnSave_Click(object sender, EventArgs e)
{
var invoiceModel = BLL.PhtglInvoiceService.GetPHTGL_InvoiceById(InvoiceId);
invoiceModel.OrderInDate=txtOrderInDate.SelectedDate;
invoiceModel.OrderOutDate=txtOrderOutDate.SelectedDate;
invoiceModel.OrderCode=txtOrderCode.Text;
invoiceModel.MaterialRequisitionUnit=txtMaterialRequisitionUnit.Text;
BLL.PhtglInvoiceService.UpdatePHTGL_Invoice(invoiceModel);
ShowNotify("保存成功!" ,MessageBoxIcon.Success);
}
protected void btnEditProcess_Click(object sender, EventArgs e)
{
if (Type == "0")
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InvoiceOrderReviewEdit.aspx?InvoiceId={0}&&Type={1}", InvoiceId, "0", "编辑 - ")));
}
else if (Type == "1")
{
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("InvoiceOrderReviewEdit.aspx?InvoiceId={0}&&Type={1}", InvoiceId, "1", "编辑 - ")));
}
}
protected void btnAgree_Click(object sender, EventArgs e)
{
PhtglInvoiceService.Approve(InvoiceId, int.Parse(Type),this.CurrUser.PersonId,true, txtApproveIdea.Text);
ShowNotify("审批成功!", MessageBoxIcon.Success);
if (!string.IsNullOrEmpty(Request.Params["PHTUrl"]))
{
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
PageContext.RegisterStartupScript("closeActiveTab();");
}
else
{
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
}
protected void btnDisgree_Click(object sender, EventArgs e)
{
PhtglInvoiceService.Approve(InvoiceId, int.Parse(Type), this.CurrUser.PersonId, false, txtApproveIdea.Text);
ShowNotify("审批成功!", MessageBoxIcon.Success);
if (!string.IsNullOrEmpty(Request.Params["PHTUrl"]))
{
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
PageContext.RegisterStartupScript("closeActiveTab();");
}
else
{
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
}
}
}