using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL.EC;
using CY.Model;
using CY.Infrastructure.Common;
using CY.BLL.Integrity;
using CY.BLL;
using System.Threading.Tasks;
using System.Transactions;
using CY.BLL.OA;
namespace CY.WebForm.Pages.business
{
//吴辉
//卖家评价
public partial class Waixiefukuanshenqing : BasePage
{
EC_OrderBasicBLL bll_EC_OrderBasicBLL = null;
EC_OrderBLL _eC_OrderBLL = null;
OA_FukuanshenqingBLL _oA_FukuanshenqingBLL = null;
OA_CorporateClientsBLL _oA_CorporateClientsBLL = null;
OA_StaffBLL bll_OA_StaffBLL = null;
OA_WorkPlanBll oA_WorkReminderBll = null;
OA_SuppliersBLL _OA_SuppliersBLL = null;
//初始化
public Waixiefukuanshenqing()
{
bll_EC_OrderBasicBLL = new EC_OrderBasicBLL();
_eC_OrderBLL = new EC_OrderBLL();
_oA_CorporateClientsBLL = new OA_CorporateClientsBLL();
_oA_FukuanshenqingBLL = new OA_FukuanshenqingBLL();
bll_OA_StaffBLL = new OA_StaffBLL();
oA_WorkReminderBll = new OA_WorkPlanBll();
_OA_SuppliersBLL = new OA_SuppliersBLL();
}
//页面加载
protected void Page_Load(object sender, EventArgs e)
{
try
{
switch (Request["Target"])
{
case "GetSuplier":
LoadCommunication();
break;
default:
if (!IsPostBack)
{
InitData();
}
return;
}
}
catch (Exception ex)
{
PAGEHandleException(ex);
Response.Clear();
//Response.Write("-1");
Response.Write(ex.Message);
}
Response.End();
}
//绑定数据
public void InitData()
{
string orderIdStr = Request["id"];
string orderNoStr = Request["orderno"];
if (!string.IsNullOrEmpty(orderIdStr))
{
this.ordernos.InnerText = orderNoStr.Trim(',');
////供应商
//this.selSuppliers.DataSource = _OA_SuppliersBLL.getSupplierTable(CurrentUser.MemberId);
//this.selSuppliers.DataBind();
//this.selSuppliers.Items.Insert(0, new ListItem("全部", ""));
decimal total = 0;
orderIdStr = orderIdStr.Trim(',');
string[] idsArray = orderIdStr.Split(',');
if (idsArray != null && idsArray.Length > 0)
{
var models = _eC_OrderBLL.GetOrderByIds(orderIdStr).ToList();
if (models.Count > 0)
{
var corporateClients = _oA_CorporateClientsBLL.GetModel(models[0].SellerId);
this.txtSupplierName.Value = corporateClients.OutVendorName;
this.selSuppliersss.Value = corporateClients.Keyid.ToString();
var sss = _OA_SuppliersBLL.getSupplierByFirmId(CurrentUser.MemberId, corporateClients.OutVendorName.Trim()).ToList();
if (sss.Count > 0)
{
this.txtHuming.Value = sss[0].Huming;// ["Huming"].ToString();
this.txtBank.Value = sss[0].Bank; //["Bank"].ToString();
this.txtAccountID.Value = sss[0].AccountID;//["AccountID"].ToString();
}
}
total = models.Sum(x => x.SumPrice) ?? 0;
ordernjine.InnerText = total.ToString("0.00");
this.txtZengjianmoney.Value = total.ToString("0.00");
//khname.InnerText = name;
//Dingdanshu.InnerText = orderIdStr.Split(',').Length +"个";
}
else
{
JavaScript.CloseDIVOpener(this);
}
}
}
///
/// 加载供应商
///
private void LoadCommunication()
{
Response.Clear();
string id = Request["id"];
if (string.IsNullOrEmpty(id))
{
Response.Write("-2");
return;
}
var oA_Suppliers = _OA_SuppliersBLL.getSingleSupplier(id);
Response.Write(null == oA_Suppliers ? "" : JsonHelper.GetJsonStringByObject(oA_Suppliers));
}
//提交事件
protected void btn_Submit_form(object sender, EventArgs e)
{
AcceptAll3();
}
///
/// 批量开票申请
///
public void AcceptAll3()
{
//if (string.IsNullOrEmpty(this.selSuppliers.Value))
//{
// JavaScript.MessageBox("请选择收款单位!", this);
// return;
//}
if (this.txtZengjianmoney.Value.ToDecimal2()<=0)
{
JavaScript.MessageBox("请输入申请金额!", this);
return;
}
string ids = Request["id"].Trim(',');
string orderNoStr = Request["orderno"].Trim(',');
string[] idsArray = ids.Split(',');
if (idsArray != null && idsArray.Length > 0)
{
//EC_OrderBasic eC_OrderBasic = bll_EC_OrderBasicBLL.SelectModelById(idsArray[0].ToInt32().Value);
//OA_CorporateClients oA_CorporateClients = _oA_CorporateClientsBLL.SelectModelByFirmIdandMemberId(CurrentUser.MemberId, eC_OrderBasic.BuyerId);
using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
new TransactionOptions
{
IsolationLevel = IsolationLevel.ReadCommitted,
Timeout = TransactionManager.MaximumTimeout
}
)
)
{
try
{
bool result = false;
OA_Fukuanshenqing oA_Fukuanshenqing = new OA_Fukuanshenqing();
oA_Fukuanshenqing.FirmId = CurrentUser.MemberId;
oA_Fukuanshenqing.SupplierId = this.selSuppliersss.Value;
oA_Fukuanshenqing.Fukuanshenqingstatus = 0;
oA_Fukuanshenqing.ApprovalStatus = 0;
oA_Fukuanshenqing.Fukuanmoney = this.txtZengjianmoney.Value.ToDecimal2();
oA_Fukuanshenqing.Bank = this.txtBank.Value;
oA_Fukuanshenqing.Huming = this.txtHuming.Value;
oA_Fukuanshenqing.AccountID = this.txtAccountID.Value;
oA_Fukuanshenqing.Yishoumoney = 0;
oA_Fukuanshenqing.Youwufapiao = 0;
oA_Fukuanshenqing.Fukuanyongtu = "外协加工费";
oA_Fukuanshenqing.FukuanStatus = 1 ;
oA_Fukuanshenqing.remark = "";
oA_Fukuanshenqing.DindanId = ids;
oA_Fukuanshenqing.Creater = CurrentUser.ShortName;
oA_Fukuanshenqing.CreateTime = DateTime.Now;
oA_Fukuanshenqing.Updater = CurrentUser.ShortName;
oA_Fukuanshenqing.LastUpdateTime = DateTime.Now;
//var oA_Suppliers = _OA_SuppliersBLL.getSingleSupplier(this.selSuppliers.Value);
//var _SupplierName = "";
//if (oA_Suppliers != null)
//{
// _SupplierName = oA_Suppliers.Name;
//}
var _SupplierName = this.txtSupplierName.Value;
oA_Fukuanshenqing.SupplierName = _SupplierName;
var id = _oA_FukuanshenqingBLL.InsertModel(oA_Fukuanshenqing);
//需要添加审批信息
DateTime nowTime = DateTime.Now;
OA_WorkPlan m_OA_WorkPlan = new OA_WorkPlan();
m_OA_WorkPlan.ApprovalContent = "";
m_OA_WorkPlan.ApprovalStaffId = Guid.Empty;
m_OA_WorkPlan.ApprovalStaffName = "";
m_OA_WorkPlan.ApprovalStatus = 0;
m_OA_WorkPlan.ApprovalTime = nowTime;
m_OA_WorkPlan.EvaluationContent = "";
m_OA_WorkPlan.EvaluationStaff = "";
m_OA_WorkPlan.EvaluationStaffId = Guid.Empty;
m_OA_WorkPlan.EvaluationStatus = 0;
m_OA_WorkPlan.EvaluationTime = nowTime;
m_OA_WorkPlan.RewardContent = "";
m_OA_WorkPlan.RewardMoney = 0;
m_OA_WorkPlan.RewardResult = "";
m_OA_WorkPlan.RewardType = 0;
m_OA_WorkPlan.PlanStartTime = nowTime;
m_OA_WorkPlan.PlanStatus = 1;
m_OA_WorkPlan.SentStaffId = CurrentUser.TrueMemberId;
m_OA_WorkPlan.MemberId = CurrentUser.MemberId;
OA_Staff m_OA_Staff = bll_OA_StaffBLL.GetModelByMemberId(CurrentUser.TrueMemberId);
if (m_OA_Staff != null)
m_OA_WorkPlan.DepartId = m_OA_Staff.DepartmentId;
else
m_OA_WorkPlan.DepartId = 0;
m_OA_WorkPlan.PlanPeople = CurrentUser.TrueName;
m_OA_WorkPlan.ReciveStaffId = CurrentUser.TrueMemberId;
m_OA_WorkPlan.Operator = CurrentUser.ShortName;
m_OA_WorkPlan.PlanComplany = id.ToString();
m_OA_WorkPlan.PlanContent = orderNoStr + ",订单金额:" + this.ordernjine.InnerText + ", 收款单位:"+ _SupplierName + "。" ;
m_OA_WorkPlan.PlanDataType = 14;
m_OA_WorkPlan.PlanMoney = oA_Fukuanshenqing.Fukuanmoney;
m_OA_WorkPlan.PlanRemark = oA_Fukuanshenqing.remark;
m_OA_WorkPlan.PlanRunTime = DateTime.Now;
m_OA_WorkPlan.PlanTitle = "订单金额:" + this.ordernjine.InnerText + ", 收款单位:" + _SupplierName + "。";
m_OA_WorkPlan.PlanType = 3;
m_OA_WorkPlan.LastUpdateTime = nowTime;
result = oA_WorkReminderBll.InsertModel(m_OA_WorkPlan);
if (!result)
{
return;
}
//}
scope.Complete();
}
catch (Exception ex)
{
// 回滚事务
}
finally
{
// 释放资源
scope.Dispose();
}
}
//JavaScript.MessageBox("提交成功", this);
//操作成功
JavaScript.MessageBoxsssss("提交成功", this, true, true);
}
}
}
}