private void FormFZC_Load(object sender, EventArgs e) { try { if (AllProduct == null) { List <View_P_AssemblingBom> list = new List <View_P_AssemblingBom>(); DataTable dt = m_preventErrorServer.GetAllAssemblingBom(m_productType); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { View_P_AssemblingBom assembling = new View_P_AssemblingBom(); assembling.父总成名称 = dt.Rows[i]["分总成名称"].ToString(); list.Add(assembling); } } AllProduct = list; } DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn(); column.Visible = true; column.Name = "选中"; column.HeaderText = "选中"; column.ReadOnly = false; dataGridView1.Columns.Add(column); dataGridView1.Columns.Add("分总成名称", "分总成名称"); foreach (DataGridViewColumn item in dataGridView1.Columns) { if (item.Name != "选中") { item.ReadOnly = true; item.Width = item.HeaderText.Length * (int)this.Font.Size + 100; } else { item.Width = 68; item.ReadOnly = false; item.Frozen = false; } } bool selectedFlag = false; int count = 0; foreach (var item in AllProduct) { selectedFlag = false; if (SelectedProduct != null && count < SelectedProduct.Count) { if (SelectedProduct.FindIndex(c => c.父总成名称 == item.父总成名称) >= 0) { selectedFlag = true; count++; } } dataGridView1.Rows.Add(new object[] { selectedFlag, item.父总成名称 }); } m_count = dataGridView1.Rows.Count; if (m_dataLocalizer == null) { m_dataLocalizer = new UserControlDataLocalizer(dataGridView1, this.Name, UniversalFunction.SelectHideFields(this.Name, dataGridView1.Name, BasicInfo.LoginID)); panelTop.Controls.Add(m_dataLocalizer); m_dataLocalizer.Dock = DockStyle.Bottom; } } catch (Exception err) { MessageDialog.ShowErrorMessage(err.Message); } }
private void FormProductType_Load(object sender, EventArgs e) { AllProduct = null; dataGridView1.Rows.Clear(); try { if (AllProduct == null) { IQueryable <View_P_ProductInfo> productInfo = null; if (!m_productInfoServer.GetAllProductInfo(out productInfo, out m_error)) { MessageDialog.ShowErrorMessage(m_error); } AllProduct = productInfo.ToList(); } DataGridViewCheckBoxColumn column = new DataGridViewCheckBoxColumn(); column.Visible = true; column.Name = "选中"; column.HeaderText = "选中"; column.ReadOnly = false; dataGridView1.Columns.Add(column); dataGridView1.Columns.Add("序号", "序号"); dataGridView1.Columns.Add("产品类型编码", "产品类型编码"); dataGridView1.Columns.Add("产品类型名称", "产品类型名称"); dataGridView1.Columns.Add("产品装配简码", "产品装配简码"); dataGridView1.Columns.Add("是否返修专用", "是否返修专用"); dataGridView1.Columns.Add("备注", "备注"); foreach (DataGridViewColumn item in dataGridView1.Columns) { if (item.Name != "选中") { item.ReadOnly = true; item.Width = item.HeaderText.Length * (int)this.Font.Size + 100; } else { item.Width = 68; item.ReadOnly = false; item.Frozen = false; } } bool selectedFlag = false; int count = 0; foreach (var item in AllProduct) { selectedFlag = false; if (SelectedProduct != null && count < SelectedProduct.Count) { if (SelectedProduct.FindIndex(c => c.产品类型编码 == item.产品类型编码) >= 0) { selectedFlag = true; count++; } } dataGridView1.Rows.Add(new object[] { selectedFlag, item.序号, item.产品类型编码, item.产品类型名称, item.产品装配简码, item.是否返修专用, item.备注 }); } m_count = dataGridView1.Rows.Count; if (m_dataLocalizer == null) { m_dataLocalizer = new UserControlDataLocalizer(dataGridView1, this.Name, UniversalFunction.SelectHideFields(this.Name, dataGridView1.Name, BasicInfo.LoginID)); panelTop.Controls.Add(m_dataLocalizer); m_dataLocalizer.Dock = DockStyle.Bottom; } dataGridView1.Columns["序号"].Visible = false; } catch (Exception err) { MessageDialog.ShowErrorMessage(err.Message); } }