请问一下,我想实现针对datagridview的部分列,如“是否合作”,采用下拉框的形式选择“是”或“否”,而不要手工录入,相关界面与代码如下,请问应该怎么修改;
using (SqlConnection ConnK = new SqlConnection(connectionStringK))
{
ConnK.Open();
DataTable ComdtK = new DataTable();//定义此表,是为了下面的循环中,全部显示出来,而不是只显示第一行;
foreach (DataRow row in sumdt.Rows)
{
string batchNo = row["batchNo"].ToString();
string orderCode = row["orderCode"].ToString();
string queryK = @"select t2.FBillNo as FBillNo,t1.FBatchNo as FBatchNo,t3.FName as proName,t3.Fmodel as Fmodel,t6.FName as saleman ,t1.FEntrySelfB01115 as jjr from ICStockBill t2
join ICStockBillEntry t1 on t1.FInterID = t2.FInterID
join t_icitem t3 on t3.FItemID = t1.FItemID
join ICTransactionType t5 on t2.FTranType=t5.FID
join t_Organization t4 on t2.FSupplyID = t4.FItemID
join t_Emp t6 on t2.FEmpID = t6.FItemID
where t2.FTranType = '21'
and t2.FBillNo = @orderCode
and t1.FBatchNo = @batchNo";
SqlCommand cmd = new SqlCommand(queryK, ConnK);
cmd.Parameters.AddWithValue("@batchNo", batchNo);
cmd.Parameters.AddWithValue("@orderCode", orderCode);
SqlDataReader reader2 = cmd.ExecuteReader();
DataTable dtK = new DataTable();
dtK.Load(reader2);
ComdtK.Merge(dtK);//合并显示全部内容;
//dataGridView1.DataSource = ComdtK;
DataTable mergedTable = MergeTables(sumdt,ComdtK);
mergedTable.Columns.Add("购药人",typeof(string));
mergedTable.Columns.Add("承担人",typeof(string));
mergedTable.Columns.Add("序号", typeof(int));
mergedTable.Columns.Add("属性", typeof(string));
mergedTable.Columns.Add("上报日期", typeof(string));
mergedTable.Columns.Add("具体时间", typeof(string));
mergedTable.Columns.Add("网购部门", typeof(string));
mergedTable.Columns.Add("平台", typeof(string));
mergedTable.Columns.Add("购买地点", typeof(string));
mergedTable.Columns.Add("是否备案", typeof(string));
mergedTable.Columns.Add("购药数量", typeof(decimal));
mergedTable.Columns.Add("单价", typeof(decimal));
mergedTable.Columns.Add("运费", typeof(decimal));
mergedTable.Columns.Add("总金额", typeof(decimal));
mergedTable.Columns.Add("冲击单位", typeof(decimal));
mergedTable.Columns.Add("是否合作", typeof(string));
mergedTable.Columns.Add("冲击方终端经理", typeof(string));
mergedTable.Columns.Add("商业管理模式", typeof(string));
mergedTable.Columns.Add("销售总监", typeof(string));
mergedTable.Columns.Add("销售部", typeof(string));
mergedTable.Columns.Add("片区", typeof(string));
mergedTable.Columns.Add("是否扫码", typeof(string));
mergedTable.Columns.Add("终端", typeof(string));
mergedTable.Columns.Add("补偿被冲击方", typeof(string));
mergedTable.Columns.Add("应处罚", typeof(decimal));
mergedTable.Columns.Add("实际处罚", typeof(decimal));
mergedTable.Columns.Add("MS申请单", typeof(string));
mergedTable.Columns.Add("备注说明", typeof(string));
dataGridView1.DataSource = mergedTable;
dataGridView1.Columns["属性"].DisplayIndex = 0;
dataGridView1.Columns["序号"].DisplayIndex = 0;
dataGridView1.Columns["购药人"].DisplayIndex = 14;
dataGridView1.Columns["承担人"].DisplayIndex = 15;
dataGridView1.Columns["是否备案"].DisplayIndex = 16;
dataGridView1.Columns["购买地点"].DisplayIndex = 17;
dataGridView1.Columns["平台"].DisplayIndex = 18;
dataGridView1.Columns["网购部门"].DisplayIndex = 19;
dataGridView1.Columns["上报日期"].DisplayIndex = 20;
dataGridView1.Columns["具体时间"].DisplayIndex = 21;
dataGridView1.Columns["购药数量"].DisplayIndex = 22;
dataGridView1.Columns["单价"].DisplayIndex = 23;
dataGridView1.Columns["运费"].DisplayIndex = 24;
dataGridView1.Columns["总金额"].DisplayIndex = 25;
dataGridView1.Columns["冲击单位"].DisplayIndex = 26;
dataGridView1.Columns["是否合作"].DisplayIndex = 27;
dataGridView1.Columns["冲击方终端经理"].DisplayIndex = 28;
dataGridView1.Columns["商业管理模式"].DisplayIndex = 29;
dataGridView1.Columns["销售总监"].DisplayIndex = 30;
dataGridView1.Columns["销售部"].DisplayIndex = 31;
dataGridView1.Columns["片区"].DisplayIndex = 32;
dataGridView1.Columns["是否扫码"].DisplayIndex = 33;
dataGridView1.Columns["终端"].DisplayIndex = 34;
dataGridView1.Columns["补偿被冲击方"].DisplayIndex = 35;
dataGridView1.Columns["应处罚"].DisplayIndex = 36;
dataGridView1.Columns["实际处罚"].DisplayIndex = 37;
dataGridView1.Columns["MS申请单"].DisplayIndex = 38;
dataGridView1.Columns["备注说明"].DisplayIndex = 39;
dataGridView1.Columns[0].HeaderText = "批号";
dataGridView1.Columns[1].HeaderText = "出库单号";
dataGridView1.Columns[2].HeaderText = "小盒码";
dataGridView1.Columns[3].HeaderText = "大箱号";
dataGridView1.Columns[4].HeaderText = "客户名称";
dataGridView1.Columns[5].HeaderText = "类型";
dataGridView1.Columns[6].HeaderText = "出库日期";
dataGridView1.Columns[7].HeaderText = "出库时间";
dataGridView1.Columns[8].HeaderText = "产品名称";
dataGridView1.Columns[9].HeaderText = "规格";
dataGridView1.Columns[10].HeaderText = "商务经理";
dataGridView1.Columns[11].HeaderText = "冲击方";
dataGridView1.Columns[0].Frozen = true;
dataGridView1.Columns[0].DividerWidth = 1;
foreach (DataRow row1 in mergedTable.Rows)//加上出库单的类型
{
string type = Convert.ToString(row["orderType"]);
if (type == "OA") { row1["orderType"] = "销售出库"; }
if (type == "IB") { row1["orderType"] = "退货入库"; }
}
}
}