using LYFZ.ComponentLibrary;
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.InitialSet
{
public partial class PackagesGoodsSetFormMain : LYFZ.Software.UI.InitialSet.PackagesGoodsSetFormMain
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
LYFZ.BLL.BLL_ErpProduct ptbll = new BLL.BLL_ErpProduct();
LYFZ.BLL.BLL_ErpPackages pkbll = new BLL.BLL_ErpPackages();
LYFZ.BLL.BLL_ErpTheScenery tsbll = new BLL.BLL_ErpTheScenery();
LYFZ.BLL.BLL_ErpPackagesGiftMerchandise pgmbll = new BLL.BLL_ErpPackagesGiftMerchandise();
public PackagesGoodsSetFormMain(string StrType = "0")
{
if (!string.IsNullOrEmpty(StrType))
{ this.StrPackagesType = Convert.ToInt32(StrType); }
else
{ this.StrPackagesType = 0; }
this.Load += PackagesGoodsSetFormMain_Load;
this.Shown += PackagesGoodsSetFormMain_Shown;
this.cmbtreev_PackageName.ComboBoxTree_NodeMouseClick += cmbtreev_PackageName_ComboBoxTree_NodeMouseClick;
this.btnToolbox_Product.Click += btnToolbox_Product_Click;
this.btnToolbox_Service.Click += btnToolbox_Service_Click;
this.btnToolbox_Sights.Click += btnToolbox_Sights_Click;
this.btnDelete_Product.Click += btnDelete_Product_Click;
this.btnDelete_Service.Click += btnDelete_Service_Click;
this.btnDelete_Sights.Click += btnDelete_Sights_Click;
this.btnSaveed.Click += btnSaveed_Click;
this.btnCloseed.Click += btnCloseed_Click;
this.btnSet.Click += btnSet_Click;
this.btnUp.Click += btnUp_Click;
this.btnDown.Click += btnDown_Click;
this.TabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;
this.listViewData_Product.MouseDoubleClick += listViewData_Product_MouseDoubleClick;
this.listViewData_Service.MouseDoubleClick += listViewData_Service_MouseDoubleClick;
this.listViewData_Sights.MouseDoubleClick += listViewData_Sights_MouseDoubleClick;
this.listViewData_Stages.MouseDoubleClick += listViewData_Stages_MouseDoubleClick;
this.listViewData_Product.MouseDown += listViewData_Product_MouseDown;
this.listViewData_Service.MouseDown += listViewData_Service_MouseDown;
this.txtText.KeyPress += txtText_KeyPress;
this.txtText.Leave += txtText_Leave;
this.txtIntoRegister.KeyPress += txtIntoRegister_KeyPress;
this.txtIntoBottom.KeyPress += txtIntoBottom_KeyPress;
this.FormClosing += PackagesGoodsSetFormMain_FormClosing;
}
///
/// 套系大类类型
///
public int StrPackagesType;
///
/// 是否保存
///
public bool IsSaveed = false;
///
/// 套系设置是否有修改
///
private bool IsPackagesSet = false;
///
/// 存储产品略图集合
///
ImageList mlistImage = new ImageList();
///
/// true为首次运行
///
private bool IsFirstLoad = true;
///
/// 套系数据是否有变动过
///
private bool IsDataChange = false;
///
/// 窗体加载事件
///
///
///
void PackagesGoodsSetFormMain_Load(object sender, EventArgs e)
{
this.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
this.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
if (this.StrPackagesType == 1)
{
this.panelEx4.Visible = false;
this.Text = "礼包套系商品设置";
this.labelEx6.Text = "套系礼包商品";
this.labelEx8.Text = "套系礼包服务";
}
else
{ this.txtIntoBottom.WaterText = "-1表示全送"; }
}
///
/// 窗体加载事件
///
///
///
void PackagesGoodsSetFormMain_Shown(object sender, EventArgs e)
{
//获取绑定拍摄次数 获取绑定套系名称
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PackagesCategoryAndName(this.cmbtreev_PackageName, StrParentCode: Enum.GetName(typeof(LYFZ.EnumPublic.EnumPackagesType), StrPackagesType).ToString().Trim());
this.tabPage1.Parent = null;
this.tabPage2.Parent = null;
switch (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType())
{
case LYFZ.Software.MainBusiness.EnumPermissions.BusinessType.儿童版:
if (!LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsEnablePhotoEdition)
{
this.tabPage2.Parent = this.TabControl;
this.btnUp.Visible = true;
this.btnDown.Visible = true;
}
else
{
this.tabPage1.Parent = this.TabControl;
this.tabPage2.Parent = this.TabControl;
}
break;
case LYFZ.Software.MainBusiness.EnumPermissions.BusinessType.婚纱版:
this.tabPage1.Parent = this.TabControl;
break;
default:
this.tabPage1.Parent = this.TabControl;
this.tabPage2.Parent = this.TabControl;
break;
}
//权限设置
if (this.StrPackagesType == 0)
{
if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PackagesGoodsCompetence, CustomAttributes.OperatingAuthority.Add) || LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PackagesGoodsCompetence, CustomAttributes.OperatingAuthority.Update))
{ this.btnSaveed.Enabled = true; this.btnSet.Enabled = true; }
else
{ this.btnSaveed.Enabled = false; this.btnSet.Enabled = false; }
this.btnDelete_Product.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PackagesGoodsCompetence, CustomAttributes.OperatingAuthority.Delete);
}
else
{
if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PackagesSuperposedCompetence, CustomAttributes.OperatingAuthority.Add) || LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PackagesSuperposedCompetence, CustomAttributes.OperatingAuthority.Update))
{ this.btnSaveed.Enabled = true; this.btnSet.Enabled = true; }
else
{ this.btnSaveed.Enabled = false; this.btnSet.Enabled = false; }
this.btnDelete_Product.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.PackagesSuperposedCompetence, CustomAttributes.OperatingAuthority.Delete);
}
this.btnDelete_Service.Enabled = this.btnDelete_Product.Enabled;
this.btnDelete_Sights.Enabled = this.btnDelete_Product.Enabled;
#region 设置列表标题
#region 商品表标题
this.listViewData_Product.View = View.Details;
this.listViewData_Product.GridLines = true;
string[] StrColumns = "商品名称,数量,进货价格,销售单价".Split(',');
int SurplusCount = 90 + 85 + 85 + 23;
for (int i = 0; i < StrColumns.Length; i++)
{
ColumnHeader ch = new ColumnHeader();
ch.Text = StrColumns[i].Trim();
ch.TextAlign = HorizontalAlignment.Left;
if (i == 0)
{ ch.Width = this.listViewData_Product.Width - SurplusCount; }
else if (i == StrColumns.Length - 1)
{ ch.Width = 90; }
else
{ ch.Width = 85; }
switch (StrColumns[i].Trim())
{
case "进货价格":
case "销售单价":
ch.TextAlign = HorizontalAlignment.Right;
break;
default:
ch.TextAlign = HorizontalAlignment.Center;
break;
}
this.listViewData_Product.Columns.Add(ch);
}
this.mlistImage.ImageSize = new Size(25, 25);
this.mlistImage.ColorDepth = ColorDepth.Depth32Bit;
this.listViewData_Product.SmallImageList = mlistImage;
this.listViewData_Product.MultiSelect = true;
#endregion
#region 服务表标题
this.listViewData_Service.View = View.Details;
this.listViewData_Service.GridLines = true;
for (int i = 0; i < StrColumns.Length; i++)
{
ColumnHeader ch = new ColumnHeader();
ch.Text = StrColumns[i].Trim();
ch.TextAlign = HorizontalAlignment.Left;
if (i == 0)
{ ch.Width = this.listViewData_Service.Width - SurplusCount; }
else if (i == StrColumns.Length - 1)
{ ch.Width = 90; }
else
{ ch.Width = 85; }
switch (StrColumns[i].Trim())
{
case "进货价格":
case "销售单价":
ch.TextAlign = HorizontalAlignment.Right;
break;
default:
ch.TextAlign = HorizontalAlignment.Center;
break;
}
this.listViewData_Service.Columns.Add(ch);
}
this.listViewData_Service.SmallImageList = mlistImage;
this.listViewData_Service.MultiSelect = true;
#endregion
#region 景点表标题
this.listViewData_Sights.View = View.Details;
this.listViewData_Sights.GridLines = true;
ImageList imgList = new ImageList();
imgList.ImageSize = new Size(1, 25);
this.listViewData_Sights.SmallImageList = imgList;
StrColumns = "景点名称,服装套数,成本单价,销售单价".Split(',');
SurplusCount = 90 + 85 + 85 + 23;
for (int i = 0; i < StrColumns.Length; i++)
{
ColumnHeader ch = new ColumnHeader();
ch.Text = StrColumns[i].Trim();
ch.TextAlign = HorizontalAlignment.Left;
if (i == 0)
{ ch.Width = this.listViewData_Sights.Width - SurplusCount; }
else if (i == StrColumns.Length - 1)
{ ch.Width = 90; }
else
{ ch.Width = 85; }
switch (StrColumns[i].Trim())
{
case "成本单价":
case "销售单价":
ch.TextAlign = HorizontalAlignment.Right;
break;
default:
ch.TextAlign = HorizontalAlignment.Center;
break;
}
this.listViewData_Sights.Columns.Add(ch);
}
#endregion
#region 拍摄次数表标题
this.listViewData_Stages.View = View.Details;
this.listViewData_Stages.GridLines = true;
this.listViewData_Stages.SmallImageList = imgList;
StrColumns = "次数名称,入册,入底,服装套数".Split(',');
for (int i = 0; i < StrColumns.Length; i++)
{
ColumnHeader ch = new ColumnHeader();
ch.Text = StrColumns[i].Trim();
switch (StrColumns[i].Trim())
{
case "次数名称": ch.Width = this.listViewData_Stages.Width - 270 - 23; break;
case "入册": ch.Width = 90; break;
case "入底": ch.Width = 90; break;
case "服装套数": ch.Width = 90; break;
}
switch (StrColumns[i].Trim())
{
case "次数名称": ch.TextAlign = HorizontalAlignment.Left; break;
case "入册":
case "入底":
case "服装套数": ch.TextAlign = HorizontalAlignment.Center; break;
}
this.listViewData_Stages.Columns.Add(ch);
}
#endregion
#endregion
this.IsFirstLoad = false;
}
///
/// 套系名称选择设置
///
///
///
void cmbtreev_PackageName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.listViewData_Product.Items.Clear();
this.listViewData_Product.Groups.Clear();
this.listViewData_Service.Items.Clear();
this.listViewData_Service.Groups.Clear();
this.listViewData_Sights.Items.Clear();
this.listViewData_Stages.Items.Clear();
this.IsDataChange = false;
//获取套系名称资料
DataTable dt = orbll.GetView_Custom("tb_ErpPackages", StrWhere: "Pak_PackagesID='" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "'", ShowColumnName: "Pak_UnitPrice,Pak_IntoTheArchive,Pak_IntoTheBook").Tables[0];
if (dt.Rows.Count > 0)
{
this.lblPakUnitPrice.Text = "套系价格:" + dt.Rows[0]["Pak_UnitPrice"].ToString().Trim();
this.txtIntoRegister.Text = dt.Rows[0]["Pak_IntoTheBook"].ToString().Trim();
this.txtIntoBottom.Text = dt.Rows[0]["Pak_IntoTheArchive"].ToString().Trim();
#region 景点与次数
DataTable tblSights = orbll.GetView_Custom("tb_ErpPackagesGiftMerchandise Left Join tb_ErpTheScenery on tb_ErpTheScenery.ID = Pgm_ProductNumber", StrWhere: "Tsc_Name is not null And Pgm_PackagesCode = '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "' And Pgm_GiveType in (2,3)", ShowColumnName: "tb_ErpPackagesGiftMerchandise.ID,Pgm_GiveType,Pgm_PackagesCode,Pgm_ProductNumber,Pgm_Quantity,Tsc_Name,Tsc_CostPrice,Tsc_SalesPrice,Pgm_IntoRegisterQuantity,Pgm_IntoBottomQuantity").Tables[0];
for (int i = 0; i < tblSights.Rows.Count; i++)
{
ListViewItem lvItem = new ListViewItem();
lvItem.Tag = tblSights.Rows[i]["Pgm_ProductNumber"].ToString().Trim() + "|" + tblSights.Rows[i]["ID"].ToString().Trim();
lvItem.Text = tblSights.Rows[i]["Tsc_Name"].ToString().Trim();
if (tblSights.Rows[i]["Pgm_GiveType"].ToString().Trim() == "2")
{
ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "服装套数";
ListSubItem.Text = tblSights.Rows[i]["Pgm_Quantity"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "成本单价";
ListSubItem.Text = tblSights.Rows[i]["Tsc_CostPrice"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "销售单价";
ListSubItem.Text = tblSights.Rows[i]["Tsc_SalesPrice"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
if ((this.listViewData_Sights.Items.Count % 2) > 0)
{ lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
else
{ lvItem.BackColor = System.Drawing.Color.PowderBlue; }
this.listViewData_Sights.Items.Add(lvItem);
}
else if (tblSights.Rows[i]["Pgm_GiveType"].ToString().Trim() == "3")
{
ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "入册";
ListSubItem.Text = tblSights.Rows[i]["Pgm_IntoRegisterQuantity"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "入底";
ListSubItem.Text = tblSights.Rows[i]["Pgm_IntoBottomQuantity"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "服装套数";
ListSubItem.Text = tblSights.Rows[i]["Pgm_Quantity"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
if ((this.listViewData_Stages.Items.Count % 2) > 0)
{ lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
else
{ lvItem.BackColor = System.Drawing.Color.PowderBlue; }
ListViewGroup man_lvg = new ListViewGroup();
man_lvg.Tag = lvItem.Text;
man_lvg.Name = lvItem.Text;
man_lvg.Header = lvItem.Text;
man_lvg.HeaderAlignment = HorizontalAlignment.Left;
this.listViewData_Product.Groups.Add(man_lvg);
man_lvg = new ListViewGroup();
man_lvg.Tag = lvItem.Text;
man_lvg.Name = lvItem.Text;
man_lvg.Header = lvItem.Text;
man_lvg.HeaderAlignment = HorizontalAlignment.Left;
this.listViewData_Service.Groups.Add(man_lvg);
this.listViewData_Stages.Items.Add(lvItem);
}
}
#endregion
#region 商品与服务
if (this.tabPage2.Parent == null)
{
string StrTableName = "(select Prod_Class,Sc_ClassName,Pgm_GiveType,Pgm_PackagesCode from tb_ErpPackagesGiftMerchandise Left Join tb_ErpProduct on Prod_Number = Pgm_ProductNumber " +
"Left Join tb_ErpSystemCategory on Prod_Class = Sc_ClassCode Group by Prod_Class,Sc_ClassName,Pgm_GiveType,Pgm_PackagesCode ) as tb";
DataTable dtGroup = orbll.GetView_Custom(StrTableName, StrWhere: "Pgm_PackagesCode = '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "' And Pgm_GiveType in ('0','1')", ShowColumnName: "*").Tables[0];
ListViewGroup man_lvg = null;
for (int i = 0; i < dtGroup.Rows.Count; i++)
{
man_lvg = new ListViewGroup();
man_lvg.Tag = dtGroup.Rows[i]["Sc_ClassName"].ToString().Trim();
man_lvg.Name = dtGroup.Rows[i]["Prod_Class"].ToString().Trim();
man_lvg.Header = dtGroup.Rows[i]["Sc_ClassName"].ToString().Trim();
man_lvg.HeaderAlignment = HorizontalAlignment.Left;
if (dtGroup.Rows[i]["Pgm_GiveType"].ToString().Trim() == "0")
{ this.listViewData_Product.Groups.Add(man_lvg); }
else if (dtGroup.Rows[i]["Pgm_GiveType"].ToString().Trim() == "1")
{ this.listViewData_Service.Groups.Add(man_lvg); }
}
}
else
{
ListViewGroup man_lvg = new ListViewGroup();
man_lvg.Tag = "";
man_lvg.Name = "NotGroup";
man_lvg.Header = "未分组";
man_lvg.HeaderAlignment = HorizontalAlignment.Left;
this.listViewData_Product.Groups.Add(man_lvg);
man_lvg = new ListViewGroup();
man_lvg.Tag = "";
man_lvg.Name = "NotGroup";
man_lvg.Header = "未分组";
man_lvg.HeaderAlignment = HorizontalAlignment.Left;
this.listViewData_Service.Groups.Add(man_lvg);
}
DataTable tblProduct = orbll.GetView_Custom("tb_ErpPackagesGiftMerchandise Left Join tb_ErpProduct on Prod_Number = Pgm_ProductNumber", StrWhere: "Pgm_PackagesCode = '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "' And Pgm_GiveType in ('0','1')", ShowColumnName: "tb_ErpPackagesGiftMerchandise.ID,Pgm_GiveType,Pgm_PackagesCode,Pgm_Quantity,Prod_Number,Prod_Name,Prod_CostPrice,Prod_SalesPrice,Prod_Thumbnail,Prod_Class,Pgm_ProductGroupName").Tables[0];
for (int i = 0; i < tblProduct.Rows.Count; i++)
{
if (!this.mlistImage.Images.Keys.Contains(tblProduct.Rows[i]["Prod_Number"].ToString().Trim()))
{
Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetProductImage(tblProduct.Rows[i]["Prod_Thumbnail"].ToString().Trim());
this.mlistImage.Images.Add(tblProduct.Rows[i]["Prod_Number"].ToString().Trim(), img);
}
ListViewItem lvItem = new ListViewItem();
lvItem.Tag = tblProduct.Rows[i]["Prod_Number"].ToString().Trim() + "|" + tblProduct.Rows[i]["ID"].ToString().Trim();
lvItem.ImageKey = tblProduct.Rows[i]["Prod_Number"].ToString().Trim();
lvItem.Text = tblProduct.Rows[i]["Prod_Name"].ToString().Trim();
if (tblProduct.Rows[i]["Prod_Number"]==null||string.IsNullOrEmpty(tblProduct.Rows[i]["Prod_Number"].ToString()))
{
lvItem.Text = "此产品已在产品设置表中删除";
lvItem.ForeColor = Color.Red;
}
ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "数量";
ListSubItem.Text = tblProduct.Rows[i]["Pgm_Quantity"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "进货价格";
ListSubItem.Text = tblProduct.Rows[i]["Prod_CostPrice"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "销售单价";
ListSubItem.Text = tblProduct.Rows[i]["Prod_SalesPrice"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
if (tblProduct.Rows[i]["Pgm_GiveType"].ToString().Trim() == "0")
{
if (this.tabPage2.Parent == null)
{
if (this.listViewData_Product.Groups.Count > 0)
{ this.listViewData_Product.Groups[tblProduct.Rows[i]["Prod_Class"].ToString().Trim()].Items.Add(lvItem); }
}
else
{
if (!string.IsNullOrEmpty(tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()))
{
if (this.listViewData_Product.Groups[tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()] != null)
{ this.listViewData_Product.Groups[tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()].Items.Add(lvItem); }
else
{ this.listViewData_Product.Groups["NotGroup"].Items.Add(lvItem); }
}
else
{ this.listViewData_Product.Groups["NotGroup"].Items.Add(lvItem); }
}
this.listViewData_Product.Items.Add(lvItem);
}
else if (tblProduct.Rows[i]["Pgm_GiveType"].ToString().Trim() == "1")
{
if (this.tabPage2.Parent == null)
{
if (this.listViewData_Service.Groups[tblProduct.Rows[i]["Prod_Class"].ToString().Trim()] != null)
{ this.listViewData_Service.Groups[tblProduct.Rows[i]["Prod_Class"].ToString().Trim()].Items.Add(lvItem); }
}
else
{
if (!string.IsNullOrEmpty(tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()))
{
if (this.listViewData_Service.Groups.Count > 0 && this.listViewData_Service.Groups[tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()]!=null)
{ this.listViewData_Service.Groups[tblProduct.Rows[i]["Pgm_ProductGroupName"].ToString().Trim()].Items.Add(lvItem); }
else
{ this.listViewData_Service.Groups["NotGroup"].Items.Add(lvItem); }
}
else
{ this.listViewData_Service.Groups["NotGroup"].Items.Add(lvItem); }
}
this.listViewData_Service.Items.Add(lvItem);
}
}
this.ListViewDrawSingleOrDoubleRows(ListViewType.套系商品);
this.ListViewDrawSingleOrDoubleRows(ListViewType.套系服务);
#endregion
}
else
{
this.lblPakUnitPrice.Text = "套系价格:0";
MessageBoxCustom.Show(this.cmbtreev_PackageName.Text.ToString() + " 此类型无套系名称!请添加套系名称");
this.cmbtreev_PackageName.SetTextAndTag_ValueNull();
}
this.GetSeriesCostsPriceStatistics();
}
///
/// 商品工具箱_产品
///
///
///
void btnToolbox_Product_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.cmbtreev_PackageName.Text))
{ MessageBoxCustom.Show("请选择套系名称!"); return; }
LYFZ.Software.MainBusiness.DoorCityProcess.SetSmallForm.ToolboxListViewSamllForm frm = new DoorCityProcess.SetSmallForm.ToolboxListViewSamllForm();
frm.LoadType = "套系包含商品";
frm.ShowDialog();
if (frm.IsSaveed)
{
for (int i = 0; i < frm.mlist_SmallImage.Images.Keys.Count; i++)
{
if (!this.mlistImage.Images.Keys.Contains(frm.mlist_SmallImage.Images.Keys[i].Trim()))
{ this.mlistImage.Images.Add(frm.mlist_SmallImage.Images.Keys[i].Trim(), frm.mlist_SmallImage.Images[frm.mlist_SmallImage.Images.Keys[i].Trim()]); }
}
for (int i = 0; i < frm.mlist.Count; i++)
{
ListViewItem lvItem = new ListViewItem();
lvItem.Tag = frm.mlist[i].Prod_Number.Trim() + "|";
lvItem.ImageKey = frm.mlist[i].Prod_Number.Trim();
lvItem.Text = frm.mlist[i].Prod_Name.Trim();
ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "数量";
ListSubItem.Text = "1";
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "进货价格";
ListSubItem.Text = frm.mlist[i].Prod_CostPrice.ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "销售单价";
ListSubItem.Text = frm.mlist[i].Prod_SalesPrice.ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
//if (this.listViewData_Product.Groups.Count > 0)
{
if (this.tabPage2.Parent == null)
{
if (this.listViewData_Product.Groups[frm.mlist[i].Prod_Class] == null)
{
DataTable tbl = orbll.GetView_Custom("tb_ErpSystemCategory", StrWhere: "Sc_ClassCode = '" + frm.mlist[i].Prod_Class + "'", ShowColumnName: "Sc_ClassName").Tables[0];
ListViewGroup man_lvg = new ListViewGroup();
man_lvg.Name = frm.mlist[i].Prod_Class;
if (tbl.Rows.Count > 0)
{ man_lvg.Header = tbl.Rows[0]["Sc_ClassName"].ToString().Trim(); }
else
{ man_lvg.Header = "未分组"; }
man_lvg.HeaderAlignment = HorizontalAlignment.Left;
this.listViewData_Product.Groups.Add(man_lvg);
}
this.listViewData_Product.Groups[frm.mlist[i].Prod_Class].Items.Add(lvItem);
}
else
{
lvItem.Group = this.listViewData_Product.Groups["NotGroup"];
}
}
this.listViewData_Product.Items.Add(lvItem);
this.IsDataChange = true;
}
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Product);
}
}
///
/// 商品工具箱_服务
///
///
///
void btnToolbox_Service_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.cmbtreev_PackageName.Text))
{ MessageBoxCustom.Show("请选择套系名称!"); return; }
LYFZ.Software.MainBusiness.DoorCityProcess.SetSmallForm.ToolboxListViewSamllForm frm = new DoorCityProcess.SetSmallForm.ToolboxListViewSamllForm();
frm.LoadType = "婚庆服务";
frm.ShowDialog();
if (frm.IsSaveed)
{
for (int i = 0; i < frm.mlist_SmallImage.Images.Keys.Count; i++)
{
if (!this.mlistImage.Images.Keys.Contains(frm.mlist_SmallImage.Images.Keys[i].Trim()))
{ this.mlistImage.Images.Add(frm.mlist_SmallImage.Images.Keys[i].Trim(), frm.mlist_SmallImage.Images[frm.mlist_SmallImage.Images.Keys[i].Trim()]); }
}
for (int i = 0; i < frm.mlist.Count; i++)
{
ListViewItem lvItem = new ListViewItem();
lvItem.Tag = frm.mlist[i].Prod_Number.Trim() + "|";
lvItem.ImageKey = frm.mlist[i].Prod_Number.Trim();
lvItem.Text = frm.mlist[i].Prod_Name.Trim();
ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "数量";
ListSubItem.Text = "1";
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "进货价格";
ListSubItem.Text = frm.mlist[i].Prod_CostPrice.ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "销售单价";
ListSubItem.Text = frm.mlist[i].Prod_SalesPrice.ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
//if (this.listViewData_Service.Groups.Count > 0)
{
if (this.tabPage2.Parent == null)
{
if (this.listViewData_Service.Groups[frm.mlist[i].Prod_Class] == null)
{
DataTable tbl = orbll.GetView_Custom("tb_ErpSystemCategory", StrWhere: "Sc_ClassCode = '" + frm.mlist[i].Prod_Class + "'", ShowColumnName: "Sc_ClassName").Tables[0];
ListViewGroup man_lvg = new ListViewGroup();
man_lvg.Name = frm.mlist[i].Prod_Class;
if (tbl.Rows.Count > 0)
{ man_lvg.Header = tbl.Rows[0]["Sc_ClassName"].ToString().Trim(); }
else
{ man_lvg.Header = "未分组"; }
man_lvg.HeaderAlignment = HorizontalAlignment.Left;
this.listViewData_Service.Groups.Add(man_lvg);
}
this.listViewData_Service.Groups[frm.mlist[i].Prod_Class].Items.Add(lvItem);
}
else
{
lvItem.Group = this.listViewData_Service.Groups["NotGroup"];
}
}
this.listViewData_Service.Items.Add(lvItem);
this.IsDataChange = true;
}
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Service);
}
}
///
/// 景点、次数工具箱
///
///
///
void btnToolbox_Sights_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.cmbtreev_PackageName.Text))
{ MessageBoxCustom.Show("请选择套系名称!"); return; }
LYFZ.Software.MainBusiness.InitialSet.PackagesGoods.FrmTheScenery frm = new PackagesGoods.FrmTheScenery();
frm.StrPackagesType = this.StrPackagesType;
if (this.TabControl.SelectedTab.Name.Trim() == "tabPage1")
{
#region
frm.StrSightsType = "0";
frm.ShowDialog();
if (frm.IsSaveed)
{
for (int i = 0; i < frm.tbl_Select.Rows.Count; i++)
{
bool IsFind = false;
for (int j = 0; j < this.listViewData_Sights.Items.Count; j++)
{
if (this.listViewData_Sights.Items[j].Text.Trim() == frm.tbl_Select.Rows[i]["Tsc_Name"].ToString().Trim())
{ IsFind = true; break; }
}
if (!IsFind)
{
ListViewItem lvItem = new ListViewItem();
lvItem.Tag = frm.tbl_Select.Rows[i]["ID"].ToString().Trim() + "|";
lvItem.Text = frm.tbl_Select.Rows[i]["Tsc_Name"].ToString().Trim();
ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "服装套数";
ListSubItem.Text = "1";
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "成本单价";
ListSubItem.Text = frm.tbl_Select.Rows[i]["Tsc_CostPrice"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "销售单价";
ListSubItem.Text = frm.tbl_Select.Rows[i]["Tsc_SalesPrice"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
if ((this.listViewData_Sights.Items.Count % 2) > 0)
{ lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
else
{ lvItem.BackColor = System.Drawing.Color.PowderBlue; }
this.listViewData_Sights.Items.Add(lvItem);
this.IsDataChange = true;
}
}
}
#endregion
}
else if (this.TabControl.SelectedTab.Name.Trim() == "tabPage2")
{
#region
frm.StrSightsType = "1";
frm.ShowDialog();
if (frm.IsSaveed)
{
for (int i = 0; i < frm.tbl_Select.Rows.Count; i++)
{
bool IsFind = false;
for (int j = 0; j < this.listViewData_Stages.Items.Count; j++)
{
if (this.listViewData_Stages.Items[j].Text.Trim() == frm.tbl_Select.Rows[i]["Tsc_Name"].ToString().Trim())
{ IsFind = true; break; }
}
if (!IsFind)
{
ListViewItem lvItem = new ListViewItem();
lvItem.Tag = frm.tbl_Select.Rows[i]["ID"].ToString().Trim() + "|";
lvItem.Text = frm.tbl_Select.Rows[i]["Tsc_Name"].ToString().Trim();
ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "入册";
ListSubItem.Text = "0";
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "入底";
ListSubItem.Text = "0";
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "服装套数";
ListSubItem.Text = "1";
lvItem.SubItems.Add(ListSubItem);
if ((this.listViewData_Stages.Items.Count % 2) > 0)
{ lvItem.BackColor = System.Drawing.Color.PapayaWhip; }
else
{ lvItem.BackColor = System.Drawing.Color.PowderBlue; }
ListViewGroup man_lvg = new ListViewGroup();
man_lvg.Tag = lvItem.Text;
man_lvg.Name = lvItem.Text;
man_lvg.Header = lvItem.Text;
man_lvg.HeaderAlignment = HorizontalAlignment.Left;
this.listViewData_Product.Groups.Add(man_lvg);
man_lvg = new ListViewGroup();
man_lvg.Tag = lvItem.Text;
man_lvg.Name = lvItem.Text;
man_lvg.Header = lvItem.Text;
man_lvg.HeaderAlignment = HorizontalAlignment.Left;
this.listViewData_Service.Groups.Add(man_lvg);
this.listViewData_Stages.Items.Add(lvItem);
this.IsDataChange = true;
}
}
}
#endregion
}
}
///
/// 商品删除
///
///
///
void btnDelete_Product_Click(object sender, EventArgs e)
{
if (this.listViewData_Product.Items.Count > 0 && this.listViewData_Product.SelectedItems.Count > 0)
{
if (MessageBoxCustom.Show("你确定要移除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.listViewData_Product.Items.Remove(this.listViewData_Product.SelectedItems[0]);
this.ListViewDrawSingleOrDoubleRows(ListViewType.套系商品);
this.IsDataChange = true;
this.GetSeriesCostsPriceStatistics();
}
}
}
///
/// 服务删除
///
///
///
void btnDelete_Service_Click(object sender, EventArgs e)
{
if (this.listViewData_Service.Items.Count > 0 && this.listViewData_Service.SelectedItems.Count > 0)
{
if (MessageBoxCustom.Show("你确定要移除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.listViewData_Service.Items.Remove(this.listViewData_Service.SelectedItems[0]);
this.ListViewDrawSingleOrDoubleRows(ListViewType.套系服务);
this.IsDataChange = true;
this.GetSeriesCostsPriceStatistics();
}
}
}
///
/// 景点、次数删除
///
///
///
void btnDelete_Sights_Click(object sender, EventArgs e)
{
if (this.TabControl.SelectedTab.Name.Trim() == "tabPage1")
{
if (this.listViewData_Sights.Items.Count > 0 && this.listViewData_Sights.SelectedItems.Count > 0)
{
if (MessageBoxCustom.Show("你确定要移除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
List ListRemove = new List();
for (int i = 0; i < this.listViewData_Sights.SelectedItems.Count; i++)
{ ListRemove.Add(this.listViewData_Sights.SelectedItems[i]); }
for (int i = 0; i < ListRemove.Count; i++)
{ this.listViewData_Sights.Items.Remove(ListRemove[i]); }
this.ListViewDrawSingleOrDoubleRows(ListViewType.套系景点);
this.IsDataChange = true;
this.GetSeriesCostsPriceStatistics();
}
}
}
else if (this.TabControl.SelectedTab.Name.Trim() == "tabPage2")
{
if (this.listViewData_Stages.Items.Count > 0 && this.listViewData_Stages.SelectedItems.Count > 0)
{
if (MessageBoxCustom.Show("你确定要移除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
List ListRemove = new List();
for (int i = 0; i < this.listViewData_Stages.SelectedItems.Count; i++)
{
for (int j = 0; j < this.listViewData_Product.Items.Count; j++)
{
if (this.listViewData_Product.Items[j].Group.Header.Trim() == this.listViewData_Stages.SelectedItems[i].Text.Trim())
{
this.listViewData_Product.Items[j].Group = this.listViewData_Product.Groups["NotGroup"];
}
}
this.listViewData_Product.Groups.Remove(this.listViewData_Product.Groups[this.listViewData_Stages.SelectedItems[i].Text.Trim()]);
for (int j = 0; j < this.listViewData_Service.Items.Count; j++)
{
if (this.listViewData_Service.Items[j].Group.Header.Trim() == this.listViewData_Stages.SelectedItems[i].Text.Trim())
{
this.listViewData_Service.Items[j].Group = this.listViewData_Service.Groups["NotGroup"];
}
}
this.listViewData_Service.Groups.Remove(this.listViewData_Service.Groups[this.listViewData_Stages.SelectedItems[i].Text.Trim()]);
ListRemove.Add(this.listViewData_Stages.SelectedItems[i]);
}
for (int i = 0; i < ListRemove.Count; i++)
{ this.listViewData_Stages.Items.Remove(ListRemove[i]); }
this.ListViewDrawSingleOrDoubleRows(ListViewType.套系次数);
this.IsDataChange = true;
this.GetSeriesCostsPriceStatistics();
}
}
}
}
///
/// 保存
///
///
///
void btnSaveed_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.cmbtreev_PackageName.Text.Trim()))
{
if (!this.IsDataChange)
{ MessageBoxCustom.Show("没做任何修改,无须保存!"); return; }
DateTime StrTime = SDateTime.Now;
string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
string StrPackagesName = this.cmbtreev_PackageName.Text.Trim();
string StrPackagesClass = this.cmbtreev_PackageName.Tag.ToString().Trim();
List clist = new List();
DataTable tblPackage = orbll.GetView_Custom("tb_ErpPackages", StrWhere: "Pak_PackagesID = '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "'", ShowColumnName: "*").Tables[0];
if (tblPackage.Rows.Count <= 0)
{ MessageBoxCustom.Show("套系'" + this.cmbtreev_PackageName.Text.Trim() + "'不存在,可能已经被删除!"); return; }
LYFZ.Model.Model_ErpPackagesGiftMerchandise model = null;
DataTable tblProduct = orbll.GetView_Custom("tb_ErpPackagesGiftMerchandise", StrWhere: "Pgm_PackagesCode = '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "' And Pgm_GiveType in ('0','1')", ShowColumnName: "*").Tables[0];
#region 商品
for (int i = 0; i < this.listViewData_Product.Items.Count; i++)
{
string[] StrArray = this.listViewData_Product.Items[i].Tag.ToString().Trim().Split('|');
if (string.IsNullOrEmpty(this.listViewData_Product.Items[i].SubItems["数量"].Text.Trim()))
{ MessageBoxCustom.Show("商品'" + this.listViewData_Product.Items[i].Text + "'的数量不能为空!"); return; }
string strProductName = this.listViewData_Product.Items[i].Text.Trim();
int Quantity = Convert.ToInt32(this.listViewData_Product.Items[i].SubItems["数量"].Text);
if (!string.IsNullOrEmpty(StrArray[1].Trim()))
{
DataRow[] dtRow = tblProduct.Select("ID = '" + StrArray[1].Trim() + "'");
if (dtRow.Length <= 0)
{ MessageBoxCustom.Show("此套系赠送商品已被修改过,商品'" + strProductName + "'已被删除!"); return; }
model = pgmbll.DataRowToModel(dtRow[0]);
model.Pgm_Quantity = Quantity;
if (this.listViewData_Product.Items[i].Group.Tag != null)
{ model.Pgm_ProductGroupName = this.listViewData_Product.Items[i].Group.Tag.ToString().Trim(); }
model.Pgm_UpdateDateTime = StrTime;
model.Pgm_UpdateName = StrUserID;
clist.Add(pgmbll.GetUpdateCommandInfo(model));
tblProduct.Rows.Remove(dtRow[0]);
}
else
{
model = new Model.Model_ErpPackagesGiftMerchandise();
model.Pgm_GiveType = 0;
model.Pgm_ProductNumber = StrArray[0].Trim();
model.Pgm_ProductName = strProductName;
model.Pgm_Quantity = Quantity;
model.Pgm_StageNumber = "";
model.Pgm_StageName = "";
model.Pgm_PackagesNumber = tblPackage.Rows[0]["Pak_PackagesClass"].ToString().Trim();
model.Pgm_PackagesName = StrPackagesName;
model.Pgm_PackagesCode = StrPackagesClass;
if (this.listViewData_Product.Items[i].Group.Tag != null)
{ model.Pgm_ProductGroupName = this.listViewData_Product.Items[i].Group.Tag.ToString().Trim(); }
model.Pgm_CreateDateTime = StrTime;
model.Pgm_CreateName = StrUserID;
clist.Add(pgmbll.GetAddCommandInfo(model));
}
}
#endregion
#region 服务
for (int i = 0; i < this.listViewData_Service.Items.Count; i++)
{
string[] StrArray = this.listViewData_Service.Items[i].Tag.ToString().Trim().Split('|');
if (string.IsNullOrEmpty(this.listViewData_Service.Items[i].SubItems["数量"].Text.Trim()))
{ MessageBoxCustom.Show("服务'" + this.listViewData_Service.Items[i].Text + "'的数量不能为空!"); return; }
string strProductName = this.listViewData_Service.Items[i].Text.Trim();
int Quantity = Convert.ToInt32(this.listViewData_Service.Items[i].SubItems["数量"].Text);
if (!string.IsNullOrEmpty(StrArray[1].Trim()))
{
DataRow[] dtRow = tblProduct.Select("ID = '" + StrArray[1].Trim() + "'");
if (dtRow.Length <= 0)
{ MessageBoxCustom.Show("此套系赠送服务已被修改过,服务'" + strProductName + "'已被删除!"); return; }
model = pgmbll.DataRowToModel(dtRow[0]);
model.Pgm_Quantity = Quantity;
if (this.listViewData_Service.Items[i].Group.Tag != null)
{ model.Pgm_ProductGroupName = this.listViewData_Service.Items[i].Group.Tag.ToString().Trim(); }
model.Pgm_UpdateDateTime = StrTime;
model.Pgm_UpdateName = StrUserID;
clist.Add(pgmbll.GetUpdateCommandInfo(model));
tblProduct.Rows.Remove(dtRow[0]);
}
else
{
model = new Model.Model_ErpPackagesGiftMerchandise();
model.Pgm_GiveType = 1;
model.Pgm_ProductNumber = StrArray[0].Trim();
model.Pgm_ProductName = strProductName;
model.Pgm_Quantity = Quantity;
model.Pgm_StageNumber = "";
model.Pgm_StageName = "";
model.Pgm_PackagesNumber = tblPackage.Rows[0]["Pak_PackagesClass"].ToString().Trim();
model.Pgm_PackagesName = StrPackagesName;
model.Pgm_PackagesCode = StrPackagesClass;
if (this.listViewData_Service.Items[i].Group.Tag != null)
{ model.Pgm_ProductGroupName = this.listViewData_Service.Items[i].Group.Tag.ToString().Trim(); }
model.Pgm_CreateDateTime = StrTime;
model.Pgm_CreateName = StrUserID;
clist.Add(pgmbll.GetAddCommandInfo(model));
}
}
#endregion
for (int i = 0; i < tblProduct.Rows.Count; i++)
{ clist.Add(pgmbll.GetDeleteCommandInfo("ID", "=", tblProduct.Rows[i]["ID"])); }
#region 景点
if (this.TabControl.TabPages.ContainsKey("tabPage1"))
{
DataTable tblSights = orbll.GetView_Custom("tb_ErpPackagesGiftMerchandise", StrWhere: "Pgm_PackagesCode = '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "' And Pgm_GiveType = '2'", ShowColumnName: "*").Tables[0];
for (int i = 0; i < this.listViewData_Sights.Items.Count; i++)
{
string[] StrArray = this.listViewData_Sights.Items[i].Tag.ToString().Trim().Split('|');
if (string.IsNullOrEmpty(this.listViewData_Sights.Items[i].SubItems["服装套数"].Text.Trim()))
{ MessageBoxCustom.Show("景点'" + this.listViewData_Sights.Items[i].Text + "'的服装套数不能为空!"); return; }
string strProductName = this.listViewData_Sights.Items[i].Text.Trim();
int Quantity = Convert.ToInt32(this.listViewData_Sights.Items[i].SubItems["服装套数"].Text);
if (!string.IsNullOrEmpty(StrArray[1].Trim()))
{
DataRow[] dtRow = tblSights.Select("ID = '" + StrArray[1].Trim() + "'");
if (dtRow.Length <= 0)
{ MessageBoxCustom.Show("此套系赠送景点已被修改过,景点'" + strProductName + "'已被删除!"); return; }
model = pgmbll.DataRowToModel(dtRow[0]);
model.Pgm_IntoRegisterQuantity = 0;
model.Pgm_IntoBottomQuantity = 0;
model.Pgm_Quantity = Quantity;
model.Pgm_UpdateDateTime = StrTime;
model.Pgm_UpdateName = StrUserID;
clist.Add(pgmbll.GetUpdateCommandInfo(model));
tblSights.Rows.Remove(dtRow[0]);
}
else
{
model = new Model.Model_ErpPackagesGiftMerchandise();
model.Pgm_GiveType = 2;
model.Pgm_ProductNumber = StrArray[0].Trim();
model.Pgm_Quantity = Quantity;
model.Pgm_PackagesNumber = tblPackage.Rows[0]["Pak_PackagesClass"].ToString().Trim();
model.Pgm_ProductName = strProductName;
model.Pgm_PackagesName = StrPackagesName;
model.Pgm_StageNumber = "";
model.Pgm_StageName = "";
model.Pgm_IntoRegisterQuantity = 0;
model.Pgm_IntoBottomQuantity = 0;
model.Pgm_PackagesCode = StrPackagesClass;
model.Pgm_CreateDateTime = StrTime;
model.Pgm_CreateName = StrUserID;
clist.Add(pgmbll.GetAddCommandInfo(model));
}
}
for (int i = 0; i < tblSights.Rows.Count; i++)
{ clist.Add(pgmbll.GetDeleteCommandInfo("ID", "=", tblSights.Rows[i]["ID"])); }
}
#endregion
#region 次数
if (this.TabControl.TabPages.ContainsKey("tabPage2"))
{
DataTable tblStages = orbll.GetView_Custom("tb_ErpPackagesGiftMerchandise", StrWhere: "Pgm_PackagesCode = '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "' And Pgm_GiveType = '3'", ShowColumnName: "*").Tables[0];
for (int i = 0; i < this.listViewData_Stages.Items.Count; i++)
{
string[] StrArray = this.listViewData_Stages.Items[i].Tag.ToString().Trim().Split('|');
if (string.IsNullOrEmpty(this.listViewData_Stages.Items[i].SubItems["服装套数"].Text.Trim()))
{ MessageBoxCustom.Show("次数'" + this.listViewData_Stages.Items[i].Text + "'的服装套数不能为空!"); return; }
int IntoRegisterQuantity = 0;
if (!string.IsNullOrEmpty(this.listViewData_Stages.Items[i].SubItems["入册"].Text.Trim()))
{ IntoRegisterQuantity = Convert.ToInt32(this.listViewData_Stages.Items[i].SubItems["入册"].Text.Trim()); }
int IntoBottomQuantity = 0;
if (!string.IsNullOrEmpty(this.listViewData_Stages.Items[i].SubItems["入底"].Text.Trim()))
{ IntoBottomQuantity = Convert.ToInt32(this.listViewData_Stages.Items[i].SubItems["入底"].Text.Trim()); }
string strProductName = this.listViewData_Stages.Items[i].Text.Trim();
int Quantity = Convert.ToInt32(this.listViewData_Stages.Items[i].SubItems["服装套数"].Text);
if (!string.IsNullOrEmpty(StrArray[1].Trim()))
{
DataRow[] dtRow = tblStages.Select("ID = '" + StrArray[1].Trim() + "'");
if (dtRow.Length <= 0)
{ MessageBoxCustom.Show("此套系赠送次数已被修改过,次数'" + strProductName + "'已被删除!"); return; }
model = pgmbll.DataRowToModel(dtRow[0]);
model.Pgm_IntoRegisterQuantity = IntoRegisterQuantity;
model.Pgm_IntoBottomQuantity = IntoBottomQuantity;
model.Pgm_Quantity = Quantity;
model.Pgm_UpdateDateTime = StrTime;
model.Pgm_UpdateName = StrUserID;
clist.Add(pgmbll.GetUpdateCommandInfo(model));
tblStages.Rows.Remove(dtRow[0]);
}
else
{
model = new Model.Model_ErpPackagesGiftMerchandise();
model.Pgm_GiveType = 3;
model.Pgm_ProductNumber = StrArray[0].Trim();
model.Pgm_Quantity = Quantity;
model.Pgm_PackagesNumber = tblPackage.Rows[0]["Pak_PackagesClass"].ToString().Trim();
model.Pgm_ProductName = strProductName;
model.Pgm_PackagesName = StrPackagesName;
model.Pgm_StageNumber = "";
model.Pgm_StageName = "";
model.Pgm_IntoRegisterQuantity = IntoRegisterQuantity;
model.Pgm_IntoBottomQuantity = IntoBottomQuantity;
model.Pgm_PackagesCode = StrPackagesClass;
model.Pgm_CreateDateTime = StrTime;
model.Pgm_CreateName = StrUserID;
clist.Add(pgmbll.GetAddCommandInfo(model));
}
}
for (int i = 0; i < tblStages.Rows.Count; i++)
{ clist.Add(pgmbll.GetDeleteCommandInfo("ID", "=", tblStages.Rows[i]["ID"])); }
}
#endregion
int IntoRegisterQuantityPackage = 0;
if (!string.IsNullOrEmpty(this.txtIntoRegister.Text.Trim()))
{ IntoRegisterQuantityPackage = Convert.ToInt32(this.txtIntoRegister.Text.Trim()); }
int IntoBottomQuantityPackage = 0;
if (!string.IsNullOrEmpty(this.txtIntoBottom.Text.Trim()))
{ IntoBottomQuantityPackage = Convert.ToInt32(this.txtIntoBottom.Text.Trim()); }
LYFZ.Model.Model_ErpPackages modelPackages = pkbll.DataRowToModel(tblPackage.Select("Pak_PackagesID= '" + this.cmbtreev_PackageName.Tag.ToString().Trim() + "'")[0]);
modelPackages.Pak_IntoTheArchive = IntoBottomQuantityPackage;
modelPackages.Pak_IntoTheBook = IntoRegisterQuantityPackage;
modelPackages.Pak_UpdateDatetime = StrTime;
modelPackages.Pak_Update = StrUserID;
clist.Add(pkbll.GetUpdateCommandInfo(modelPackages));
if (clist.Count > 0)
{
if (MessageBoxCustom.Show("您确定要保存吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
{ return; }
if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
{
this.IsSaveed = true;
this.IsDataChange = false;
MessageBoxCustom.Show("保存成功!");
}
else
{ MessageBoxCustom.Show("保存失败!"); }
}
}
}
///
/// 关闭
///
///
///
void btnCloseed_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 设置
///
///
///
void btnSet_Click(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.InitialSet.FrmPackagesSet frm = new FrmPackagesSet();
frm.IsShowUcNavigationTool = false;
frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
frm.StrPackagesType = this.StrPackagesType;
frm.ShowDialog();
if (frm.IsSaveed)
{
this.listViewData_Product.Items.Clear();
this.listViewData_Service.Items.Clear();
this.listViewData_Sights.Items.Clear();
this.listViewData_Stages.Items.Clear();
this.cmbtreev_PackageName.SetTextAndTag_ValueNull();
this.lblCostPrice.Text = "0.00";
this.lblSalePrice.Text = "0.00";
this.IsPackagesSet = true;
this.IsDataChange = false;
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_PackagesCategoryAndName(this.cmbtreev_PackageName, StrParentCode: Enum.GetName(typeof(LYFZ.EnumPublic.EnumPackagesType), StrPackagesType).ToString().Trim());
}
}
///
/// 上移
///
///
///
void btnUp_Click(object sender, EventArgs e)
{
if (this.listViewData_Stages.Items.Count > 0 && this.listViewData_Stages.SelectedItems.Count > 0)
{
int selectionIdx = this.listViewData_Stages.SelectedIndices[0];
if (selectionIdx > 0)
{
ListViewItem lvItem = new ListViewItem();
ListViewItem.ListViewSubItem ListSubItem = null;
for (int i = 0; i < this.listViewData_Stages.Columns.Count; i++)
{
if (i == 0)
{
lvItem.ImageKey = this.listViewData_Stages.SelectedItems[0].ImageKey;
lvItem.Text = this.listViewData_Stages.SelectedItems[0].Text;
lvItem.Tag = this.listViewData_Stages.SelectedItems[0].Tag;
}
else
{
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = this.listViewData_Stages.Columns[i].Text.Trim();
ListSubItem.Text = this.listViewData_Stages.SelectedItems[0].SubItems[this.listViewData_Stages.Columns[i].Text.Trim()].Text.Trim();
lvItem.SubItems.Add(ListSubItem);
}
}
//ListViewItem lvItem = new ListViewItem();
//lvItem.Text = this.listViewData_Stages.SelectedItems[0].Text;
//lvItem.Tag = this.listViewData_Stages.SelectedItems[0].Tag;
//ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
//ListSubItem.Name = "服装套数";
//ListSubItem.Text = this.listViewData_Stages.SelectedItems[0].SubItems["服装套数"].Text.Trim();
//lvItem.SubItems.Add(ListSubItem);
this.listViewData_Stages.Items.Remove(this.listViewData_Stages.SelectedItems[0]);
this.listViewData_Stages.Items.Insert(selectionIdx - 1, lvItem);
this.listViewData_Stages.Items[selectionIdx - 1].Selected = true;
this.ListViewDrawSingleOrDoubleRows(ListViewType.套系次数);
this.listViewData_Stages.Select();
}
}
}
///
/// 下移
///
///
///
void btnDown_Click(object sender, EventArgs e)
{
if (this.listViewData_Stages.Items.Count > 0 && this.listViewData_Stages.SelectedItems.Count > 0)
{
int selectionIdx = this.listViewData_Stages.SelectedIndices[0];
if (selectionIdx < (this.listViewData_Stages.Items.Count - 1))
{
ListViewItem lvItem = new ListViewItem();
ListViewItem.ListViewSubItem ListSubItem = null;
for (int i = 0; i < this.listViewData_Stages.Columns.Count; i++)
{
if (i == 0)
{
lvItem.ImageKey = this.listViewData_Stages.SelectedItems[0].ImageKey;
lvItem.Text = this.listViewData_Stages.SelectedItems[0].Text;
lvItem.Tag = this.listViewData_Stages.SelectedItems[0].Tag;
}
else
{
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = this.listViewData_Stages.Columns[i].Text.Trim();
ListSubItem.Text = this.listViewData_Stages.SelectedItems[0].SubItems[this.listViewData_Stages.Columns[i].Text.Trim()].Text.Trim();
lvItem.SubItems.Add(ListSubItem);
}
}
//ListViewItem lvItem = new ListViewItem();
//lvItem.Text = this.listViewData_Stages.SelectedItems[0].Text;
//lvItem.Tag = this.listViewData_Stages.SelectedItems[0].Tag;
//ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
//ListSubItem.Name = "服装套数";
//ListSubItem.Text = this.listViewData_Stages.SelectedItems[0].SubItems["服装套数"].Text.Trim();
//lvItem.SubItems.Add(ListSubItem);
this.listViewData_Stages.Items.Remove(this.listViewData_Stages.SelectedItems[0]);
this.listViewData_Stages.Items.Insert(selectionIdx + 1, lvItem);
this.listViewData_Stages.Items[selectionIdx + 1].Selected = true;
this.ListViewDrawSingleOrDoubleRows(ListViewType.套系次数);
this.listViewData_Stages.Select();
}
}
}
///
/// 选择版本获取商品成本价,卖价
///
///
///
void TabControl_SelectedIndexChanged(object sender, EventArgs e)
{
if (!this.IsFirstLoad)
{
if (this.TabControl.SelectedTab != null)
{
if (this.TabControl.SelectedTab.Name.Trim() == "tabPage2")
{
this.btnDown.Visible = true;
this.btnUp.Visible = true;
}
else
{
this.btnDown.Visible = false;
this.btnUp.Visible = false;
}
this.GetSeriesCostsPriceStatistics();
}
}
}
///
/// 商品列表双击
///
///
///
void listViewData_Product_MouseDoubleClick(object sender, MouseEventArgs e)
{
ListViewHitTestInfo info = this.listViewData_Product.HitTest(e.X, e.Y);
if (!string.IsNullOrEmpty(info.SubItem.Name.Trim()))
{
Rectangle rect = info.SubItem.Bounds;
switch (info.SubItem.Name.Trim())
{
case "数量":
this.txtText.Location = new Point(rect.Location.X + this.listViewData_Product.Location.X + 3, rect.Location.Y + this.listViewData_Product.Location.Y + this.splitContainerEx1.Location.Y + 2);
this.txtText.Size = rect.Size;
this.txtText.Visible = true;
this.txtText.Tag = info.SubItem.Name.Trim() + "|Product";
this.txtText.Text = info.SubItem.Text.Trim();
this.txtText.Focus();
break;
}
}
}
///
/// 服务列表双击
///
///
///
void listViewData_Service_MouseDoubleClick(object sender, MouseEventArgs e)
{
ListViewHitTestInfo info = this.listViewData_Service.HitTest(e.X, e.Y);
if (!string.IsNullOrEmpty(info.SubItem.Name.Trim()))
{
Rectangle rect = info.SubItem.Bounds;
switch (info.SubItem.Name.Trim())
{
case "数量":
this.txtText.Location = new Point(this.splitContainerEx1.Panel1.Width + rect.Location.X + this.listViewData_Service.Location.X + 6, rect.Location.Y + this.listViewData_Service.Location.Y + this.splitContainerEx1.Location.Y + 2);
this.txtText.Size = rect.Size;
this.txtText.Visible = true;
this.txtText.Tag = info.SubItem.Name.Trim() + "|Service";
this.txtText.Text = info.SubItem.Text.Trim();
this.txtText.Focus();
break;
}
}
}
///
/// 景点列表双击
///
///
///
void listViewData_Sights_MouseDoubleClick(object sender, MouseEventArgs e)
{
ListViewHitTestInfo info = this.listViewData_Sights.HitTest(e.X, e.Y);
if (!string.IsNullOrEmpty(info.SubItem.Name.Trim()))
{
Rectangle rect = info.SubItem.Bounds;
switch (info.SubItem.Name.Trim())
{
case "服装套数":
this.txtText.Location = new Point(this.splitContainerEx1.Panel1.Width + rect.Location.X + this.listViewData_Sights.Location.X + 10, rect.Location.Y + this.listViewData_Sights.Location.Y + this.splitContainerEx1.Location.Y + this.splitContainerEx2.Panel1.Height + 39);
this.txtText.Size = rect.Size;
this.txtText.Visible = true;
this.txtText.Tag = info.SubItem.Name.Trim() + "|Sights";
this.txtText.Text = info.SubItem.Text.Trim();
this.txtText.Focus();
break;
}
}
}
///
/// 次数列表双击
///
///
///
void listViewData_Stages_MouseDoubleClick(object sender, MouseEventArgs e)
{
ListViewHitTestInfo info = this.listViewData_Stages.HitTest(e.X, e.Y);
if (!string.IsNullOrEmpty(info.SubItem.Name.Trim()))
{
Rectangle rect = info.SubItem.Bounds;
switch (info.SubItem.Name.Trim())
{
case "入册":
case "入底":
case "服装套数":
this.txtText.Location = new Point(this.splitContainerEx1.Panel1.Width + rect.Location.X + this.listViewData_Stages.Location.X + 10, rect.Location.Y + this.listViewData_Stages.Location.Y + this.splitContainerEx1.Location.Y + this.splitContainerEx2.Panel1.Height + 39);
this.txtText.Size = rect.Size;
this.txtText.Visible = true;
this.txtText.Tag = info.SubItem.Name.Trim() + "|Stages";
this.txtText.Text = info.SubItem.Text.Trim();
this.txtText.Focus();
break;
}
}
}
///
/// 商品右键
///
///
///
void listViewData_Product_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
LYFZ.ComponentLibrary.ContextMenuStripEx contextmenu = new ContextMenuStripEx();
contextmenu.Name = "Source";
contextmenu.ItemClicked += contextmenu_ItemClicked;
//弹出操作菜单
contextmenu.Items.Clear();
contextmenu.Show(MousePosition.X, MousePosition.Y);
if (this.listViewData_Product.SelectedItems.Count > 0)
{
ToolStripMenuItem item = null;
for (int i = 0; i < this.listViewData_Stages.Items.Count; i++)
{
item = new ToolStripMenuItem();
item.Text = this.listViewData_Stages.Items[i].Text.Trim();
item.Name = "Grouped_Product_" + i;
item.Tag = this.listViewData_Stages.Items[i].Text.Trim();
contextmenu.Items.Add(item);
}
item = new ToolStripMenuItem();
item.Text = "未分组";
item.Name = "Grouped_Product_NotGroup_";
item.Tag = "";
contextmenu.Items.Add(item);
if (this.listViewData_Product.SelectedItems.Count == 1)
{
ToolStripSeparator tools = new ToolStripSeparator();
contextmenu.Items.Add(tools);
item = new ToolStripMenuItem();
item.Text = "放大(" + this.listViewData_Product.SelectedItems[0].Text.Trim() + ")";
item.Name = "ZoomView_0";
item.Tag = this.listViewData_Product.SelectedItems[0].Tag.ToString().Trim();
contextmenu.Items.Add(item);
}
}
contextmenu.Show();
}
}
///
/// 服务右键
///
///
///
void listViewData_Service_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
LYFZ.ComponentLibrary.ContextMenuStripEx contextmenu = new ContextMenuStripEx();
contextmenu.Name = "Source";
contextmenu.ItemClicked += contextmenu_ItemClicked;
//弹出操作菜单
contextmenu.Items.Clear();
contextmenu.Show(MousePosition.X, MousePosition.Y);
if (this.listViewData_Service.SelectedItems.Count > 0)
{
ToolStripMenuItem item = null;
for (int i = 0; i < this.listViewData_Stages.Items.Count; i++)
{
item = new ToolStripMenuItem();
item.Text = this.listViewData_Stages.Items[i].Text.Trim();
item.Name = "Grouped_Service_" + i;
item.Tag = this.listViewData_Stages.Items[i].Text.Trim();
contextmenu.Items.Add(item);
}
item = new ToolStripMenuItem();
item.Text = "未分组";
item.Name = "Grouped_Service_NotGroup";
item.Tag = "";
contextmenu.Items.Add(item);
if (this.listViewData_Service.SelectedItems.Count == 1)
{
ToolStripSeparator tools = new ToolStripSeparator();
contextmenu.Items.Add(tools);
item = new ToolStripMenuItem();
item.Text = "放大(" + this.listViewData_Service.SelectedItems[0].Text.Trim() + ")";
item.Name = "ZoomView_0";
item.Tag = this.listViewData_Service.SelectedItems[0].Tag.ToString().Trim();
contextmenu.Items.Add(item);
}
}
contextmenu.Show();
}
}
///
/// 右键菜单选择事件
///
///
///
void contextmenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
ToolStripItem item = e.ClickedItem;
if (!string.IsNullOrEmpty(item.Text.Trim()))
{
string[] StrArrayName = item.Name.Trim().Split('_');
switch (StrArrayName[0].Trim())
{
case "ZoomView":
string[] StrArray = item.Tag.ToString().Trim().Split('|');
DataTable tbl = orbll.GetView_Custom("tb_ErpProduct", StrWhere: "Prod_Number = '" + StrArray[0].Trim() + "'", ShowColumnName: "Prod_Thumbnail").Tables[0];
if (tbl.Rows.Count > 0)
{
if (!string.IsNullOrEmpty(tbl.Rows[0]["Prod_Thumbnail"].ToString().Trim()))
{
LYFZ.Software.MainBusiness.InitialSet.Product.FrmProductPic frm = new InitialSet.Product.FrmProductPic();
frm.FrmImage = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetImage(LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.StringToByte(tbl.Rows[0]["Prod_Thumbnail"].ToString()));
frm.ShowDialog();
}
else
{ MessageBoxCustom.Show("产品未上传相片!"); return; }
}
break;
case "Grouped":
this.IsDataChange = true;
switch (StrArrayName[1].Trim())
{
case "Product":
for (int i = 0; i < this.listViewData_Product.SelectedItems.Count; i++)
{
switch (StrArrayName[2].Trim())
{
case "NotGroup":
this.listViewData_Product.SelectedItems[i].Group = this.listViewData_Product.Groups["NotGroup"];
break;
default:
this.listViewData_Product.SelectedItems[i].Group = this.listViewData_Product.Groups[item.Text.Trim()];
break;
}
}
break;
case "Service":
for (int i = 0; i < this.listViewData_Service.SelectedItems.Count; i++)
{
switch (StrArrayName[2].Trim())
{
case "NotGroup":
this.listViewData_Service.SelectedItems[i].Group = this.listViewData_Service.Groups["NotGroup"];
break;
default:
this.listViewData_Service.SelectedItems[i].Group = this.listViewData_Service.Groups[item.Text.Trim()];
break;
}
}
break;
}
break;
}
}
}
///
/// 文本框控件限制输入
///
///
///
void txtText_KeyPress(object sender, KeyPressEventArgs e)
{
string[] StrArray = this.txtText.Tag.ToString().Trim().Split('|');
bool IsFind = false;
switch (StrArray[0].Trim())
{
case "入册":
case "入底":
if (this.StrPackagesType == 0)
{
IsFind = true;
if (Convert.ToString(e.KeyChar) == "-")
{
if (this.txtText.BaseText.SelectedText.Trim() == this.txtText.Text.Trim())
{ this.txtText.Text = ""; }
if (this.txtText.Text.Trim().IndexOf('-') != -1)
{ e.Handled = true; }
if (this.txtText.Text.Trim().Length > 0)
{ e.Handled = true; }
}
else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
else
{
if (!string.IsNullOrEmpty(this.txtText.Text.Trim()))
{
char[] chr = this.txtText.Text.Trim().ToArray();
if (chr[0].ToString().Trim() == "-")
{
if (Char.IsNumber(e.KeyChar))
{
if (Convert.ToInt32(e.KeyChar.ToString().Trim()) != 1)
{ e.Handled = true; }
}
}
}
}
}
break;
}
if (!IsFind)
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
}
}
///
/// 文本框控件离开事件
///
///
///
void txtText_Leave(object sender, EventArgs e)
{
string[] StrArray = this.txtText.Tag.ToString().Trim().Split('|');
switch (StrArray[1].Trim())
{
case "Product":
if (this.listViewData_Product.SelectedItems[0].SubItems[StrArray[0].Trim()].Text.Trim() != this.txtText.Text.Trim())
{
this.listViewData_Product.SelectedItems[0].SubItems[StrArray[0].Trim()].Text = this.txtText.Text.Trim() == "" ? "1" : this.txtText.Text;
this.IsDataChange = true;
this.GetSeriesCostsPriceStatistics();
}
break;
case "Service":
if (this.listViewData_Service.SelectedItems[0].SubItems[StrArray[0].Trim()].Text.Trim() != this.txtText.Text.Trim())
{
this.listViewData_Service.SelectedItems[0].SubItems[StrArray[0].Trim()].Text = this.txtText.Text.Trim() == "" ? "1" : this.txtText.Text;
this.IsDataChange = true;
this.GetSeriesCostsPriceStatistics();
}
break;
case "Sights":
if (this.listViewData_Sights.SelectedItems[0].SubItems[StrArray[0].Trim()].Text.Trim() != this.txtText.Text.Trim())
{
this.listViewData_Sights.SelectedItems[0].SubItems[StrArray[0].Trim()].Text = this.txtText.Text.Trim() == "" ? "1" : this.txtText.Text;
this.IsDataChange = true;
this.GetSeriesCostsPriceStatistics();
}
break;
case "Stages":
if (this.listViewData_Stages.SelectedItems[0].SubItems[StrArray[0].Trim()].Text.Trim() != this.txtText.Text.Trim())
{
this.listViewData_Stages.SelectedItems[0].SubItems[StrArray[0].Trim()].Text = this.txtText.Text.Trim() == "" ? "1" : this.txtText.Text;
this.IsDataChange = true;
this.GetSeriesCostsPriceStatistics();
}
break;
}
this.txtText.Visible = false;
}
///
/// 入册
///
///
///
void txtIntoRegister_KeyPress(object sender, KeyPressEventArgs e)
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
if (!e.Handled)
{ this.IsDataChange = true; }
}
///
/// 入底
///
///
///
void txtIntoBottom_KeyPress(object sender, KeyPressEventArgs e)
{
if (this.StrPackagesType == 0)
{
if (Convert.ToString(e.KeyChar) == "-")
{
if (this.txtIntoBottom.BaseText.SelectedText.Trim() == this.txtIntoBottom.Text.Trim())
{ this.txtIntoBottom.Text = ""; }
if (this.txtIntoBottom.Text.Trim().IndexOf('-') != -1)
{ e.Handled = true; }
if (this.txtIntoBottom.Text.Trim().Length > 0)
{ e.Handled = true; }
}
else if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
else
{
if (!string.IsNullOrEmpty(this.txtIntoBottom.Text.Trim()))
{
char[] chr = this.txtIntoBottom.Text.Trim().ToArray();
if (chr[0].ToString().Trim() == "-")
{
if (Char.IsNumber(e.KeyChar))
{
if (Convert.ToInt32(e.KeyChar.ToString().Trim()) != 1)
{ e.Handled = true; }
}
}
}
}
}
else
{
if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
{ e.Handled = true; }
}
if (!e.Handled)
{ this.IsDataChange = true; }
}
///
/// 窗体关闭前
///
///
///
void PackagesGoodsSetFormMain_FormClosing(object sender, FormClosingEventArgs e)
{
if (!this.IsSaveed)
{
if (this.IsPackagesSet)
{ this.IsSaveed = this.IsPackagesSet; }
}
}
#region
///
/// 获取套系成本统计
///
void GetSeriesCostsPriceStatistics()
{
decimal CostPrice = 0;
decimal SalePrice = 0;
if (this.TabControl.SelectedTab.Name.Trim() == "tabPage1")
{
this.GetProductPrice(ref CostPrice, ref SalePrice);
this.GetServicePrice(ref CostPrice, ref SalePrice);
this.GetSightsPrice(ref CostPrice, ref SalePrice);
this.lblCostPrice.Text = Convert.ToDecimal(CostPrice).ToString("N2");
this.lblSalePrice.Text = Convert.ToDecimal(SalePrice).ToString("N2");
}
else
{
this.GetProductPrice(ref CostPrice, ref SalePrice);
this.GetServicePrice(ref CostPrice, ref SalePrice);
this.lblCostPrice.Text = Convert.ToDecimal(CostPrice).ToString("N2");
this.lblSalePrice.Text = Convert.ToDecimal(SalePrice).ToString("N2");
}
////儿童与婚纱区分版本
////版本判断
//switch (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetBusinessType())
//{
// case LYFZ.Software.MainBusiness.EnumPermissions.BusinessType.儿童版:
// this.GetProductPrice(ref CostPrice, ref SalePrice);
// this.GetServicePrice(ref CostPrice, ref SalePrice);
// this.lblCostPrice.Text = Convert.ToDecimal(CostPrice).ToString("N2");
// this.lblSalePrice.Text = Convert.ToDecimal(SalePrice).ToString("N2");
// break;
// default:
// this.GetProductPrice(ref CostPrice, ref SalePrice);
// this.GetServicePrice(ref CostPrice, ref SalePrice);
// this.GetSightsPrice(ref CostPrice, ref SalePrice);
// this.lblCostPrice.Text = Convert.ToDecimal(CostPrice).ToString("N2");
// this.lblSalePrice.Text = Convert.ToDecimal(SalePrice).ToString("N2");
// break;
//}
}
decimal ConvertToDecimal(object obj)
{
try
{
if (obj != null && !string.IsNullOrEmpty(obj.ToString()))
{
decimal outdec = 0.00m;
decimal.TryParse(obj.ToString().Trim(), out outdec);
return outdec;
}
else
{
return 0.00m;
}
}
catch {
return 0.00m;
}
}
///
/// 获取商品成本价
///
///
///
void GetProductPrice(ref decimal CostPrice, ref decimal SalesPrice)
{
for (int i = 0; i < this.listViewData_Product.Items.Count; i++)
{
CostPrice += ConvertToDecimal(this.listViewData_Product.Items[i].SubItems["数量"].Text.Trim()) * ConvertToDecimal(this.listViewData_Product.Items[i].SubItems["进货价格"].Text.Trim());
SalesPrice += ConvertToDecimal(this.listViewData_Product.Items[i].SubItems["数量"].Text.Trim()) * ConvertToDecimal(this.listViewData_Product.Items[i].SubItems["销售单价"].Text.Trim());
}
}
///
/// 获取服务成本价
///
///
///
void GetServicePrice(ref decimal CostPrice, ref decimal SalesPrice)
{
for (int i = 0; i < this.listViewData_Service.Items.Count; i++)
{
CostPrice += ConvertToDecimal(this.listViewData_Service.Items[i].SubItems["数量"].Text.Trim()) * ConvertToDecimal(this.listViewData_Service.Items[i].SubItems["进货价格"].Text.Trim());
SalesPrice += ConvertToDecimal(this.listViewData_Service.Items[i].SubItems["数量"].Text.Trim()) * ConvertToDecimal(this.listViewData_Service.Items[i].SubItems["销售单价"].Text.Trim());
}
}
///
/// 获取景点成本价
///
///
///
void GetSightsPrice(ref decimal CostPrice, ref decimal SalesPrice)
{
for (int i = 0; i < this.listViewData_Sights.Items.Count; i++)
{
CostPrice += ConvertToDecimal(this.listViewData_Sights.Items[i].SubItems["成本单价"].Text.Trim());
SalesPrice += ConvertToDecimal(this.listViewData_Sights.Items[i].SubItems["销售单价"].Text.Trim());
}
}
///
/// 绘制列表单双行
///
///
void ListViewDrawSingleOrDoubleRows(ListViewType ProcessType)
{
if (ProcessType == ListViewType.套系商品)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Product);
}
else if (ProcessType == ListViewType.套系服务)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Service);
}
else if (ProcessType == ListViewType.套系景点)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Sights);
}
else if (ProcessType == ListViewType.套系次数)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Stages);
}
}
#endregion
enum ListViewType
{
套系商品,
套系服务,
套系景点,
套系次数
}
}
}