123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Collections;
- namespace LYFZ.ComponentLibrary
- {
- public partial class OrderExtractIntoItemEx : UserControl
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpOrderDigital dbll = new LYFZ.BLL.BLL_ErpOrderDigital();
- LYFZ.BLL.BLL_ErpPieceCommissionRecords pcrsbll = new BLL.BLL_ErpPieceCommissionRecords();
- public OrderExtractIntoItemEx(object objValue)
- {
- InitializeComponent();
- this.cmbtreevItemName.ComboBoxTree_NodeMouseClick += cmbtreevItemName_ComboBoxTree_NodeMouseClick;
- this.labelEx1.ForeColor = UIBlueThemeResources.TitleTextColor;
- Hashtable htData = (Hashtable)objValue;
- this.StrOrdNumber = htData["StrOrdNumber"].ToString();
- this.StrOrdViceNumber = htData["StrOrdViceNumber"].ToString();
- this.StrType = htData["StrType"].ToString();
- this.StrUsrID = htData["StrUsrID"].ToString();
- this.btnAdd.Click += btnAdd_Click;
- this.btnDelete.Click += btnDelete_Click;
- this.txtQuantity.KeyPress += txtQuantity_KeyPress;
- this.GetData();
- this.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbtreevDeductPercentagePeople, (DataTable)htData["tblDepartment"], (DataTable)htData["tblUser"]);
- this.BindComboBoxTreeView_SystemCategory("BEBBBABBEBAIHGDCB", this.cmbtreevItemName);
- this.cmbtreevDeductPercentagePeople.Nodes[0].ExpandAll();
- if (string.IsNullOrEmpty(processName) || processName != "精修")
- {
- DataTable dt = orbll.GetView_Custom("tb_ErpOrderDigital", StrWhere: "Ordv_ViceNumber = '" + this.StrOrdViceNumber + "'", ShowColumnName: "Ordv_IntoBottomQuantity,Ordv_IntoBottomQuantityPackage,Ordv_IntoBottomAddPickQuantity").Tables[0];
- if (dt.Rows.Count > 0)
- {
- IntoBottomQuantity = Convert.ToInt32(dt.Rows[0]["Ordv_IntoBottomQuantity"]);
- if (IntoBottomQuantity >= 0)
- {
- IntoBottomQuantity += Convert.ToInt32(dt.Rows[0]["Ordv_IntoBottomQuantityPackage"]);
- IntoBottomQuantity += Convert.ToInt32(dt.Rows[0]["Ordv_IntoBottomAddPickQuantity"]);
- }
- }
- }
-
- }
- public string processName
- {
- get;
- set;
- }
- string _strUsrID;
- /// <summary>
- /// 当前登录者ID
- /// </summary>
- public string StrUsrID
- {
- get { return _strUsrID; }
- set { _strUsrID = value; }
- }
- string _strOrdNumber;
- /// <summary>
- /// 订单号
- /// </summary>
- string StrOrdNumber
- {
- get { return _strOrdNumber; }
- set { _strOrdNumber = value; }
- }
- string _strOrdViceNumber;
- /// <summary>
- /// 订单号
- /// </summary>
- string StrOrdViceNumber
- {
- get { return _strOrdViceNumber; }
- set { _strOrdViceNumber = value; }
- }
- string _strType;
- /// <summary>
- /// 计件提成类型
- /// </summary>
- string StrType
- {
- get { return _strType; }
- set { _strType = value; }
- }
- int _IntoBottomQuantity = 0;
- /// <summary>
- /// 入底数量
- /// </summary>
- public int IntoBottomQuantity
- {
- get { return _IntoBottomQuantity; }
- set { _IntoBottomQuantity = value; }
- }
- string _StrSightsName;
- public string StrSightsName
- {
- get
- {
- return _StrSightsName;
- }
- set
- {
- _StrSightsName = value;
- }
- }
- public List<Helper.CommandInfo> Getdgvclist()
- {
- DataTable tbl = GetDataTablePieceCommissionRecords();
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- for (int i = 0; i < tbl.Rows.Count; i++)
- {
- bool isFind = false;
- for (int j = 0; j < this.dgvData.Rows.Count; j++)
- {
- if (this.dgvData.Rows[j].Cells["ID"].Value.ToString().Trim() != "")
- {
- if (this.dgvData.Rows[j].Cells["ID"].Value.ToString().Trim() == tbl.Rows[i]["ID"].ToString().Trim())
- { isFind = true; break; }
- }
- }
- if (!isFind)
- { clist.Add(pcrsbll.GetDeleteCommandInfo("ID", "=", tbl.Rows[i]["ID"])); }
- }
- if (this.dgvData.Rows.Count > 0)
- {
- LYFZ.Model.Model_ErpPieceCommissionRecords model = null;
- DateTime StrTime = SDateTime.Now;
- for (int j = 0; j < this.dgvData.Rows.Count; j++)
- {
- if (this.dgvData.Rows[j].Cells["ID"].Value.ToString().Trim() == "")
- {
- model = new Model.Model_ErpPieceCommissionRecords();
- model.Pcr_DividedShop = LYFZ.BLL.OrderPayment_Member.StrInfoID;
- model.Pcr_OrderNumber = this.StrOrdNumber;
- model.Pcr_DigitalDivision = this.dgvData.Rows[j].Cells["提成人编号"].Value.ToString().Trim();
- model.Pcr_Date = Convert.ToDateTime(this.dgvData.Rows[j].Cells["日期"].Value);
- model.Pcr_CompletionContents = this.dgvData.Rows[j].Cells["项目编号"].Value.ToString().Trim();
- model.Pcr_Quantity = Convert.ToInt32(this.dgvData.Rows[j].Cells["数量"].Value);
- model.Pcr_Type = Convert.ToInt32(this.StrType);
- model.Pcr_MarkKey = "";
- model.Pcr_CreateTime = StrTime;
- model.Pcr_EntryPeople = StrUsrID;
- model.Pcr_OrderSource = "订单";
- model.Pcr_OrderDigNumber = this.StrOrdViceNumber;
- clist.Add(pcrsbll.GetAddCommandInfo(model));
- }
- }
- }
- return clist;
- }
- /// <summary>
- /// 更新实际计件提成数量
- /// </summary>
- /// <param name="dirType"></param>
- public void SetServicePhotographCount(LYFZ.Model.Model_ErpOrder.DirectoryType dirType)
- {
- pcrsbll.SetServicePhotographCount(dirType,this.StrOrdNumber,this.StrOrdViceNumber,this.StrSightsName,this.StrType);
- }
- /// <summary>
- /// 绑定
- /// </summary>
- /// <returns></returns>
- DataTable GetDataTablePieceCommissionRecords()
- { return orbll.GetView_Custom("tb_ErpPieceCommissionRecords Left Join tb_ErpSystemCategory on Sc_ClassCode = Pcr_CompletionContents Left Join tb_ErpUser on User_EmployeeID = Pcr_DigitalDivision", StrWhere: "Pcr_OrderNumber = '" + StrOrdNumber + "' and Pcr_Type = '" + StrType + "'", filedOrder: "Pcr_Date DESC", ShowColumnName: "tb_ErpPieceCommissionRecords.ID, Pcr_CompletionContents AS 项目编号, Sc_ClassName AS 项目名称,Pcr_Quantity AS 数量,Pcr_DigitalDivision AS 提成人编号, User_Name AS 提成人, Pcr_Date AS 日期").Tables[0]; }
- /// <summary>
- /// 获取数据并绑定
- /// </summary>
- void GetData()
- {
- DataTable tbl = GetDataTablePieceCommissionRecords();
- this.dgvData.DataColumns(tbl.Columns, "ID,提成人编号,项目编号");
- DataGridViewCell cell = null;
- for (int i = 0; i < tbl.Rows.Count; i++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- cell = new DataGridViewTextBoxCell();
- cell.Value = tbl.Rows[i]["ID"].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 = Convert.ToInt32(tbl.Rows[i]["数量"]);
- 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 = LYFZ.Command.Command_Validate.DateTimeToString(tbl.Rows[i]["日期"], "yyyy-MM-dd HH:mm:ss");
- dgvr.Cells.Add(cell);
- this.dgvData.Rows.Add(dgvr);
- }
- this.dgvData.Columns["项目名称"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
- this.dgvData.Columns["数量"].Width = 60;
- this.dgvData.Columns["提成人"].Width = 80;
- this.dgvData.Columns["日期"].Width = 125;
- }
- /// <summary>
- /// 添加
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnAdd_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(this.cmbtreevItemName.Text.Trim()))
- { MessageBoxCustom.Show("项目不能为空!"); return; }
- if (string.IsNullOrEmpty(this.txtQuantity.Text.Trim()))
- { MessageBoxCustom.Show("数量不能为空!"); return; }
- if (string.IsNullOrEmpty(this.cmbtreevDeductPercentagePeople.Text.Trim()))
- { MessageBoxCustom.Show("提成人不能为空!"); return; }
- if (string.IsNullOrEmpty(this.dtpDate.DateValue.Trim()))
- { MessageBoxCustom.Show("日期不能为空!"); return; }
- if (this.cmbtreevItemName.Tag.ToString().Trim() == "BAAGAAI")
- {
- if (this.IntoBottomQuantity >= 0 && this.txtQuantity.Text.Trim().Length > 0)
- {
- if (this.IntoBottomQuantity < Convert.ToInt32(this.txtQuantity.Text))
- { MessageBoxCustom.Show("精修张数不能大于入底数量,入底数量为:" + this.IntoBottomQuantity); return; }
- }
- }
- DataGridViewRow dgvr = new DataGridViewRow();
- dgvr.DefaultCellStyle.ForeColor = Color.Red;
- DataGridViewCell cell = null;
- cell = new DataGridViewTextBoxCell();
- cell.Value = "";
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = this.cmbtreevItemName.Tag.ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = this.cmbtreevItemName.Text.Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = this.txtQuantity.Text.Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = this.cmbtreevDeductPercentagePeople.Tag.ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = this.cmbtreevDeductPercentagePeople.Text.Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = LYFZ.Command.Command_Validate.DateTimeToString(this.dtpDate.DateTimeValue, "yyyy-MM-dd HH:mm:ss");
- dgvr.Cells.Add(cell);
- this.dgvData.Rows.Add(dgvr);
- this.cmbtreevItemName.SetTextAndTag_ValueNull();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDelete_Click(object sender, EventArgs e)
- {
- if (this.dgvData.Rows.Count > 0)
- {
- if (MessageBoxCustom.Show("删除后则不能恢复回来!您确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- this.dgvData.Rows.Remove(this.dgvData.CurrentRow);
- }
- }
- /// <summary>
- /// 限制输入
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtQuantity_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- /// <summary>
- /// 选择工作内容选择事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void cmbtreevItemName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- //if (this.cmbtreevItemName.Tag.ToString().Trim() == "BAAGAAI")
- //{
- // if (this.IntoBottomQuantity > 0 && this.txtQuantity.Text.Trim().Length>0)
- // {
- // if (this.IntoBottomQuantity < Convert.ToInt32(this.txtQuantity.Text))
- // {
- // MessageBoxCustom.Show("");
- // }
- // }
- //}
- }
- #region 部门与人员绑定
- /// <summary>
- /// 部门、员工绑定
- /// </summary>
- /// <param name="cmbtreev">控件</param>
- /// <param name="IsFirstNodeNull">第一节点是否为空</param>
- void BindComboBoxTreeView_DepartmentAndEmployee(LYFZ.ComponentLibrary.ComboBoxTreeViewEx cmbtreev, DataTable tbl, DataTable tbl_user, bool IsFirstNodeNull = false)
- {
- TreeNode root = null;
- cmbtreev.Nodes.Clear();
- for (int i = 0; i < tbl.Rows.Count; i++)
- {
- if (i == 0)
- {
- if (IsFirstNodeNull)
- {
- root = new TreeNode(" ");
- root.Tag = "";
- root.Name = "";
- cmbtreev.Nodes.Add(root);
- }
- }
- DataRow[] dtRow = tbl_user.Select("User_Department='" + tbl.Rows[i]["ID"].ToString().Trim() + "'");
- if (dtRow.Length <= 0)
- { continue; }
- root = new TreeNode(tbl.Rows[i]["Dt_Name"].ToString());
- root.Tag = tbl.Rows[i]["ID"].ToString().Trim();
- root.Name = "Department";
- CreateTreeViewDepartmentUser(root, tbl.Rows[i]["ID"].ToString(), tbl_user);
- cmbtreev.TreeView.Nodes.Add(root);
- }
- }
- /// <summary>
- /// 绑定第二级人员
- /// </summary>
- /// <param name="nodes">TreeView的节点集合</param>
- /// <param name="dataSource">数据源</param>
- /// <param name="parentid"></param>
- void CreateTreeViewDepartmentUser(TreeNode nodes, string ClassCode, DataTable tbl_user)
- {
- if (ClassCode != "")
- {
- DataRow[] dtRow = tbl_user.Select("User_Department='" + ClassCode + "' and User_Status = '在职'");
- if (dtRow.Length > 0)
- {
- TreeNode node;
- for (int i = 0; i < dtRow.Length; i++)
- {
- node = new TreeNode();
- node.Text = dtRow[i]["User_Name"].ToString();
- node.Tag = dtRow[i]["User_EmployeeID"].ToString();
- node.Name = "User";
- nodes.Nodes.Add(node);
- if(this.StrUsrID== node.Tag.ToString())
- {
- nodes.Expand();
- this.cmbtreevDeductPercentagePeople.SelectedNode = node;
- this.cmbtreevDeductPercentagePeople.Text = node.Text;
- this.cmbtreevDeductPercentagePeople.Tag = node.Tag;
- }
- }
- }
- }
- }
- #endregion
- #region 系统类别设置绑定
- /// <summary>
- /// 系统设置的绑定数据
- /// </summary>
- /// <param name="StrParentCode">系统类别中的Sc_ClassCode值</param>
- /// <param name="cmbtreev">当前下拉树</param>
- /// <param name="IsFirstNodeNull">第一节点是否为空</param>
- void BindComboBoxTreeView_SystemCategory(string StrParentCode, LYFZ.ComponentLibrary.ComboBoxTreeViewEx cmbtreev, bool IsFirstNodeNull = false)
- {
- DataTable tbl = new BLL.BLL_ErpSystemCategory().GetCategory("ID,Sc_ClassCode,Sc_ClassName,Sc_ClassParentID", "").Tables[0];
- cmbtreev.Nodes.Clear();
- DataRow[] dtRow = tbl.Select("Sc_ClassCode = '" + StrParentCode + "'");
- if (dtRow.Length > 0)
- {
- DataRow[] dtRow2 = tbl.Select("Sc_ClassParentID = '" + dtRow[0]["ID"].ToString().Trim() + "'");
- TreeNode root = null;
- for (int i = 0; i < dtRow2.Length; i++)
- {
- if (i == 0)
- {
- if (IsFirstNodeNull)
- {
- root = new TreeNode(" ");
- root.Tag = "";
- root.Name = "";
- cmbtreev.Nodes.Add(root);
- }
- }
- root = new TreeNode();
- root.Text = dtRow2[i]["Sc_ClassName"].ToString();
- root.Tag = dtRow2[i]["Sc_ClassCode"].ToString();
- root.Name = dtRow2[i]["ID"].ToString();
- CreateTreeViewSystemCategory(root, dtRow2[i]["ID"].ToString(), tbl);
- cmbtreev.TreeView.Nodes.Add(root);
- }
- }
- }
- /// <summary>
- /// 第二级绑定
- /// </summary>
- /// <param name="nodes">父节点</param>
- /// <param name="ClassParentID">父节点的ID</param>
- /// <param name="tbl">当前数据源</param>
- private static void CreateTreeViewSystemCategory(TreeNode nodes, string ClassParentID, DataTable tbl)
- {
- DataRow[] dtRow = tbl.Select("Sc_ClassParentID='" + ClassParentID + "'");
- if (dtRow.Length > 0)
- {
- TreeNode node;
- for (int i = 0; i < dtRow.Length; i++)
- {
- node = new TreeNode();
- node.Text = dtRow[i]["Sc_ClassName"].ToString();
- node.Tag = dtRow[i]["Sc_ClassCode"].ToString();
- node.Name = dtRow[i]["ID"].ToString();
- nodes.Nodes.Add(node);
- CreateTreeViewSystemCategory(node, dtRow[i]["ID"].ToString(), tbl);
- }
- }
- }
- #endregion
- }
- }
|