using System;
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.Dresses
{
public partial class DressEnteredManagedFormMain : LYFZ.Software.UI.Dresses.DressEnteredManagedFormMain
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
LYFZ.BLL.BLL_ErpDressFrom dfbll = new BLL.BLL_ErpDressFrom();
public DressEnteredManagedFormMain()
{
this.Load += DressEnteredManagedFormMain_Load;
this.Shown += DressEnteredManagedFormMain_Shown;
this.chkUpperRack.Click += chkUpperRack_Click;
this.chkDownRack.Click += chkDownRack_Click;
this.btnQuery.Click += btnQuery_Click;
this.btnAdded.Click += btnAdded_Click;
this.btnUpdata.Click += btnUpdata_Click;
this.btnDeleted.Click += btnDeleted_Click;
this.btnUseRecord.Click += btnUseRecord_Click;
this.btnExport.Click += btnExport_Click;
this.btnClose.Click += btnClose_Click;
this.listViewData_Dress.MouseDoubleClick += listViewData_Dress_MouseDoubleClick;
this.Resize += DressEnteredManagedFormMain_Resize;
this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
this.listViewData_Dress.MouseClick += ListViewData_Dress_MouseClick;
}
private void ListViewData_Dress_MouseClick(object sender, MouseEventArgs e)
{
if(this.listViewData_Dress.SelectedItems.Count>0&& e.Location.X>0&& e.Location.X< this.listViewData_Dress.Columns[0].Width&& this.listViewData_Dress.SelectedItems[0].Bounds.Y< e.Location.Y &&
this.listViewData_Dress.SelectedItems[0].Bounds.Y+ this.listViewData_Dress.SelectedItems[0].Bounds.Height > e.Location.Y)
{
if(this.listViewData_Dress.SelectedItems.Count>0)
{
LvItemImageModel model = this.listViewData_Dress.SelectedItems[0].Tag as LvItemImageModel;
if (!model.bImageLoad)
{
string[] StrArray = model.ImagePath.Split('|');//dt.Rows[i]["Dsfm_DressPhotoNames"].ToString().Trim().Split('|');
model.bImageLoad = true;
if (!this.mlistImage.Images.Keys.Contains(model.Text))
{ //dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim()
string loadMessage = "";
Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDressImage_Small(StrArray[0].Trim(), ref loadMessage);
model.ImageMessage = loadMessage;
if (loadMessage != "加载成功")
{
model.bLoadStatus = false;
//MessageBoxCustom.Show(model.ImageMessage, "提示消息", MessageBoxButtons.OK, null, false, 1);
}
else
{
model.bLoadStatus = true;
this.mlistImage.Images.Add(model.Text, img);
this.listViewData_Dress.SelectedItems[0].ImageKey = model.Text;
}
exToolTip1.RemoveAll();
//tempModel = model;
exToolTip1.SetToolTip(listViewData_Dress, model.ImageMessage);
//timer.Enabled = true;
}
}
else
{
exToolTip1.RemoveAll();
//timer.Enabled = true;
//tempModel = model;
exToolTip1.SetToolTip(listViewData_Dress, model.ImageMessage);
//MessageBoxCustom.Show(model.ImageMessage, "提示消息", MessageBoxButtons.OK, null, false, 1);
}
}
}
else
{
exToolTip1.SetToolTip(listViewData_Dress, "");
}
}
///
/// 相片集合
///
ImageList mlistImage = new ImageList();
///
/// 窗体加载事件
///
///
///
void DressEnteredManagedFormMain_Load(object sender, EventArgs e)
{
this.listViewData_Dress.View = View.Details;
this.listViewData_Dress.GridLines = true;
string[] StrColumns = "礼服编号,礼服名称,摆放区域,礼服品牌,礼服尺寸,成本价格,出租价格,出售价格,礼服状态,出租次数,送洗次数,出售状态,购买日期,录入时间,礼服备注".Split(',');
for (int i = 0; i < StrColumns.Length; i++)
{
ColumnHeader ch = new ColumnHeader();
ch.Text = StrColumns[i].Trim();
ch.TextAlign = HorizontalAlignment.Left;
switch (StrColumns[i].Trim())
{
case "礼服编号":
ch.Width = 150;
break;
case "礼服名称":
ch.Width = 150;
break;
case "摆放区域":
ch.Width = 120;
break;
case "礼服品牌":
ch.Width = 120;
break;
case "礼服尺寸":
ch.Width = 100;
break;
case "成本价格":
ch.Width = 90;
break;
case "出租价格":
ch.Width = 90;
break;
case "出售价格":
ch.Width = 90;
break;
case "礼服状态":
ch.Width = 120;
break;
case "出租次数":
ch.Width = 80;
break;
case "送洗次数":
ch.Width = 80;
break;
case "出售状态":
ch.Width = 80;
break;
case "购买日期":
ch.Width = 90;
break;
case "录入时间":
ch.Width = 110;
break;
case "礼服备注":
ch.Width = 300;
break;
}
switch (StrColumns[i].Trim())
{
case "成本价格":
case "出租价格":
case "出售价格":
ch.TextAlign = HorizontalAlignment.Right;
break;
case "礼服编号":
case "礼服名称":
case "摆放区域":
case "礼服品牌":
case "礼服尺寸":
case "礼服备注":
ch.TextAlign = HorizontalAlignment.Left;
break;
default:
ch.TextAlign = HorizontalAlignment.Center;
break;
}
this.listViewData_Dress.Columns.Add(ch);
}
this.mlistImage.ImageSize = new Size(60, 50);
this.mlistImage.ColorDepth = ColorDepth.Depth32Bit;
this.listViewData_Dress.SmallImageList = mlistImage;
this.btnDeleted.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressEntry, CustomAttributes.OperatingAuthority.Delete);
this.btnExport.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressEntry, CustomAttributes.OperatingAuthority.DataExport);
this.btnUseRecord.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressView, CustomAttributes.OperatingAuthority.SeeView);
}
///
/// 窗体加载事件
///
///
///
void DressEnteredManagedFormMain_Shown(object sender, EventArgs e)
{
bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.礼服管理);
if (!b)
{
this.Close();
return;
}
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEAJBGADDCBAHFFA", this.cmbtreevCategory, IsFirstNodeNull: true, IsFirstNodeName: "全部");
this.cmbtreevCategory.TextFindTag("全部");
this.PublicFunctionRows();
}
///
/// 上架
///
///
///
void chkUpperRack_Click(object sender, EventArgs e)
{
this.chkDownRack.Checked = false;
this.PublicFunctionRows();
}
///
/// 下架
///
///
///
void chkDownRack_Click(object sender, EventArgs e)
{
this.chkUpperRack.Checked = false;
this.PublicFunctionRows();
}
///
/// 查询
///
///
///
void btnQuery_Click(object sender, EventArgs e)
{
this.PublicFunctionRows();
}
///
/// 添加
///
///
///
void btnAdded_Click(object sender, EventArgs e)
{
#if DEBUG
LYFZ.Software.MainBusiness.NewDressSystem.frmAddDress addDress = new NewDressSystem.frmAddDress();
addDress.ShowDialog();
#else
LYFZ.Software.MainBusiness.Dresses.SetSmallForm.DressEnteredAddedSmallForm frm = new SetSmallForm.DressEnteredAddedSmallForm();
frm.ShowDialog();
if (frm.IsSaveed)
{ this.PublicFunctionRows(); }
#endif
}
///
/// 修改
///
///
///
void btnUpdata_Click(object sender, EventArgs e)
{
if (this.listViewData_Dress.Items.Count > 0 && this.listViewData_Dress.SelectedItems.Count > 0)
{
LYFZ.Software.MainBusiness.Dresses.SetSmallForm.DressEnteredUpdateSmallForm frm = new SetSmallForm.DressEnteredUpdateSmallForm();
frm.StrDressNumber = this.listViewData_Dress.SelectedItems[0].Tag.ToString().Trim();
frm.ShowDialog();
if (frm.IsSaveed)
{ this.PublicFunctionRows(); }
}
}
///
/// 删除
///
///
///
void btnDeleted_Click(object sender, EventArgs e)
{
if (this.listViewData_Dress.Items.Count > 0 && this.listViewData_Dress.SelectedItems.Count > 0)
{
string StrDressName = this.listViewData_Dress.SelectedItems[0].SubItems["礼服名称"].Text.Trim();
string StrDressCustomNumber = this.listViewData_Dress.SelectedItems[0].Text.ToString().Trim();
string StrDressNumber = this.listViewData_Dress.SelectedItems[0].Tag.ToString().Trim();
string StrDressDeletePhotoName = "";
if (MessageBoxCustom.Show("您选中的礼服名称:" + StrDressName + "\r\n礼服编号" + StrDressCustomNumber + "\r\n您确定要删除吗?", "", MessageBoxButtons.YesNo) == DialogResult.No)
{ return; }
List clist = new List();
DataTable dt = orbll.GetView_Custom("tb_ErpDressFrom", StrWhere: "Dsfm_DressNumber = '" + StrDressNumber + "'", ShowColumnName: "ID,Dsfm_DressPhotoNames").Tables[0];
if (dt.Rows.Count > 0)
{
if (!string.IsNullOrEmpty(dt.Rows[0]["Dsfm_DressPhotoNames"].ToString().Trim()))
{
string[] StrArrayPhotoNames = dt.Rows[0]["Dsfm_DressPhotoNames"].ToString().Trim().Split('|');
for (int i = 0; i < StrArrayPhotoNames.Length; i++)
{
if (!string.IsNullOrEmpty(StrArrayPhotoNames[i].Trim()))
{
DataTable tbl = orbll.GetView_Custom("tb_ErpDressFrom", StrWhere: "Dsfm_DressNumber != '" + StrDressNumber + "' And Dsfm_DressPhotoNames like '%" + StrArrayPhotoNames[i].Trim() + "%'", ShowColumnName: "ID").Tables[0];
if (tbl.Rows.Count <= 0)
{
//backgroundWorker.ReportProgress(0, "正在删除" + StrArrayPhotoNames[1].Trim() + "...");
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DeleteDressPhoto(StrArrayPhotoNames[i].Trim() + ".jpg", IsRecursion: true, DeleteDressType: 0);
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DeleteDressPhoto(StrArrayPhotoNames[i].Trim() + ".jpg", IsRecursion: true, DeleteDressType: 1);
StrDressDeletePhotoName += StrArrayPhotoNames[i].Trim() + ",";
}
}
}
}
}
clist.Add(dfbll.GetDeleteCommandInfo("ID", "=", dt.Rows[0]["ID"].ToString().Trim()));
string StrContent = "删除礼服名称:" + StrDressName + ";礼服编号:" + StrDressNumber + ";礼服自定义编号:" + StrDressCustomNumber;
if (!string.IsNullOrEmpty(StrDressDeletePhotoName))
{ StrContent += ";删除的相片有:" + StrDressDeletePhotoName.TrimEnd(','); }
clist.Add(new BLL.BLL_ErpACVBSYS().GetAddCommandInfo(LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetModelLog(LYFZ.EnumPublic.SystemLogsType.删除礼服.ToString(), StrContent, StrContent, SDateTime.Now)));
if (clist.Count > 0)
{
if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
{ MessageBoxCustom.Show("删除成功!"); this.listViewData_Dress.Items.Remove(this.listViewData_Dress.SelectedItems[0]); }
else
{ MessageBoxCustom.Show("删除失败!"); }
}
}
}
///
/// 使用记录
///
///
///
void btnUseRecord_Click(object sender, EventArgs e)
{
if (this.listViewData_Dress.Items.Count > 0 && this.listViewData_Dress.SelectedItems.Count > 0)
{
LYFZ.Software.MainBusiness.Dresses.SetSmallForm.DressUseRecordSmallForm frm = new SetSmallForm.DressUseRecordSmallForm();
frm.StrDressNumber = this.listViewData_Dress.SelectedItems[0].Tag.ToString().Trim();
frm.Show();
}
}
///
/// 导出
///
///
///
void btnExport_Click(object sender, EventArgs e)
{
this.listViewData_Dress.ListViewToDataTable(StrFileName: "礼服详情");
}
///
/// 关闭
///
///
///
void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 列表双击修改礼服信息
///
///
///
void listViewData_Dress_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.btnUpdata_Click(this, null);
}
///
/// 窗体大小发生变化
///
///
///
void DressEnteredManagedFormMain_Resize(object sender, EventArgs e)
{
switch (this.panelExport.Location.Y)
{
case 0: this.flowLayoutPanel1.Height = 32; break;
case 32: this.flowLayoutPanel1.Height = 64; break;
}
}
///
/// 创建行
///
private void PublicFunctionRows()
{
this.CreateListViewGroup();
this.ucPagerEx1.PageCurrent = 1;
this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
this.ucPagerEx1.Bind();
}
///
/// 画分页
///
///
///
private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
{
this.listViewData_Dress.Items.Clear();
string StrWhere = "";
if (this.chkUpperRack.Checked)
{ StrWhere += "And Dsfm_IsEnabled = '1' "; }
else if (this.chkDownRack.Checked)
{ StrWhere += "And Dsfm_IsEnabled = '0' "; }
if (!string.IsNullOrEmpty(this.txtKeyWord.Text.Trim()))
{ StrWhere += "And (Dsfm_DressCustomNumber like '%" + this.txtKeyWord.Text.Trim() + "%' or Dsfm_DressName like '%" + this.txtKeyWord.Text.Trim() + "%') "; }
if (!string.IsNullOrEmpty(this.cmbtreevCategory.Text.Trim()) && this.cmbtreevCategory.Text.Trim() != "全部")
{ StrWhere += "And Dsfm_DressTypeCode = '" + this.cmbtreevCategory.Tag.ToString().Trim() + "' "; }
LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
pageData.TableName = "BView_DressManaged";
pageData.PageIndex = this.ucPagerEx1.PageCurrent;
pageData.PageSize = this.ucPagerEx1.PageSize;
pageData.QueryCondition = StrWhere.TrimStart('A', 'n', 'd');
pageData.OrderStr = "Dsfm_CreateDateTime";
pageData.OrderType = 1;
pageData.QueryFieldName = "Dsfm_DressNumber,Dsfm_DressCustomNumber,Dsfm_DressTypeCode,Dsfm_DressType,Dsfm_DressName,Dsfm_DressBrand,Dsfm_DressSize,Dsfm_CostPrice,Dsfm_RentPrice,Dsfm_SalePrice,Dsfm_IsEnabled,Dsfm_PlacedRegion,Dsfm_DressPhotoNames,Dsfm_DressBuyDate,Dsfm_DressRemark,Dsfm_CreateDateTime,Dsfm_RentCount,Dsfm_SendWashCount,Dsfm_SaleStatus";
DataTable dt = new DataTable();
this.listViewData_Dress.BeginUpdate();
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
{
dt = pageData.QueryDataTable().Tables[0];
try
{
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{
for (int i = 0; i < dt.Rows.Count; i++)
{
string[] StrArray = "".Split('|');//dt.Rows[i]["Dsfm_DressPhotoNames"].ToString().Trim().Split('|');
if (!this.mlistImage.Images.Keys.Contains(""))
{ //dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim()
Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDressImage_Small(StrArray[0].Trim());
this.mlistImage.Images.Add("defalut", img);
}
ListViewItem lvItem = new ListViewItem();
lvItem.Tag = new LvItemImageModel()
{
Text = dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim(),
bImageLoad = false,
bLoadStatus = false,
ImagePath = dt.Rows[i]["Dsfm_DressPhotoNames"].ToString().Trim(),
ImageMessage = ""
} ;
lvItem.ImageKey = "defalut";
lvItem.Text = dt.Rows[i]["Dsfm_DressCustomNumber"].ToString().Trim();
ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "礼服名称";
ListSubItem.Text = dt.Rows[i]["Dsfm_DressName"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "摆放区域";
ListSubItem.Text = dt.Rows[i]["Dsfm_PlacedRegion"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "礼服品牌";
ListSubItem.Text = dt.Rows[i]["Dsfm_DressBrand"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "礼服尺寸";
ListSubItem.Text = dt.Rows[i]["Dsfm_DressSize"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "成本价格";
ListSubItem.Text = dt.Rows[i]["Dsfm_CostPrice"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "出租价格";
ListSubItem.Text = dt.Rows[i]["Dsfm_RentPrice"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "出售价格";
ListSubItem.Text = dt.Rows[i]["Dsfm_SalePrice"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "礼服状态";
ListSubItem.Text = dt.Rows[i]["Dsfm_IsEnabled"].ToString().Trim() == "0" ? "下架" : "上架";
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "出租次数";
ListSubItem.Text = dt.Rows[i]["Dsfm_RentCount"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "送洗次数";
ListSubItem.Text = dt.Rows[i]["Dsfm_SendWashCount"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "出售状态";
ListSubItem.Text = Convert.ToInt32(dt.Rows[i]["Dsfm_SaleStatus"]) == 0 ? "" : "已售";
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "购买日期";
ListSubItem.Text = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Dsfm_DressBuyDate"]);
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "录入时间";
ListSubItem.Text = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Dsfm_CreateDateTime"], "yyyy-MM-dd HH:mm");
lvItem.SubItems.Add(ListSubItem);
ListSubItem = new ListViewItem.ListViewSubItem();
ListSubItem.Name = "礼服备注";
ListSubItem.Text = dt.Rows[i]["Dsfm_DressRemark"].ToString().Trim();
lvItem.SubItems.Add(ListSubItem);
if (this.listViewData_Dress.Groups.Count > 0)
{ this.listViewData_Dress.Groups[dt.Rows[i]["Dsfm_DressTypeCode"].ToString().Trim()].Items.Add(lvItem); }
this.listViewData_Dress.Items.Add(lvItem);
}
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData_Dress);
}));
}
catch
{ }
});
this.listViewData_Dress.EndUpdate();
try
{
this.ucPagerEx1.TbDataSource = dt;
}
catch { }
return pageData.TotalCount;
}
///
/// 创建默认分组
///
void CreateListViewGroup()
{
DataTable dtGroup = orbll.GetView_Custom("tb_ErpDressFrom Left Join tb_ErpSystemCategory on Dsfm_DressType = Sc_ClassCode", StrWhere: "", ShowColumnName: "Sc_ClassName,Dsfm_DressType", GroupBy: "Sc_ClassName,Dsfm_DressType").Tables[0];
if (dtGroup.Rows.Count > 0)
{
for (int i = 0; i < dtGroup.Rows.Count; i++)
{
if (this.listViewData_Dress.Groups[dtGroup.Rows[i]["Dsfm_DressType"].ToString().Trim()] == null)
{
ListViewGroup man_lvg = new ListViewGroup();
man_lvg.Name = dtGroup.Rows[i]["Dsfm_DressType"].ToString().Trim();
man_lvg.Header = dtGroup.Rows[i]["Sc_ClassName"].ToString().Trim();
man_lvg.HeaderAlignment = HorizontalAlignment.Left;
this.listViewData_Dress.Groups.Add(man_lvg);
}
}
if (!this.listViewData_Dress.ShowGroups)
{ this.listViewData_Dress.ShowGroups = true; }
}
}
}
class LvItemImageModel {
///
/// 内容
///
public string Text { get; set; }
public string ImagePath { get; set; }
///
/// 是否加载图片
///
public bool bImageLoad { get; set; }
///
/// 加载状态
///
public bool bLoadStatus { get; set; }
///
/// 图片加载信息
///
public string ImageMessage { get; set; }
public override string ToString()
{
return Text;
}
}
}