| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- /*******************************************************************************
- * Copyright(c) 2012 dongke All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_SelectGoods.cs
- * 2.功能描述:产品查询界面
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 陈冰 2014/09/15 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- namespace Dongke.IBOSS.PRD.Client.Controls.FormCommon
- {
- /// <summary>
- /// 产品查询界面
- /// </summary>
- public partial class F_SelectGoods : FormBase
- {
- #region 构造函数
- public F_SelectGoods()
- {
- InitializeComponent();
- this.btnOK.Text = ButtonText.BTN_OK;
- this.btnClose.Text = ButtonText.BTN_CANCEL;
- this.btnSearch.Text = ButtonText.BTN_SEARCH;
- this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
- this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
- }
- #endregion
- #region 属性
- /// <summary>
- /// 选择的数据
- /// </summary>
- public DataTable SelTable { get; set; }
- /// <summary>
- /// 转入的产品编码
- /// </summary>
- public string SetGoodsCode { get; set; }
- #endregion
- #region 事件
- /// <summary>
- /// 页面加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void SelectProduct_Load(object sender, EventArgs e)
- {
- try
- {
- // 设置表格不自动创建列
- this.dgvGoods.AutoGenerateColumns = false;
- // 加载页面所需的数据源
- LoadDataSource();
- this.txtGoodsCode.Text = this.SetGoodsCode;
- btnSearch_Click(null, null);
- // 编辑单元格的颜色
- this.dgvGoods.IsSetInputColumnsColor = true;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- GoodsEntity goods = new GoodsEntity();
- goods.CeaseFlag = 1;
- goods.ValueFlag = 1;
- if (!string.IsNullOrEmpty(this.txtGoodsCode.Text.Trim()))
- {
- goods.GoodsCode = this.txtGoodsCode.Text.Trim();
- }
- if (!string.IsNullOrEmpty(this.txtGoodsName.Text.Trim()))
- {
- goods.GoodsName = this.txtGoodsName.Text.Trim();
- }
- if (!string.IsNullOrEmpty(this.txtGoodsSpecification.Text.Trim()))
- {
- goods.GoodsSpecification = this.txtGoodsSpecification.Text.Trim();
- }
- if (!string.IsNullOrEmpty(scbGoodsType.SearchedValue + ""))
- {
- goods.GoodsTypeCode = scbGoodsType.SearchedValue + "";
- }
- if (!string.IsNullOrEmpty(this.txtGoodsModel.Text.Trim()))
- {
- goods.GoodsModel = this.txtGoodsModel.Text.Trim();
- }
- if (this.ddlGlazeTypeID.SelectedValue != null && this.ddlGlazeTypeID.SelectedValue + "" != "")
- {
- goods.GlazeTypeID = Convert.ToInt32(this.ddlGlazeTypeID.SelectedValue);
- }
- // 查询
- DataSet ds = (DataSet)DoAsync(new BaseAsyncMethod(() =>
- {
- return SystemModuleProxy.Service.SerachGoods(goods);
- }));
- if (ds != null
- && ds.Tables.Count > 0
- && ds.Tables[0].Rows.Count > 0)
- {
- this.dgvGoods.DataSource = ds.Tables[0];
- // 取消全选
- this.chkChooseAll.Checked = false;
- this.dgvGoods.CurrentCell = this.dgvGoods.Rows[0].Cells["Sel"];
- this.dgvGoods.Columns["Sel"].ReadOnly = false;
- }
- else
- {
- // 清空数据
- this.dgvGoods.DataSource = null;
- // 提示未查找到数据
- MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
- MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnOK_Click(object sender, EventArgs e)
- {
- try
- {
- this.Commit();
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 全选
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void chkChooseAll_CheckedChanged(object sender, EventArgs e)
- {
- for (int i = 0; i < this.dgvGoods.Rows.Count; i++)
- {
- this.dgvGoods.Rows[i].Cells["Sel"].Value = this.chkChooseAll.Checked;
- }
- }
- /// <summary>
- /// 选中产品
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvGoods_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- // 点击的是选中列
- if (e.ColumnIndex != -1 && e.RowIndex != -1)
- {
- if (this.dgvGoods.Columns[e.ColumnIndex].Name == "Sel")
- {
- int value = int.Parse(this.dgvGoods.Rows[e.RowIndex].Cells["Sel"].Value.ToString());
- this.dgvGoods.Rows[e.RowIndex].Cells["Sel"].Value = value == Constant.INT_IS_ONE ? Constant.INT_IS_ZERO : Constant.INT_IS_ONE;
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 清空条件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClearCondition_Click(object sender, EventArgs e)
- {
- this.txtGoodsCode.Text = "";
- this.txtGoodsName.Text = "";
- this.txtGoodsSpecification.Text = "";
- this.scbGoodsType.ClearValue();
- this.txtGoodsModel.Text = "";
- this.ddlGlazeTypeID.SelectedIndex = 0;
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 加载页面所需的数据源
- /// </summary>
- private void LoadDataSource()
- {
- try
- {
- // 绑定釉料类别
- DataTable dt = SystemModuleProxy.Service.GetDataDictionaryByType(Constant.DictionaryType.TPC002, 1);
- if (dt != null)
- {
- DataRow row = dt.NewRow();
- row["DictionaryValue"] = "";
- row["DictionaryID"] = DBNull.Value;
- dt.Rows.InsertAt(row, 0);
- ddlGlazeTypeID.DisplayMember = "DictionaryValue";
- ddlGlazeTypeID.ValueMember = "DictionaryID";
- ddlGlazeTypeID.DataSource = dt;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 点击确定或者回车键时调用
- /// </summary>
- private void Commit()
- {
- try
- {
- DataTable invDt = (DataTable)this.dgvGoods.DataSource;
- if (invDt == null || invDt.Rows.Count == 0)
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
- "没有选择数据"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- invDt.AcceptChanges();
- invDt = invDt.Copy();
- string filter = "Sel = 1";
- invDt.DefaultView.RowFilter = filter;
- invDt = invDt.DefaultView.ToTable();
- // 如果选中了数据就关闭窗体,反之则不关
- if (invDt.Rows.Count > 0)
- {
- SelTable = invDt;
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
- "没有选择数据"), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- }
- }
|