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.CameraControlBook.SuperSmallForm
{
public partial class SelectDressSuperSmallForm : LYFZ.Software.UI.CameraControlBook.SuperSmallForm.SelectDressSuperSmallForm
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
public SelectDressSuperSmallForm()
{
this.Shown += SelectDressSuperSmallForm_Shown;
this.btnQuery.Click += btnQuery_Click;
this.txtQuery.KeyDown += txtQuery_KeyDown;
this.cmbtreevCategory.ComboBoxTree_NodeMouseClick += cmbtreevCategory_ComboBoxTree_NodeMouseClick;
this.btnSaveed.Click += btnSaveed_Click;
this.btnCancel.Click += btnCancel_Click;
this.dgvData.CellMouseDoubleClick += dgvData_CellMouseDoubleClick;
this.dgvData2.CellMouseDoubleClick += dgvData2_CellMouseDoubleClick;
}
public bool IsSaveed = false;
public string StrValue;
///
/// 窗体加载事件
///
///
///
void SelectDressSuperSmallForm_Shown(object sender, EventArgs e)
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEAJBGADDCBAHFFA", this.cmbtreevCategory, IsFirstNodeNull: true);
this.dgvData.DataColumns("礼服编号,礼服类别,礼服名称,礼服品牌,礼服尺寸,摆放区域,礼服说明");
this.dgvData2.DataColumns("礼服编号,礼服名称");
this.PublicFunctionRows();
this.PublicFunctionRows2();
}
///
/// 查询
///
///
///
void btnQuery_Click(object sender, EventArgs e)
{
this.PublicFunctionRows();
}
///
/// 回车查询
///
///
///
void txtQuery_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{ this.PublicFunctionRows(); }
}
///
/// 选择类别查询
///
///
///
void cmbtreevCategory_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.PublicFunctionRows();
}
///
/// 确定
///
///
///
void btnSaveed_Click(object sender, EventArgs e)
{
string strDataRows = "";
for (int i = 0; i < this.dgvData2.Rows.Count; i++)
{ strDataRows += this.dgvData2.Rows[i].Cells["礼服编号"].Value.ToString().Trim() + ","; }
this.StrValue = strDataRows.TrimEnd(',');
this.IsSaveed = true;
this.Close();
}
///
/// 双击选中
///
///
///
void dgvData_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
if (this.dgvData.Rows.Count > 0)
{
DataGridViewRow dgvr = new DataGridViewRow();
DataGridViewCell cell = null;
cell = new DataGridViewTextBoxCell();
cell.Value = this.dgvData.Rows[e.RowIndex].Cells["礼服编号"].Value.ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = this.dgvData.Rows[e.RowIndex].Cells["礼服名称"].Value.ToString().Trim();
dgvr.Cells.Add(cell);
this.dgvData2.Rows.Add(dgvr);
}
}
}
///
/// 双击移除
///
///
///
void dgvData2_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
{
if (this.dgvData.Rows.Count > 0)
{
this.dgvData2.Rows.RemoveAt(e.RowIndex);
}
}
}
///
/// 取消
///
///
///
void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
///
///
///
private void PublicFunctionRows()
{
this.dgvData.Rows.Clear();
string strWhere = "";
if (!string.IsNullOrEmpty(this.txtQuery.Text.Trim()))
{ strWhere += " And (Dsfm_DressNumber like '%" + this.txtQuery.Text.Trim() + "%' Or Dsfm_DressName like '%" + this.txtQuery.Text.Trim() + "%')"; }
if (!string.IsNullOrEmpty(this.cmbtreevCategory.Text.Trim()))
{ strWhere += " And Dsfm_DressType = '" + this.cmbtreevCategory.Tag.ToString().Trim() + "'"; }
DataTable tbl = orbll.GetView_Custom("tb_ErpDressFrom left Join tb_ErpSystemCategory AS SystemDressType on Dsfm_DressType = SystemDressType.Sc_ClassCode left Join tb_ErpSystemCategory AS SystemPlacedRegion on Dsfm_PlacedRegion = SystemPlacedRegion.Sc_ClassCode", StrWhere: "Dsfm_IsEnabled = '1'" + strWhere, ShowColumnName: "Dsfm_DressNumber AS 礼服编号,SystemDressType.Sc_ClassName AS 礼服类别,Dsfm_DressName AS 礼服名称,Dsfm_DressBrand AS 礼服品牌,Dsfm_DressSize AS 礼服尺寸,SystemPlacedRegion.Sc_ClassName AS 摆放区域,Dsfm_DressRemark AS 礼服说明,Dsfm_PicturePath").Tables[0];
for (int i = 0; i < tbl.Rows.Count; i++)
{
DataGridViewRow dgvr = new DataGridViewRow();
DataGridViewCell cell = null;
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i]["礼服编号"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i]["礼服类别"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i]["礼服名称"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i]["礼服品牌"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i]["礼服尺寸"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i]["摆放区域"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = tbl.Rows[i]["礼服说明"].ToString().Trim();
dgvr.Cells.Add(cell);
this.dgvData.Rows.Add(dgvr);
}
this.dgvData.Columns["礼服编号"].Frozen = true;
}
///
///
///
private void PublicFunctionRows2()
{
if (!string.IsNullOrEmpty(this.StrValue))
{
string StrWhere = this.StrValue.Replace(",", "','");
StrWhere = " Dsfm_DressNumber in ('" + StrWhere + "') ";
DataTable tbl = orbll.GetView_Custom("tb_ErpDressFrom", StrWhere: StrWhere, ShowColumnName: "Dsfm_DressNumber AS 礼服编号,Dsfm_DressName AS 礼服名称").Tables[0];
tbl.PrimaryKey = new DataColumn[] { tbl.Columns["礼服编号"] };
string[] strArray = StrValue.Trim().Split(',');
for (int i = 0; i < strArray.Length; i++)
{
DataRow dtRow = tbl.Rows.Find(strArray[i].Trim());
if (dtRow != null)
{
DataGridViewRow dgvr = new DataGridViewRow();
DataGridViewCell cell = null;
cell = new DataGridViewTextBoxCell();
cell.Value = dtRow["礼服编号"].ToString().Trim();
dgvr.Cells.Add(cell);
cell = new DataGridViewTextBoxCell();
cell.Value = dtRow["礼服名称"].ToString().Trim();
dgvr.Cells.Add(cell);
this.dgvData2.Rows.Add(dgvr);
}
}
}
}
}
}