You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
312 lines
12 KiB
312 lines
12 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using CK.SCP.Common;
|
|
using CK.SCP.Controller;
|
|
using CK.SCP.Models.Enums;
|
|
using CK.SCP.Models.ScpEntity;
|
|
using CK.SCP.Utils;
|
|
using FineUI;
|
|
|
|
namespace SCP.Views.锦州锦恒.WarehouseData
|
|
{
|
|
public partial class SCP_INVOICE_CONFIRM_DETAIL : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
IsRoleRight();
|
|
|
|
if (!IsPostBack)
|
|
{
|
|
GetInvoice();
|
|
BindData();
|
|
SetRoleRule();
|
|
}
|
|
}
|
|
|
|
public void IsRoleRight()
|
|
{
|
|
|
|
|
|
if (CurrentUser.FactoryList == null || CurrentUser.FactoryList.Count == 0)
|
|
{
|
|
Alert.Show("当前用户未选择地点!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
private void SetRoleRule()
|
|
{
|
|
//IsPriceVisible(Grid1, "合同价格");
|
|
//IsPriceVisible(Grid1, "合同差额");
|
|
IsPriceVisible(Grid1, "要货日期");
|
|
}
|
|
private void GetInvoice()
|
|
{
|
|
string id = GetQueryValue("ID");
|
|
|
|
SCP_INVOICE_CONTROLLER.Get_V_TB_INVOICE_List(new V_TB_INVOICE { InvcBillNum = id }, (ret) => {
|
|
|
|
if (ret.State == ReturnStatus.Succeed)
|
|
{
|
|
var _ls = ret.Result.ToList();
|
|
if (_ls != null && _ls.Count > 0)
|
|
{
|
|
var _Model = _ls[0];
|
|
Session["invoice"] = _Model;
|
|
txtState.Text = _Model.State_DESC;
|
|
txtBillNo.Text = _Model.InvcBillNum;
|
|
txtBillTime.Text = Convert.ToDateTime(_Model.CreateTime).ToString("yyyy-MM-dd");
|
|
txtSupplierName.Text = _Model.VendName;
|
|
txtInvoiceNumber.Text = _Model.InvoiceNum;
|
|
txtTax.SelectedValue = _Model.Tax != null ? _Model.Tax.Value.ToString() : "0";
|
|
txtTaxAmount.Text = _Model.TaxAmount != null ? _Model.TaxAmount.Value.ToString() : "0";
|
|
txtExpressNumber.Text = _Model.ExpressNum;
|
|
txtAmount.Text = _Model.Amount.ToString();
|
|
txtTotal.Text = _Model.Total != null ? _Model.Total.ToString() : string.Empty;
|
|
txtContractPrice1.Text = _Model.ContractPrice != null ? _Model.ContractPrice.ToString() : string.Empty;
|
|
txtExtend1.Text = _Model.Extend1 != null ? _Model.Extend1.ToString() : string.Empty;
|
|
txtExtend2.Text = _Model.Extend2 != null ? _Model.Extend2.ToString() : string.Empty;
|
|
txtRealTotal.Text = _Model.RealTotal != null ? _Model.RealTotal.ToString() : string.Empty;
|
|
txtBlancePrice1.Text = _Model.BlancePrice != null ? _Model.BlancePrice.ToString() : string.Empty;
|
|
txtMemo.Text = _Model.Remark;
|
|
if (_Model.State == (int)InvoiceState.Apply)
|
|
{
|
|
this.btnCheckFail.Hidden = false;//.Visible = true;
|
|
this.btnCheckSuccess.Hidden = false;//.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
this.btnEdit.Hidden = true;
|
|
this.btnCheckFail.Hidden = true; // Visible = false;
|
|
this.btnCheckSuccess.Hidden = true; //Visible = false;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
this.btnEdit.Enabled = true;
|
|
|
|
|
|
}
|
|
private void Search(Action<IQueryable<V_TB_INVOICE_DETAIL>> p_list)
|
|
{
|
|
string id = GetQueryValue("ID");
|
|
V_TB_INVOICE_DETAIL _tb = new V_TB_INVOICE_DETAIL();
|
|
_tb.InvcBillNum = id;
|
|
SCP_INVOICE_CONTROLLER.Get_V_TB_INVOICE_DETAIL_List(_tb, (ret) => {
|
|
|
|
if (ret.State == ReturnStatus.Succeed)
|
|
{
|
|
p_list(ret.Result);
|
|
}
|
|
});
|
|
}
|
|
|
|
public void BindData()
|
|
{
|
|
Search(ret =>
|
|
{
|
|
Grid1.RecordCount = ret.Count();
|
|
var list = SortAndPage<V_TB_INVOICE_DETAIL>(ret, Grid1).ToList();
|
|
|
|
foreach (V_TB_INVOICE_DETAIL rec in list)
|
|
{
|
|
rec.Qty = ToDecimal(rec.Qty, 2);
|
|
rec.CanQty = ToDecimal(rec.CanQty, 2);
|
|
}
|
|
Grid1.DataSource = list;
|
|
Grid1.DataBind();
|
|
});
|
|
|
|
|
|
}
|
|
|
|
public decimal ToDecimal(decimal num, int scale)
|
|
{
|
|
decimal tempOdds = Math.Round(num, scale);
|
|
return tempOdds;
|
|
}
|
|
|
|
protected void btnCheckFail_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(
|
|
Window1.GetShowReference("../../WarehouseData/SCP_INVOICE_CHECKFAIL.aspx", "采购审核退回")
|
|
);
|
|
}
|
|
|
|
protected void btnCheckSuccess_Click(object sender, EventArgs e)
|
|
{
|
|
if (Session["Invoice"] != null)
|
|
{
|
|
var _Invoice = Session["Invoice"] as V_TB_INVOICE;
|
|
var venderId = _Invoice.VendId;
|
|
|
|
|
|
SET_INVOICE_STATE("采购审核通过", InvoiceState.CheckSuccess);
|
|
}
|
|
|
|
}
|
|
private void SET_INVOICE_STATE(string p_msg, InvoiceState p_state)
|
|
{
|
|
if (Session["Invoice"] != null)
|
|
{
|
|
var _Invoice = Session["Invoice"] as V_TB_INVOICE;
|
|
|
|
_Invoice.Remark = txtMemo.Text;
|
|
|
|
//var ret = SCP_INVOICE_CONTROLLER.SAVE_TB_INVOICE_STATE(_Invoice.InvcBillNum, p_state);
|
|
var ret = SCP_INVOICE_CONTROLLER.SAVE_TB_INVOICE_STATE(_Invoice, p_state, CurrentUser.ChineseName);
|
|
if (ret.State == ReturnStatus.Succeed)
|
|
{
|
|
Alert.Show(p_msg);
|
|
|
|
if (CurrentUser.ConfigList.Keys.Contains("供应商邮件"))
|
|
{
|
|
SCP.Common.MailManager.SendMail(_Invoice.VendId, "采购审核通过", "采购审核通过");
|
|
}
|
|
GetInvoice();
|
|
BindData();
|
|
}
|
|
else
|
|
{
|
|
Alert.Show(ret.Message);
|
|
}
|
|
}
|
|
}
|
|
protected void btnEdit_Click(object sender, EventArgs e)
|
|
{
|
|
var _invoice = Session["invoice"] as V_TB_INVOICE;
|
|
var Memo = MyWebString.GetString(txtMemo.Text.Trim());
|
|
_invoice.Remark = Memo;
|
|
_invoice.Tax = string.IsNullOrEmpty(txtTax.SelectedValue) ? 0 : decimal.Parse(txtTax.SelectedValue);
|
|
_invoice.BlancePrice = string.IsNullOrEmpty(txtBlancePrice1.Text) ? 0 : decimal.Parse(txtBlancePrice1.Text);
|
|
List<V_TB_INVOICE_DETAIL> _ls = new List<V_TB_INVOICE_DETAIL>();
|
|
Dictionary<int, Dictionary<string, object>> modifiedDict = Grid1.GetModifiedDict();
|
|
if (_invoice != null)
|
|
{
|
|
|
|
for (int i = 0, count = Grid1.Rows.Count; i < count; i++)
|
|
{
|
|
object[] rowDataKeys = Grid1.DataKeys[i];
|
|
GridRow row = Grid1.Rows[i];
|
|
V_TB_INVOICE_DETAIL _entity = new V_TB_INVOICE_DETAIL();
|
|
_entity.UID = ConvertHelper.To<Int32>(rowDataKeys[0]);
|
|
_entity.InvcBillNum = rowDataKeys[1] as string;
|
|
_entity.Qty = ConvertHelper.To<Decimal>(rowDataKeys[2]);
|
|
_entity.CanQty = ConvertHelper.To<Decimal>(rowDataKeys[3]);
|
|
_entity.State = ConvertHelper.To<Int32>(rowDataKeys[4]);
|
|
_entity.Price = ConvertHelper.To<decimal>(rowDataKeys[5]);
|
|
if (modifiedDict.Keys.Contains(i))
|
|
{
|
|
var modifyValue = modifiedDict[i];
|
|
_entity.Price = modifyValue.Keys.Contains("Price") ? ConvertHelper.To<decimal>(modifyValue["Price"]) : _entity.Price;
|
|
|
|
}
|
|
var txtLineMemo = (System.Web.UI.WebControls.TextBox)row.FindControl("txtLineMemo");
|
|
_entity.ContractPrice = ConvertHelper.To<Decimal>(rowDataKeys[6]);
|
|
_entity.BlancePrice = ConvertHelper.To<Decimal>(rowDataKeys[7]);
|
|
_entity.Remark = txtLineMemo.Text;
|
|
//把备注添加到TB_INVOICE、TB_INVOICE_DETAIL
|
|
_ls.Add(_entity);
|
|
}
|
|
}
|
|
|
|
if (_ls.Count > 0)
|
|
{
|
|
var ret = SCP_INVOICE_CONTROLLER.SAVE_TB_INVOICE_APPLY(_invoice, _ls);
|
|
if (ret.State == ReturnStatus.Succeed)
|
|
{
|
|
|
|
Alert.Show("发票备注修改成功!");
|
|
|
|
BindData();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.Show("更改记录数为零");
|
|
}
|
|
}
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(e.CloseArgument))
|
|
{
|
|
Alert.Show("请输入退回原因");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
string Memo = e.CloseArgument;
|
|
var _invoice = Session["invoice"] as V_TB_INVOICE;
|
|
|
|
_invoice.State = (int)InvoiceState.CheckFail;
|
|
_invoice.Remark = Memo;
|
|
|
|
List<V_TB_INVOICE_DETAIL> _ls = new List<V_TB_INVOICE_DETAIL>();
|
|
|
|
if (_invoice != null)
|
|
{
|
|
|
|
for (int i = 0, count = Grid1.Rows.Count; i < count; i++)
|
|
{
|
|
object[] rowDataKeys = Grid1.DataKeys[i];
|
|
|
|
|
|
GridRow row = Grid1.Rows[i];
|
|
V_TB_INVOICE_DETAIL _entity = new V_TB_INVOICE_DETAIL();
|
|
|
|
_entity.UID = ConvertHelper.To<Int32>(rowDataKeys[0]);
|
|
_entity.InvcBillNum = rowDataKeys[1] as string;
|
|
_entity.Qty = ConvertHelper.To<Decimal>(rowDataKeys[2]);
|
|
_entity.CanQty = ConvertHelper.To<Decimal>(rowDataKeys[3]);
|
|
_entity.State = (int)InvoiceState.CheckFail;
|
|
_entity.Price = ConvertHelper.To<Decimal>(rowDataKeys[5]);
|
|
_entity.ContractPrice = ConvertHelper.To<Decimal>(rowDataKeys[6]);
|
|
_entity.BlancePrice = ConvertHelper.To<Decimal>(rowDataKeys[7]);
|
|
var txtLineMemo = (System.Web.UI.WebControls.TextBox)row.FindControl("txtLineMemo");
|
|
|
|
_entity.Remark = txtLineMemo.Text;
|
|
|
|
//把备注添加到TB_INVOICE、TB_INVOICE_DETAIL
|
|
_ls.Add(_entity);
|
|
}
|
|
}
|
|
|
|
if (_ls.Count > 0)
|
|
{
|
|
var ret = SCP_INVOICE_CONTROLLER.SAVE_TB_INVOICE_APPLY(_invoice, _ls);
|
|
if (ret.State == ReturnStatus.Succeed)
|
|
{
|
|
|
|
Alert.Show("发票采购退回成功!");
|
|
|
|
if (CurrentUser.ConfigList.Keys.Contains("供应商邮件"))
|
|
{
|
|
SCP.Common.MailManager.SendMail(_invoice.VendId, "发票采购退回成功", "发票采购退回成功");
|
|
}
|
|
BindData();
|
|
GetInvoice();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.Show("退回记录数为零");
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void btnReject_Click(object sender, EventArgs e)
|
|
{
|
|
if (Session["Invoice"] != null)
|
|
{
|
|
var _Invoice = Session["Invoice"] as V_TB_INVOICE;
|
|
var venderId = _Invoice.VendId;
|
|
string url = String.Format("../../WarehouseData/SCP_RECEIVE_LIST.aspx?VendId={0}", venderId);
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(url));
|
|
}
|
|
}
|
|
}
|
|
}
|