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;
namespace CY.WebForm.Pages.business
{
//吴辉
//卖家评价
public partial class kaipiaoConfirm : BasePage
{
EC_OrderBasicBLL bll_EC_OrderBasicBLL = null;
EC_OrderBLL _eC_OrderBLL = null;
OA_KaipiaoshenqingBLL _oA_KaipiaoshenqingBLL = null;
OA_CorporateClientsBLL _oA_CorporateClientsBLL = null;
//初始化
public kaipiaoConfirm()
{
bll_EC_OrderBasicBLL = new EC_OrderBasicBLL();
_eC_OrderBLL = new EC_OrderBLL();
_oA_CorporateClientsBLL = new OA_CorporateClientsBLL();
_oA_KaipiaoshenqingBLL = new OA_KaipiaoshenqingBLL();
}
//页面加载
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitData();
}
}
//绑定数据
public void InitData()
{
string orderIdStr = Request["id"];
if (!string.IsNullOrEmpty(orderIdStr))
{
decimal total = 0;
string name = "";
this.txtOrderIds.Value = orderIdStr;
string[] idsArray = orderIdStr.Split(',');
if (idsArray != null && idsArray.Length > 0)
{
foreach(var item in idsArray)
{
var model = _eC_OrderBLL.GetOrderById(int.Parse(item));
if (model != null)
{
total += model.SumPrice??0;
if(string.IsNullOrEmpty(name))
{
name = model.BuyerName;
}
}
}
}
kpmoney.InnerText = total.ToString("0.00");
khname.InnerText = name;
}
else
{
JavaScript.CloseDIVOpener(this);
}
}
//提交事件
protected void btn_Submit_form(object sender, EventArgs e)
{
AcceptAll3();
}
///
/// 批量开票申请
///
public void AcceptAll3()
{
string ids = this.txtOrderIds.Value;
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())
{
string ssss = DateTime.Now.ToString("yyyyMMdd");
string SellerOrderId = ssss + 1.ToString("000");
string maxSellerOrderId = _oA_KaipiaoshenqingBLL.GetModelByformid(CurrentUser.MemberId).Where(x => x.SellerOrderId.Contains(ssss)).Max(x => x.SellerOrderId);
if (!string.IsNullOrWhiteSpace(maxSellerOrderId))
{
string aaaaaaaaaaaa = maxSellerOrderId.Substring(maxSellerOrderId.Length - 3, 3);
SellerOrderId = ssss + (aaaaaaaaaaaa.ToInt32().Value + 1).ToString("000");
}
OA_Kaipiaoshenqing oA_DeliverPlan = new OA_Kaipiaoshenqing();
oA_DeliverPlan.Keyid = Guid.NewGuid();
oA_DeliverPlan.FirmId = CurrentUser.MemberId;
oA_DeliverPlan.BuyerId = eC_OrderBasic.BuyerId;
oA_DeliverPlan.Kaipiaoshenqing = 1;
oA_DeliverPlan.Kehuqianshou = 1;
oA_DeliverPlan.SellerOrderId = SellerOrderId;
oA_DeliverPlan.remark = this.txtContent.Value;//.Replace("\r\n", "
");
oA_DeliverPlan.KehuqianshouTime = null;
oA_DeliverPlan.KehuqianshouCreater = null;
oA_DeliverPlan.KaipiaoquerenTime = null;
oA_DeliverPlan.KaipiaoquerenCreater = null;
oA_DeliverPlan.BusinessManagerId = oA_CorporateClients.BusinessManagerId ?? 0;
oA_DeliverPlan.Creater = CurrentUser.TrueMemberId;
oA_DeliverPlan.CreateTime = DateTime.Now;
oA_DeliverPlan.Updater = CurrentUser.TrueMemberId;
oA_DeliverPlan.LastUpdateTime = DateTime.Now;
_oA_KaipiaoshenqingBLL.InsertModel(oA_DeliverPlan);
DateTime kaipiaoshenqing = DateTime.Now;
for (int i = 0; i < idsArray.Length; i++)
{
bool result = true;
EC_OrderExtend model = new EC_OrderExtend();
model.Keyid = idsArray[i].ToInt32();
model.KaipiaoshenqingCreater = CurrentUser.TrueMemberId;
model.KaipiaoshenqingTime = kaipiaoshenqing;
model.Kaipiaoshenqing = 1;
model.KaipiaoshenqingId = oA_DeliverPlan.Keyid;
result = _eC_OrderBLL.OldUpdateKaipiaoshenqing(model);
if (!result)
{
return;
}
}
scope.Complete();
}
JavaScript.MessageBox("提交成功", this);
JavaScript.RefreshDIVOpener(this);
}
}
}
}