using LYFZ.ComponentLibrary;
using LYFZ.Model.API;
using LYFZ.Software.MainBusiness.ReportPrint.SetSmallForm;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LYFZ.Software.MainBusiness.DoorCityProcess
{
public partial class OnSingleFormMain01 : LYFZ.Software.UI.DoorCityProcess.OnSingleFormMain
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
LYFZ.BLL.BLL_ErpStyle stbll = new BLL.BLL_ErpStyle();
LYFZ.BLL.BLL_ErpPayment ptbll = new BLL.BLL_ErpPayment();
LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
LYFZ.BLL.BLL_ErpMemberCard mcbll = new BLL.BLL_ErpMemberCard();
LYFZ.BLL.BLL_ErpSystemLogs slogbll = new BLL.BLL_ErpSystemLogs();
LYFZ.BLL.BLL_ErpOrderDigital odbll = new BLL.BLL_ErpOrderDigital();
LYFZ.BLL.BLL_ErpOrdersPerson orpbll = new BLL.BLL_ErpOrdersPerson();
LYFZ.BLL.BLL_SMSTemplates smsTemplates = new BLL.BLL_SMSTemplates();
LYFZ.BLL.BLL_ErpCustomerGroup cgbll = new BLL.BLL_ErpCustomerGroup();
LYFZ.BLL.BLL_ErpHospitalClient hcbll = new BLL.BLL_ErpHospitalClient();
LYFZ.BLL.BLL_ErpWeddingService wsbll = new BLL.BLL_ErpWeddingService();
LYFZ.BLL.BLL_ErpOrderProductLOG ptlog = new BLL.BLL_ErpOrderProductLOG();
LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure();
LYFZ.BLL.BLL_ErpOrderProductList libll = new BLL.BLL_ErpOrderProductList();
LYFZ.BLL.BLL_ErpOrdersPhotography opbll = new BLL.BLL_ErpOrdersPhotography();
LYFZ.BLL.BLL_ErpMemberCardPoints mcptsbll = new BLL.BLL_ErpMemberCardPoints();
LYFZ.BLL.BLL_ErpOrderNumberRecord ornrbll = new BLL.BLL_ErpOrderNumberRecord();
LYFZ.BLL.BLL_ErpMemberCardViceCard mcvbll = new BLL.BLL_ErpMemberCardViceCard();
LYFZ.BLL.BLL_ErpOrderDigitalStatus orsbll = new BLL.BLL_ErpOrderDigitalStatus();
LYFZ.BLL.BLL_ErpMemberCardBackCash mcbcbll = new BLL.BLL_ErpMemberCardBackCash();
LYFZ.BLL.BLL_ErpCustomerGroupMembers cgmbll = new BLL.BLL_ErpCustomerGroupMembers();
LYFZ.BLL.BLL_ErpMemberCardOperateLOG mcopbll = new BLL.BLL_ErpMemberCardOperateLOG();
LYFZ.BLL.BLL_ErpMemberCardPointsLOG mcpslogbll = new BLL.BLL_ErpMemberCardPointsLOG();
LYFZ.BLL.BLL_ErpPackagesGiftMerchandise pgbll = new BLL.BLL_ErpPackagesGiftMerchandise();
LYFZ.BLL.BLL_ErpMemberCardBackCashSet mcbcsetbll = new BLL.BLL_ErpMemberCardBackCashSet();
LYFZ.BLL.BLL_ErpMemberCardInterfaceManagement mcimbll = new BLL.BLL_ErpMemberCardInterfaceManagement();
#region 属性
public bool _bSelectFilm = false;
///
/// 是否是修改订单(从订单报表、保存后这里都会为true)
///
public bool IsUpdateOrderLoad = false;
///
/// 关闭窗体前判断是否提示
///
private bool isClose = true;
///
/// 订单编号
///
public string StrNumber = "";
public int modelId = 0;
///
/// 是否保存
///
public bool IsSaveed = false;
///
/// 订单类型
///
public LYFZ.EnumPublic.OrderType OrdType;
///
/// 用于写入成人客户控件的序号
///
private int ClientAdultNameCount = 1;
///
/// 用于写入儿童客户控件的序号
///
private int ClientChildNameCount = 1;
///
/// 是否显示写真版
///
private bool IsPortrait = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsEnablePhotoEdition;
///
/// 登录都姓名
///
string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
///
/// 登录者员工ID
///
string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
///
/// 本地分店ID
///
string strInfoID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
///
/// 当前客户数量
///
int AddClinetCount = 0;
///
/// 订单客户组编号
///
string OrderGroupNumber = "";
///
/// 来单批号
///
string ComeSingleLotNumber = "";
///
/// 覆盖订单数据时候,是否覆盖客户数据
///
bool UpdateOrderIsUpdateClientData = true;
///
/// 如果没有保存权限,是否已授过权
///
bool IsSaveedHadAuthorized = false;
///
/// 当前登录者、授权者的保利系数
///
decimal dec_OrderDiscounts = 0;
///
/// 客户来源《朋友介绍——副卡资料》
///
LYFZ.Model.Model_ErpMemberCardViceCard modelViceCard = null;
///
/// 客户来源《朋友介绍——朋友资料》
///
LYFZ.Model.Model_ErpCustomer modelFriends = null;
///
/// 老客户信息
///
LYFZ.Model.Model_ErpCustomer modelOldClient = null;
///
/// 介绍人要办理的会员卡号
///
public string StrReferralsMemberCardNumber = "";
///
/// 介绍人要修改的电话号码
///
public string StrReferralsClientPhone = "";
bool _isIntentionOrder = false;
string _UploadPath = "";
///
/// 当前打开的是否为意向订单
///
bool IsIntentionOrder
{
get { return _isIntentionOrder; }
set { _isIntentionOrder = value; }
}
public LoadFormType EnumLoadFormType;
public enum LoadFormType
{
订单报表,
开单选择
}
///
/// 旧套系名称
///
string strOldTaoXiName { get; set; }
///
/// 旧套系名称
///
string strOldTaoXiCode { get; set; }
///
/// 旧套系金额
///
decimal strOldTaoXiPrice { get; set; }
string strPersonData { get; set; }
#endregion
#region 窗体事件
public OnSingleFormMain01()
{
this.Shown += OnSingleFormMain_Shown;
this.Load += OnSingleFormMain_Load;
this.btnSaveIntent.Click += btnSaveIntent_Click;
this.btnSave.Click += btnSave_Click;
this.btnPrint.Click += btnPrint_Click;
this.btnNewOrder.Click += btnNewOrder_Click;
this.btnOrderClose.Click += btnOrderClose_Click;
this.FormClosing += OnSingleFormMain_FormClosing;
this.FormClosed += OnSingleFormMain_FormClosed;
this.Resize += OnSingleFormMain_Resize;
#region 第一页
this.btnSourceSet.Click += btnSourceSet_Click;
this.btnStyleSet.Click += btnStyleSet_Click;
this.pictAddClient.Click += pictAddClient_Click;
this.btnSelectUser.Click += btnSelectUser_Click;
this.panelEx3.Click += panelEx3_Click;
this.panelEx2.Click += panelEx2_Click;
this.panelVice1.Click += panelVice1_Click;
this.PanelMain1.Click += PanelMain1_Click;
this.chkOldClient.Click += chkOldClient_Click;
this.chkFriends.Click += chkFriends_Click;
this.chkHospitalClient.Click += chkHospitalClient_Click;
this.chkOther.Click += chkOther_Click;
this.lblYiXiangClient.Click += lblYiXiangClient_Click;
this.lblBrowseSelect.Click += lblBrowseSelect_Click;
#endregion
#region 第二页
this.tabControl.SelectedIndexChanged += tabControl_SelectedIndexChanged;
this.PanelMain2.Click += PanelMain2_Click;
this.PanelMain3.Click += PanelMain3_Click;
#endregion
#region 上传预约单
this.btnUpload.Click += btnUpload_Click;
this.btnShow.Click += btnShow_Click;
#endregion
//TestData();
}
void SetButtonPostionData()
{
btnUpload.Location = new Point(this.Width - 170, btnUpload.Location.Y);
btnShow.Location = new Point(this.Width - 85, btnShow.Location.Y);
}
#region 上传预约单
void btnShow_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this._UploadPath))
{
string resData = "";
string downFilePath = Application.StartupPath + "\\Temp\\UploadFile\\" + System.IO.Path.GetFileName(this._UploadPath);
LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
{
LYFZ.Software.MainBusiness.TCPFileTransfer tcpFile = new MainBusiness.TCPFileTransfer();
resData = tcpFile.DownloadFile(downFilePath, this._UploadPath, backgroundWorker);
});
//LYFZ.Software.MainBusiness.SystemSettings.frmShowPictureBox showPictureBox = new SystemSettings.frmShowPictureBox()
//{
// filePath = filePath
//};
//showPictureBox.ShowDialog();
System.Diagnostics.Process.Start(downFilePath);
}
else
{
MessageBoxCustom.Show("未上传预约单!");
}
}
void btnUpload_Click(object sender, EventArgs e)
{
OpenFileDialog openDlg = new OpenFileDialog();
openDlg.Multiselect = false;
if (openDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
DateTime startime = DateTime.Now;
string filePath = openDlg.FileName.Trim();
if (filePath.Length > 0)
{
bool b = false;
string retmsg = "";
string servicePath= "UploadFiles\\ReservationForm\\" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + System.IO.Path.GetExtension(filePath);
LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
{
try
{
LYFZ.Software.MainBusiness.TCPFileTransfer tcpFile = new MainBusiness.TCPFileTransfer();
retmsg = tcpFile.UploadFileToServer(filePath, servicePath, backgroundWorker);
//tcpFile.
b = true;
}
catch (Exception ex)
{
retmsg = ex.Message;
b = false;
}
});
//this.textBoxEx2.Text = retmsg;
//this.labelEx3.Text = "上传完成 用时:" + ExecDateDiff(startime, DateTime.Now) + " 毫秒数 " + (ExecDateDiff(startime, DateTime.Now) / 1000) + " 秒";
if(b)
{
_UploadPath = servicePath;
MessageBoxCustom.Show(
retmsg + "\r\n" +
"上传完成"
);
/// 用时:" + LYFZ.WinAPI.CustomPublicMethod.ExecDateDiff(startime, DateTime.Now) + " 毫秒数 " + (LYFZ.WinAPI.CustomPublicMethod.ExecDateDiff(startime, DateTime.Now) / 1000) + " 秒
}
else
{
MessageBoxCustom.Show(
"上传失败\r\n" + retmsg
);
}
}
}
}
#endregion
///
/// 窗体加载事件
///
///
///
void OnSingleFormMain_Shown(object sender, EventArgs e)
{
this.Text = "开单(" + this.OrdType.ToString().Trim() + ")";
this.flowPanel0.Location = new Point(this.flowPanel0.Location.X, tabControl.Location.Y - 2);// this.flowPanel0.Location.Y);
this.FillClientDataPanelHeight();
this.PanelMain1_Click(this, null);
///保存意向订单的版本权限
List hideControl = new List();
//LYFZSS.SystemSpecterPossessed.ISystemSpecterPossessed.GetMySystemSpecter = LYFZSS.SystemSpecterType.SST_D;
hideControl.Add(this.btnSaveIntent);
LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(
VersionControl.VersionFunctionEnum.开单保存意向订单, hideControl, null, null);
///自动开会员版本权
hideControl = new List();
//LYFZSS.SystemSpecterPossessed.ISystemSpecterPossessed.GetMySystemSpecter = LYFZSS.SystemSpecterType.SST_D;
hideControl.Add(this.panelTransactmemberCard);
LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(
VersionControl.VersionFunctionEnum.开单自动开会员, hideControl, null, null);
SetButtonPostionData();
}
///
/// 窗体加载事件
///
///
///
void OnSingleFormMain_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.StrNumber))
{
DataTable odbDt = odbll.GetOrderDigitalByNumberHandSelect(this.StrNumber);
if (odbDt.Rows.Count > 0)
{
_bSelectFilm = true;
}
}
this.StyleSetAdd();
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_ClientSourec("AAAAAAF", this.cmbtreevClientSource, strHideFiled: "BFACBABGBGBJGDHIE,BFAFBCBADBDCABFDD,AAAAABT");
this.chBox_Click();
#region 权限与加载
if (this.StrNumber == "")
{
this.tap3.Parent = null;
//this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresOPenSingle, LYFZ.CustomAttributes.OperatingAuthority.NewOrder);
this.GetTransactmemberCard();
}
else
{
this.btnSaveIntent.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresOPenSingle, LYFZ.CustomAttributes.OperatingAuthority.ModifyOrder);
this.OpenSingleLoad();
}
this.btnPrint.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresOPenSingle, LYFZ.CustomAttributes.OperatingAuthority.Print);
this.btnStyleSet.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresOPenSingle, LYFZ.CustomAttributes.OperatingAuthority.OrderLoveStyleSet);
this.btnSourceSet.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StoresOPenSingle, LYFZ.CustomAttributes.OperatingAuthority.OrderClientSourceSet);
#endregion
}
void RebindUpgrade(bool b)
{
if (this.OrderEx != null)
{
this.OrderEx.bUpgrade = b;
}
//throw new NotImplementedException();
if (this.OrderProductEx != null)
{
this.OrderProductEx.bUpgrade = b;
}
if (OrderServiceEx != null)
{
OrderServiceEx.bUpgrade = b;
}
if (this.OrderSightsEx != null)
{
this.OrderSightsEx.bUpgrade = b;
}
else if (this.OrderStagesEx != null)
{
this.OrderStagesEx.bUpgrade = b;
}
}
///
/// 打开订单数据
///
void OpenSingleLoad()
{
RebindUpgrade(false);
this.IsSaveedHadAuthorized = false;
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
LYFZ.Model.Model_ErpOrder modelorder = orbll.GetModel(this.StrNumber);
if (modelorder.ID <= 0)
{ return; }
else
{
this._UploadPath = modelorder.Ord_UploadPath;
this.strOldTaoXiName = modelorder.Ord_OldSeriesName;
this.strOldTaoXiPrice = modelorder.Ord_OldSeriesPrice;
this.strOldTaoXiCode = modelorder.Ord_OldSeriesCode;
modelId = modelorder.ID;
this.OrdType = (LYFZ.EnumPublic.OrderType)Enum.Parse(typeof(LYFZ.EnumPublic.OrderType), modelorder.Ord_Type);
if (modelorder.Ord_Class == "0")
{
IsIntentionOrder = true;
}
DataTable tbl_P = orbll.GetView_Custom("tb_ErpOrdersPerson", StrWhere: "OrdPe_OrderNumber = '" + this.StrNumber + "'", filedOrder: "OrdPe_Type ASC", ShowColumnName: "dbo.fn_CheckUserIDGetUserName(OrdPe_OrdersPerson) AS OrdPe_OrdersPersonName,OrdPe_OrdersPerson,OrdPe_Type").Tables[0];
DataTable tblFriends = orbll.GetView_Custom("tb_ErpCustomerGroup", StrWhere: "GP_OrderNumber = '" + this.StrNumber + "'", ShowColumnName: "GP_CustomerGroupID,GP_IntroducerCustomerID").Tables[0];
List mlistClient = new List();
List mlistClientRelation = new List();
string StrMasterNumber = "";
string StrChildNumber = "";
DataTable tblGroup = orbll.GetView_Custom("tb_ErpCustomerGroup", StrWhere: "GP_OrderNumber = '" + this.StrNumber + "'", ShowColumnName: "GP_CustomerGroupID").Tables[0];
if (tblGroup.Rows.Count > 0)
{
DataTable tblClientGroup = orbll.GetView_Custom("View_CustomerGroupMembersAndErpCustomer", StrWhere: "GM_CustomerGroupID = '" + tblGroup.Rows[0]["GP_CustomerGroupID"].ToString().Trim() + "'", ShowColumnName: "Cus_CustomerNumber,GM_Master,GM_RelatedPersonID,GM_Relation,GM_ProtagonistCustomer").Tables[0];
for (int i = 0; i < tblClientGroup.Rows.Count; i++)
{
if (tblClientGroup.Rows[i]["GM_Master"].ToString().Trim() == "1")
{ StrMasterNumber = tblClientGroup.Rows[i]["Cus_CustomerNumber"].ToString().Trim(); }
if (modelorder.Ord_Type == "1")
{
if (tblClientGroup.Rows[i]["GM_ProtagonistCustomer"].ToString().Trim() == "1")
{ StrChildNumber = tblClientGroup.Rows[i]["Cus_CustomerNumber"].ToString().Trim(); }
}
LYFZ.Model.Model_ErpCustomer modelClient = ctbll.GetModel("Cus_CustomerNumber", tblClientGroup.Rows[i]["Cus_CustomerNumber"].ToString().Trim());
if (modelClient.ID > 0)
{
mlistClient.Add(modelClient);
mlistClientRelation.Add(tblClientGroup.Rows[i]["GM_Relation"].ToString().Trim());
}
}
}
try
{
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{
if (modelorder.Ord_Class == "1")
{ this.btnSaveIntent.Visible = false; }
else
{ this.btnSaveIntent.Visible = true; }
if (this.IsUpdateOrderLoad)
{ this.lblYiXiangClient.Enabled = false; this.panelTransactmemberCard.Visible = false; }
#region 订单资料
if (this.UpdateOrderIsUpdateClientData)
{
this.AddClinetCount = 0;
}
this.tabControl.SelectedIndex = 1;
bool IsActivity = false;
switch (this.OrdType)
{
case EnumPublic.OrderType.婚纱订单:
case EnumPublic.OrderType.儿童订单:
case EnumPublic.OrderType.写真订单:
case EnumPublic.OrderType.婚庆订单:
this.OrderEx.StrCustomPrefix = this.GetOrderCustomPrefix();
IsActivity = this.OrderEx.SetOrderValue(modelorder);
if (this.OrderSightsEx != null)
{
this.OrderSightsEx.SetOrderSightsValue(this.StrNumber, modelorder.Ord_SeriesName);
this.OrderSightsEx.OrdType = (int)this.OrdType;
}
else if (this.OrderStagesEx != null)
{ this.OrderStagesEx.SetOrderStagesValue(this.StrNumber, modelorder.Ord_SeriesName); }
break;
case EnumPublic.OrderType.服务订单:
this.ServiceOrderEx.StrCustomPrefix = this.GetOrderCustomPrefix();
this.ServiceOrderEx.SetOrderValue(modelorder);
break;
}
try
{
this.OrderServiceEx.SetOrderServiceValue(this.StrNumber, IsActivity, modelorder.Ord_SeriesName);
this.OrderProductEx.SetOrderProductValue(this.StrNumber, IsActivity, modelorder.Ord_SeriesName);
}
catch (Exception ex)
{
MessageBoxCustom.Show(ex.Message + ",原因:可能是“tb_ErpOrderProductList”商品唯一标识重复");
}
#endregion
#region 接单人
string PersonName = "";
string PersonTag = "";
string PersonType = "";
for (int i = 0; i < tbl_P.Rows.Count; i++)
{
if (i == 0)
{
PersonName = tbl_P.Rows[i]["OrdPe_OrdersPersonName"].ToString().Trim();
PersonTag = tbl_P.Rows[i]["OrdPe_OrdersPerson"].ToString().Trim();
PersonType = tbl_P.Rows[i]["OrdPe_Type"].ToString().Trim();
}
else
{
PersonName += "," + tbl_P.Rows[i]["OrdPe_OrdersPersonName"].ToString().Trim();
PersonTag += "," + tbl_P.Rows[i]["OrdPe_OrdersPerson"].ToString().Trim();
PersonType += "," + tbl_P.Rows[i]["OrdPe_Type"].ToString().Trim();
}
}
this.txtOrderPerson.Text = PersonName;
this.txtOrderPerson.Tag = PersonTag + "|" + PersonType;
strPersonData = modelorder.Ord_CommissionRatio;
#endregion
#region 客户来源
if (modelorder.Ord_CustomerSource.Trim() == "朋友介绍")
{
this.chkFriends.Checked = true;
if (tblFriends.Rows.Count > 0)
{
if (tblFriends.Rows[0]["GP_IntroducerCustomerID"].ToString().Trim() != "")
{
this.modelFriends = ctbll.GetModel("Cus_CustomerNumber", tblFriends.Rows[0]["GP_IntroducerCustomerID"]);
string StrCardType = "";
string StrCardTypeShow = "";
DataTable dt = orbll.GetView_Custom("tb_ErpMemberCard", StrWhere: "Mc_CustomerNumber = '" + this.modelFriends.Cus_CustomerNumber + "' And Mc_CradNumber != ''", ShowColumnName: "Mc_CardType").Tables[0];
if (dt.Rows.Count > 0)
{
StrCardType = ";主卡等级:" + dt.Rows[0]["Mc_CardType"].ToString().Trim();
if (dt.Rows[0]["Mc_CardType"].ToString().Trim() != "无")
{ StrCardTypeShow = " - " + dt.Rows[0]["Mc_CardType"].ToString().Trim(); }
}
LYFZ.Model.Model_ErpMemberCardBackCashSet modelCashSet = mcbcsetbll.GetModel("Mcb_OrderNumber", modelorder.Ord_Number);
if (modelCashSet.ID > 0)
{
this.modelViceCard = mcvbll.GetModel("Mvc_ViceNumber", modelCashSet.Mcb_ViceNumber);
this.chkFriends.Text = this.chkFriends.Tag + "(" + this.modelFriends.Cus_Name.Trim() + StrCardTypeShow + " - 副卡)";
this.toolTip1.SetToolTip(this.chkFriends, "朋友介绍(介绍人:" + this.modelFriends.Cus_Name + StrCardType + ";副卡卡号:" + this.modelViceCard.Mvc_ViceCardNumber + ")");
}
else
{
if (this.modelFriends.Cus_Name != null)
{
this.chkFriends.Text = this.chkFriends.Tag + "(" + this.modelFriends.Cus_Name.Trim() + StrCardTypeShow + ")";
this.toolTip1.SetToolTip(this.chkFriends, "朋友介绍(介绍人:" + this.modelFriends.Cus_Name + StrCardType + ")");
}
}
}
}
}
else if (modelorder.Ord_CustomerSource.Trim() == "老客户")
{ this.chkOldClient.Checked = true; }
else if (modelorder.Ord_CustomerSource.Trim() == "医院跟踪客户")
{ this.chkHospitalClient.Checked = true; }
else
{
this.chkOther.Checked = true;
this.cmbtreevClientSource.Enabled = true;
this.cmbtreevClientSource.TextFindTag(modelorder.Ord_CustomerSource.Trim());
}
#endregion
#region 喜爱格调
if (modelorder.Ord_LovedStyle.Trim() != "")
{
if (modelorder.Ord_LovedStyle.Trim().IndexOf('|') != -1)
{
string[] LovedStylelist = modelorder.Ord_LovedStyle.Trim().Split('|');
if (LovedStylelist.Length > 0)
{
for (int i = 0; i < LovedStylelist.Length; i++)
{
try
{
((CheckBoxEx)panelEx3.Controls[LovedStylelist[i]]).Checked = true;
}
catch { }
}
}
}
else
{ ((CheckBoxEx)panelEx3.Controls[modelorder.Ord_LovedStyle.Trim()]).Checked = true; }
}
#endregion
#region 客户资料
this.chBox_Click();
if (this.UpdateOrderIsUpdateClientData)
{
foreach (Control control in this.flowPanel1.Controls)
{
if (control is SetCustomControls.OrderClientParentsControlsEx)
{
SetCustomControls.OrderClientParentsControlsEx tmp = (SetCustomControls.OrderClientParentsControlsEx)control;
if (tmp.StrClientAttribute == "Man_")
{
for (int i = 0; i < mlistClient.Count; i++)
{
if (mlistClient[i].Cus_CustomerNumber == StrMasterNumber)
{
this.SetMarriageValue(mlistClient[i].Cus_DayForMarriage.Trim(), mlistClient[i].Cus_DayForMarriageLunar);
tmp.SetClientValue(mlistClient[i], true, mlistClientRelation[i].Trim());
tmp.IsPictResetShow = true;
tmp.IsPictEditShow = true;
mlistClient.RemoveAt(i);
mlistClientRelation.RemoveAt(i);
break;
}
}
}
else
{
for (int i = 0; i < mlistClient.Count; i++)
{
if (mlistClient[i].Cus_CustomerNumber != StrChildNumber && mlistClient[i].Cus_CustomerNumber.Trim() == StrMasterNumber)
{
this.SetMarriageValue(mlistClient[i].Cus_DayForMarriage.Trim(), mlistClient[i].Cus_DayForMarriageLunar);
tmp.SetClientValue(mlistClient[i], true, mlistClientRelation[i].Trim());
tmp.IsPictResetShow = true;
tmp.IsPictEditShow = true;
mlistClient.RemoveAt(i);
mlistClientRelation.RemoveAt(i);
break;
}
}
}
}
else if (control is SetCustomControls.OrderClientChildrenControlsEx)
{
SetCustomControls.OrderClientChildrenControlsEx tmp = (SetCustomControls.OrderClientChildrenControlsEx)control;
for (int i = 0; i < mlistClient.Count; i++)
{
if (mlistClient[i].Cus_CustomerNumber.Trim() == StrChildNumber)
{
tmp.SetClientValue(mlistClient[i], true);
tmp.IsPictResetShow = true;
tmp.IsPictEditShow = true;
mlistClient.RemoveAt(i);
mlistClientRelation.RemoveAt(i);
break;
}
}
}
}
if (mlistClient.Count > 0)
{
for (int i = 0; i < mlistClient.Count; i++)
{
this.SetMarriageValue(mlistClient[i].Cus_DayForMarriage.Trim(), mlistClient[i].Cus_DayForMarriageLunar);
this.ClientAdultPanelAdd("其他联系人" + ClientAdultNameCount, model: mlistClient[i], MainClientRelation: mlistClientRelation[i].Trim());
this.AddClinetCount++;
}
}
}
#endregion
this.Text = "开单(" + this.OrdType.ToString().Trim() + ")";
}));
}
catch { }
}
});
this.tabControl.SelectedIndex = 0;
}
///
/// 赋婚期值
///
///
///
void SetMarriageValue(string StrValue, string StrLunar)
{
switch (this.OrdType)
{
case EnumPublic.OrderType.婚纱订单:
case EnumPublic.OrderType.婚庆订单:
case EnumPublic.OrderType.服务订单:
this.mskMarriage.StrValue = StrValue;
this.chkMarriage.Checked = LYFZ.Command.Command_Validate.DateLunar(StrLunar);
break;
}
}
///
/// 获取前缀
///
///
private string GetOrderCustomPrefix()
{
string StrCustomPrefix = "";
if (this.OrdType == LYFZ.EnumPublic.OrderType.婚纱订单)
{ StrCustomPrefix = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPrefix(LYFZ.EnumPublic.OrderNumberPrefixType.婚纱订单).Trim(); }
else if (this.OrdType == LYFZ.EnumPublic.OrderType.儿童订单)
{ StrCustomPrefix = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPrefix(LYFZ.EnumPublic.OrderNumberPrefixType.儿童订单).Trim(); }
else if (this.OrdType == LYFZ.EnumPublic.OrderType.写真订单)
{ StrCustomPrefix = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPrefix(LYFZ.EnumPublic.OrderNumberPrefixType.写真订单).Trim(); }
else if (this.OrdType == LYFZ.EnumPublic.OrderType.服务订单)
{ StrCustomPrefix = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPrefix(LYFZ.EnumPublic.OrderNumberPrefixType.服务订单).Trim(); }
else if (this.OrdType == LYFZ.EnumPublic.OrderType.婚庆订单)
{ StrCustomPrefix = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPrefix(LYFZ.EnumPublic.OrderNumberPrefixType.婚庆订单).Trim(); }
return StrCustomPrefix;
}
///
/// 填充客户层的高
///
void FillClientDataPanelHeight()
{
if (this.panelVice1.Height < (this.tap1.Height - 12))
{
this.panelVice1.Height = this.tap1.Height - 12;
this.flowPanel1.Height = this.panelVice1.Height - this.flowPanel1.Location.Y;
}
}
///
/// 检查数据是否被修改过
///
///
bool CheckDataIsUpdate()
{
bool IsUpdateSaveed = false;
if (this.OrdType == EnumPublic.OrderType.服务订单)
{ }
else
{
ComboBoxTreeViewEx cmbtreevTaoXiName = OrderEx.CmbtreevTaoXi;
if (cmbtreevTaoXiName.Tag != null)
{
DataRow[] dtRow0 = null;
DataRow[] dtRow1 = null;
DataRow[] dtRow2 = null;
DataTable tbl0 = null;
DataTable tbl1 = null;
DataTable tbl2 = null;
string ExecuteSql = "select tb_ErpPackagesGiftMerchandise.ID,Sc_ClassName,Pgm_GiveType,Pgm_IntoRegisterQuantity,Pgm_IntoBottomQuantity,Pgm_Quantity " +
"from tb_ErpPackagesGiftMerchandise Left Join tb_ErpTheScenery on cast(tb_ErpTheScenery.ID as varchar(20)) = Pgm_ProductNumber " +
"Left Join tb_ErpSystemCategory on Tsc_Rating = Sc_ClassCode where Pgm_GiveType in ('2','3') And Pgm_PackagesCode = '" + cmbtreevTaoXiName.Tag.ToString().Trim() + "';";
ExecuteSql += "select tb_ErpPackagesGiftMerchandise.ID,Prod_Batch,Pgm_Quantity,Pgm_GiveType from tb_ErpPackagesGiftMerchandise " +
"Left Join tb_ErpProduct on Prod_Number = Pgm_ProductNumber where Pgm_GiveType in ('0','1') And Pgm_PackagesCode = '" + cmbtreevTaoXiName.Tag.ToString().Trim() + "';";
ExecuteSql += "select Pak_UnitPrice from tb_ErpPackages where Pak_PackagesID = '" + cmbtreevTaoXiName.Tag.ToString().Trim() + "';";
DataSet dsData = orbll.GetView_Custom(ExecuteSql);
DataTable dt0 = dsData.Tables["ds"];
DataTable dt1 = dsData.Tables["ds1"];
DataTable dt2 = dsData.Tables["ds2"];
switch (this.OrdType)
{
case EnumPublic.OrderType.儿童订单:
case EnumPublic.OrderType.婚纱订单:
case EnumPublic.OrderType.写真订单:
case EnumPublic.OrderType.婚庆订单:
#region 判断价格
if (dt2.Rows.Count > 0)
{
if (Convert.ToDecimal(dt2.Rows[0]["Pak_UnitPrice"]) != Convert.ToDecimal(this.OrderEx.TaoXiPrice))
{ IsUpdateSaveed = true; }
}
#endregion
#region 判断入底入册
switch (this.OrdType)
{
case EnumPublic.OrderType.写真订单:
case EnumPublic.OrderType.婚庆订单:
try
{
DataTable dt = orbll.GetView_Custom("tb_ErpPackages", StrWhere: "Pak_PackagesID = '" + cmbtreevTaoXiName.Tag.ToString().Trim() + "'", ShowColumnName: "Pak_IntoTheArchive,Pak_IntoTheBook").Tables[0];
Hashtable htDataPackages = this.OrderEx.GetIntoRegisterAndIntoBottom();
if (dt.Rows.Count == 0 && htDataPackages.Count > 0)
{ IsUpdateSaveed = true; }
else if (Convert.ToInt32(dt.Rows[0]["Pak_IntoTheArchive"]) != Convert.ToInt32(htDataPackages["IntoBottom"].ToString()) || Convert.ToInt32(dt.Rows[0]["Pak_IntoTheBook"]) != Convert.ToInt32(htDataPackages["IntoRegister"].ToString()))
{ IsUpdateSaveed = true; }
}
catch
{ }
break;
}
#endregion
#region 商品与服务
if (!IsUpdateSaveed)
{
dtRow0 = dt1.Select("Pgm_GiveType = '0'");
tbl0 = this.OrderProductEx.GetListViewData();
if (dtRow0.Length != tbl0.Rows.Count)
{ IsUpdateSaveed = true; }
else if (dtRow0.Length > 0 && tbl0.Rows.Count > 0)
{
for (int j = 0; j < tbl0.Rows.Count; j++)
{
if (string.IsNullOrEmpty(tbl0.Rows[j]["PgmID"].ToString().Trim()))
{
IsUpdateSaveed = true;
break;
}
}
if (!IsUpdateSaveed)
{
for (int i = 0; i < dtRow0.Length; i++)
{
DataRow[] dtRow = tbl0.Select("PgmID = '" + dtRow0[i]["ID"].ToString().Trim() + "'");
if (dtRow0.Length <= 0)
{ IsUpdateSaveed = true; }
else
{
if (Convert.ToInt32(dtRow[0]["商品P数"]) != Convert.ToInt32(dtRow0[i]["Prod_Batch"]) || Convert.ToInt32(dtRow[0]["商品数量"]) != Convert.ToInt32(dtRow0[i]["Pgm_Quantity"]))
{
IsUpdateSaveed = true;
break;
}
}
}
}
}
}
if (!IsUpdateSaveed)
{
dtRow1 = dt1.Select("Pgm_GiveType = '1'");
tbl1 = this.OrderServiceEx.GetListViewData();
if (dtRow1.Length != tbl1.Rows.Count)
{ IsUpdateSaveed = true; }
else if (dtRow1.Length > 0 && tbl1.Rows.Count > 0)
{
for (int j = 0; j < tbl1.Rows.Count; j++)
{
if (string.IsNullOrEmpty(tbl1.Rows[j]["PgmID"].ToString().Trim()))
{
IsUpdateSaveed = true;
break;
}
}
if (!IsUpdateSaveed)
{
for (int i = 0; i < dtRow1.Length; i++)
{
DataRow[] dtRow = tbl1.Select("PgmID = '" + dtRow1[i]["ID"].ToString().Trim() + "'");
if (dtRow1.Length <= 0)
{ IsUpdateSaveed = true; }
else
{
if (Convert.ToInt32(dtRow[0]["服务数量"]) != Convert.ToInt32(dtRow1[i]["Pgm_Quantity"]))
{
IsUpdateSaveed = true;
break;
}
}
}
}
}
}
#endregion
#region 景点与拍摄次数
if (!IsUpdateSaveed)
{
switch (this.OrdType)
{
case EnumPublic.OrderType.婚纱订单:
case EnumPublic.OrderType.写真订单:
dtRow2 = dt0.Select("Pgm_GiveType = '2'");
tbl2 = this.OrderSightsEx.GetListViewData();
break;
case EnumPublic.OrderType.儿童订单:
dtRow2 = dt0.Select("Pgm_GiveType = '3'");
tbl2 = this.OrderStagesEx.GetListViewData();
break;
}
if (dtRow2.Length != tbl2.Rows.Count)
{ IsUpdateSaveed = true; }
else if (dtRow2.Length > 0 && tbl2.Rows.Count > 0)
{
for (int j = 0; j < tbl2.Rows.Count; j++)
{
if (string.IsNullOrEmpty(tbl2.Rows[j]["PgmID"].ToString().Trim()))
{
IsUpdateSaveed = true;
break;
}
}
if (!IsUpdateSaveed)
{
for (int i = 0; i < dtRow2.Length; i++)
{
DataRow[] dtRow = tbl2.Select("PgmID = '" + dtRow2[i]["ID"].ToString().Trim() + "'");
if (dtRow2.Length <= 0)
{ IsUpdateSaveed = true; }
else
{
if (dtRow[0]["拍摄级别"].ToString().Trim() != dtRow2[i]["Sc_ClassName"].ToString().Trim() || Convert.ToInt32(dtRow[0]["服装套数"]) != Convert.ToInt32(dtRow2[i]["Pgm_Quantity"]))
{
IsUpdateSaveed = true;
break;
}
if (!IsUpdateSaveed)
{
switch (this.OrdType)
{
case EnumPublic.OrderType.儿童订单:
if (Convert.ToInt32(dtRow[0]["入册"]) != Convert.ToInt32(dtRow2[i]["Pgm_IntoRegisterQuantity"]) || Convert.ToInt32(dtRow[0]["入底"]) != Convert.ToInt32(dtRow2[i]["Pgm_IntoBottomQuantity"]) || Convert.ToInt32(dtRow[0]["服装套数"]) != Convert.ToInt32(dtRow2[i]["Pgm_Quantity"]))
{
IsUpdateSaveed = true;
break;
}
break;
}
}
}
}
}
}
}
#endregion
break;
}
}
}
return IsUpdateSaveed;
}
///
/// 保存意向
///
///
///
void btnSaveIntent_Click(object sender, EventArgs e)
{
SaveOrderData("0");
}
///
/// 保存意向订单和真实订单数据
///
/// 0意向订单,1开单
void SaveOrderData(string saveClass)
{
Api_ErpOrderModel apiErpModel = new Api_ErpOrderModel()
{
OrderID = modelId,
strTime = SDateTime.Now,
strUserName = StrUserName,
dividedShop = strInfoID,
strUserID = strUserID,
User_IP = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.User_IP,
strMskMarriage = this.mskMarriage.StrValue,
bChkCheckBox = this.chkMarriage.Checked,
chkTransactmemberCard = this.chkTransactmemberCard.Checked,
StrSaveClass = saveClass,
strStyle = this.GetStyle(),
StrClientSource = this.GetClientSource(),
dec_OrderDiscounts = this.dec_OrderDiscounts,
strOldTaoXiName=this.strOldTaoXiName,
strOldTaoXiCode = this.strOldTaoXiCode,
strOldTaoXiPrice = this.strOldTaoXiPrice,
UploadPath = this._UploadPath,
CommissionRatio = this.strPersonData,
strOrderPerson = txtOrderPerson.Tag == null ? "" : txtOrderPerson.Tag.ToString(),
strOrderPersonName = txtOrderPerson.Tag == null ? "" : txtOrderPerson.Text.ToString(),
ComeSingleLotNumber = this.ComeSingleLotNumber,
StrNewOrderNumber = (modelId > 0 ? this.StrNumber : null),
OrderGroupNumber = this.OrderGroupNumber,
customerData = new List(),
OrderSightData = new List(),
OrderServiceData = new List(),
OrderProductData = new List(),
modelFriends = new Model.Model_ErpCustomer(),
modelViceCard = new Model.Model_ErpMemberCardViceCard(),
IsMagess = true
};
if (this.modelFriends != null)
{
apiErpModel.friend_CustomerNumber = this.modelFriends.Cus_CustomerNumber;
}
else
{
apiErpModel.friend_CustomerNumber = "";
}
apiErpModel.orderType = this.OrdType;
///会员副卡
apiErpModel.modelViceCard = this.modelViceCard;
if (apiErpModel.modelViceCard != null)
{
if (apiErpModel.modelViceCard.Mvc_CreateDatetime == new DateTime())
{
apiErpModel.modelViceCard.Mvc_CreateDatetime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
}
if (apiErpModel.modelViceCard.Mvc_UpdateDateTime == new DateTime())
{
apiErpModel.modelViceCard.Mvc_UpdateDateTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
}
}
//朋友介绍
apiErpModel.modelFriends = this.modelFriends;
if (apiErpModel.modelFriends != null)
{
if (apiErpModel.modelFriends.Cus_CreateDateTime == new DateTime())
{
apiErpModel.modelFriends.Cus_CreateDateTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
}
if (apiErpModel.modelFriends.Cus_UpdateDateTime == new DateTime())
{
apiErpModel.modelFriends.Cus_UpdateDateTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
}
}
string ChildCilentRelation = "";
string MainCilentRelation = "";
foreach (Control control in this.flowPanel1.Controls)
{
///成人客户信息
if (control is SetCustomControls.OrderClientParentsControlsEx)
{
SetCustomControls.OrderClientParentsControlsEx tmp = (SetCustomControls.OrderClientParentsControlsEx)control;
tmp.GetClientValueData(apiErpModel, ref MainCilentRelation);
}
///儿童客户信息
if (control is SetCustomControls.OrderClientChildrenControlsEx)
{
SetCustomControls.OrderClientChildrenControlsEx tmp = (SetCustomControls.OrderClientChildrenControlsEx)control;
tmp.GetClientValueData(apiErpModel, ref ChildCilentRelation);
}
}
if (this.OrderEx != null)
{
///获取订单数据
this.OrderEx.BindApiData(apiErpModel);
}
if( this.ServiceOrderEx!=null)
{
this.ServiceOrderEx.BindApiData(apiErpModel);
}
///获取拍摄场景数据
switch (this.OrdType)
{
case EnumPublic.OrderType.婚纱订单:
case EnumPublic.OrderType.写真订单:
if (this.OrderSightsEx != null)
{
this.OrderSightsEx.GetOrderSightsValueData(apiErpModel);
}
break;
case EnumPublic.OrderType.儿童订单:
if (this.OrderStagesEx != null)
{
this.OrderStagesEx.GetOrderStagesValueData(apiErpModel);
}
break;
}
///服务的数据信息
if (this.OrderServiceEx != null)
{
this.OrderServiceEx.GetOrderServiceValueData(apiErpModel);
}
if (this.OrderProductEx != null)
{
this.OrderProductEx.GetOrderProductValueData(apiErpModel);
}
int indx = 0;
bool bSelect = false;
LYFZ.BLL.BLL_ErpOrder erpOrder = new BLL.BLL_ErpOrder();
// string json = Json.JsonTool.ObjectToJson(apiErpModel);
数据检查队列:
LYFZ.Command.Result result = erpOrder.SaveErpOrderDataByCheck(apiErpModel, ref indx, ref bSelect);
if (!result.Status)
{
if(result.StatusMsg=="手机号码重复,请核实客户数据!")
{
MessageBoxCustom.Show(result.StatusMsg);
return;
}
LYFZ.Command.Result resultMsg = ((LYFZ.Command.Result)result);
if (resultMsg.Data == Command.EnumReturnMsg.ReturnMsg)
{
MessageBoxCustom.Show(resultMsg.StatusMsg);
return;
}
else if (resultMsg.Data == Command.EnumReturnMsg.SelectMsg)
{
if (MessageBoxCustom.Show(resultMsg.StatusMsg, "温馨提示",
MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
{
return;
}
else
{
bSelect = true;
goto 数据检查队列;
}
}
else if (resultMsg.Data == Command.EnumReturnMsg.CostAuthorization)
{
if (MessageBoxCustom.Show(resultMsg.StatusMsg, "温馨提示",
MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
{
LYFZ.Software.MainBusiness.DoorCityProcess.SuperSmallForm.AuthorizeLoginSuperSmallForm frm = new SuperSmallForm.AuthorizeLoginSuperSmallForm(null, CustomAttributes.OperatingAuthority.ErrorPrivilegeValue, 1);
frm.ShowDialog();
if (!frm.IsSaveed)
{
return;
}
else
{
decimal Ord_SeriesPrice = 0;
decimal.TryParse(apiErpModel.strTaoXiPrice, out Ord_SeriesPrice);
decimal Old_PackagesAmount = apiErpModel.ProductAmount();
Old_PackagesAmount += apiErpModel.ServiceAmount();
if (apiErpModel.orderType == EnumPublic.OrderType.儿童订单)
{
Old_PackagesAmount += apiErpModel.SightOrStageAmount();
}
else if (apiErpModel.orderType != EnumPublic.OrderType.婚庆订单)
{
Old_PackagesAmount += apiErpModel.SightOrStageAmount();
}
if (Ord_SeriesPrice < (Old_PackagesAmount * frm.CurrentAuthorizeUserRights.GetOrderDiscounts(Convert.ToInt32(this.OrdType))))
{
frm.SetAuthorizationResult(String.Format("授权失败,授权人成本管控权限不够"));
MessageBoxCustom.Show("授权帐号:" + frm.StrUserAccount + ",授权后的套系价格低于订单总成本,无法保存!"); return; }
else
{
frm.SetAuthorizationResult();
bSelect = true;
goto 数据检查队列;
}
}
}
else
{
return;
}
}
else
{
MessageBoxCustom.Show(resultMsg.StatusMsg);
return;
}
}
else
{
//string strOrderPrefix = LYFZ.BLL.Common.BLL_Com_Data.GetOrderCustomPrefix(apiErpModel.orderType);
//if (apiErpModel.OrderID == 0)
//{
// if (apiErpModel.bIsShowSinceOrderNumber)
// {
// apiErpModel.SinceOrderNumber
// }
//}
bool isAddOrder = false;
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
backgroundWorker.ReportProgress(0, "正在提交数据... ");
result = erpOrder.SaveErpOrderData(apiErpModel, ref isAddOrder);
});
if (result.Status)
{
object obj;
try
{
obj = ((LYFZ.Command.Result