问题描述
- 进销存管理系统C#中,什么存在二义性,inputDataGridArray[0]这里不懂怎么改
-
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;namespace 进销存管理系统
{
public partial class StockTable : Form
{
private LinkDataBase link = new LinkDataBase();
private DataTable newTable;
//保存从”供货商信息维护”窗体中选择后传过来的数据,它们将被放入DataGrid的相 应表格中
public static string[] inputDataGridArray = new string[]{null,null,null};
//保存从”供货商信息维护”窗体中选择后传过来的数据,它们将被赋值给供货商号和名称
//的控件Text属性
//确定要赋的值为文本,故用空字符初始化
public static string[] inputDataGridArray = new string[] {"",""};
private DateTime gridMouseDownTime;//记录单击DateGrid时的时间public StockTable() { InitializeComponent(); this.selectDataBase(); this.DataGridStateControl(); this.cmb_StokerID.Items.Add(""); } public void setWareData() {
dgrd_StockTable[dgrd_StockTable.CurrentCell.RowNumber,0]=inputDataGridArray[0];
dgrd_StockTable[dgrd_StockTable.CurrentCell.RowNumber,4]=inputDataGridArray[1];
dgrd_StockTable[dgrd_StockTable.CurrentCell.RowNumber,5]=inputDataGridArray[2];
dgrd_StockTable[dgrd_StockTable.CurrentCell.RowNumber,7]=17;} private void setTextData() { this .cmb_StokerID.IntegralHeight = false; this .cmb_StokerID.DroppedDown = false; this .cmb_StokerID.Items[0] = inputDataGridArray[0]; this .cmb_StokerID.SelectedIndex= 0; this.txt_StokerName.Text= inputDataGridArray [1]; this .cmb_StokerID.IntegralHeight = true ; } private void selectDataBase() { this .txt_StockDate.Text = System .DateTime .Today.ToShortDateString (); string tempStrSQL = "select distinct 姓名from 用户清单"; DataTable tempDataTable = link.SelectDataBase(tempStrSQL); for (int i =0;i<tempDataTable .Rows .Count ;i++) this .cmb_Oprater.Items.Add(tempDataTable.Rows [i][0]); this.cmb_Oprater.SelectedIndex = 0; } private void DataGridStateControl() { newTable = new DataTable (); newTable.Columns.Add("货号(双击)",typeof (string )); newTable.Columns.Add("数量",typeof (decimal )); newTable.Columns.Add("单价",typeof (decimal )); newTable.Columns.Add("仓库",typeof(string )); newTable.Columns.Add("品名",typeof (string )); newTable.Columns.Add("单位",typeof (string )); newTable.Columns.Add("金额",typeof (decimal ),"数量单价?"); newTable.Columns.Add("税率",typeof (decimal )); newTable.Columns.Add("不含税额",typeof (decimal ),"金额/1.17"); newTable.Columns.Add("税额",typeof (decimal ),"金额-不含税额"); this .dgrd_StockTable.DataSource= newTable; newTable.Rows.Add(newTable.NewRow()); DataGridTableStyle ts = new DataGridTableStyle (); DataGridTextBoxColumn aColumnTextColumn; ts.AllowSorting = false ; ts.AlternatingBackColor = Color .LightGray ; ts.MappingName = newTable.TableName; int numCols = newTable.Columns.Count; for (int i =0;i <numCols ;i++) { aColumnTextColumn = new DataGridTextBoxColumn (); if (i!=0&&i!=1&&i!=2&&i!=3) { aColumnTextColumn .ReadOnly = true ; } if (i==0) { aColumnTextColumn .TextBox .MouseDown += new MouseEventHandler (TextBoxMouseDownHandler); } if (i==4) { aColumnTextColumn .Width =160; } if (i==3) { string sendStrSQL ="select distinct仓库from 库存库a order by 仓库ASC"; DataTable tempTable = this .link.SelectDataBase(sendStrSQL ); } else { aColumnTextColumn .MappingName = newTable.Columns[i].ColumnName; aColumnTextColumn .HeaderText = newTable.Columns[i].ColumnName; aColumnTextColumn .NullText= ""; aColumnTextColumn .Format= "N"; ts .GridColumnStyles.Add(aColumnTextColumn ); } } this .dgrd_StockTable.TableStyles.Add(ts); } private void toolBar1_Button_Click(object sender,System .Windows .Forms . ToolBarButtonClickEventArgs e) { if (e.Button .ToolTipText =="保存修改?") { clickedSaveIcon(); } else if (e.Button .ToolTipText =="删除数据") { try { if (newTable.Rows.Count>0) { this .newTable.Rows.RemoveAt(this .dgrd_StockTable.CurrentCell.RowNumber); this .controlCalculate(); } if (newTable.Rows.Count-1<=0) newTable.Rows.Add(newTable.NewRow()); } catch { return; } } else if (e.Button.ToolTipText==" 打印报表") { }
}
//------------创建窗体,共用户选择供货商------------
private void cmd_Stoker_DropDown(object sender ,System.EventArgs e)
{
StokerDataManage newFrm= new StokerDataManage();
newFrm.setDataGridReadOnly();
newFrm.ShowDialog();
setTextData();
SendKeys.Send("{Tab}"); //向活动应用程序发送Tab键,跳到下一控件
}
解决方案
public static string[] inputDataGridArray = new string[]{null,null,null};
public static string[] inputDataGridArray = new string[] {"",""};
同一个变量你定义了2次,你应该删除其中之一。