private void but_new_Click(object sender, EventArgs e) { HCSCM_storage_manage_new hcsm = new HCSCM_storage_manage_new(null); hcsm.ShowDialog(); Loaddata(); if (dgv_01.Rows.Count > 0) { dgv_01.CurrentRow = dgv_01.Rows[dgv_01.RowCount - 1]; } }
private void but_new_Click(object sender, EventArgs e) { HCSCM_storage_manage_new hcsm = new HCSCM_storage_manage_new(null); //获取一个值,指是否在Windows任务栏中显示窗体。 hcsm.ShowInTaskbar = false; hcsm.ShowDialog(); Loaddata(null); if (dgv_01.Rows.Count > 0) { dgv_01.CurrentRow = dgv_01.Rows[dgv_01.RowCount - 1]; } }
//修改 private void but_edit_Click(object sender, EventArgs e) { if (dgv_01.SelectedRows.Count == 0) { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("choicechange", EnumPromptMessage.warning, new string[] { "修改", "存储点" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int selectedIndex = dgv_01.Rows.IndexOf(dgv_01.SelectedRows[0]); SortedList slindata = new SortedList();//存取和传递dgv某一行数据 try { slindata.Add("id", dgv_01.SelectedRows[0].Cells["id"].Value); slindata.Add("s_name", dgv_01.SelectedRows[0].Cells["s_name"].Value); slindata.Add("s_barcode", dgv_01.SelectedRows[0].Cells["s_barcode"].Value); slindata.Add("s_type", dgv_01.SelectedRows[0].Cells["s_type"].Value); slindata.Add("s_room", dgv_01.SelectedRows[0].Cells["s_room"].Value); slindata.Add("s_customer", sl_customer.GetKey(sl_customer.IndexOfValue(dgv_01.SelectedRows[0].Cells["s_customer"].Value))); slindata.Add("s_uselocation", sl_uselocation.GetKey(sl_uselocation.IndexOfValue(dgv_01.SelectedRows[0].Cells["s_uselocation"].Value))); Costcenter(sl_customer.GetKey(sl_customer.IndexOfValue(dgv_01.SelectedRows[0].Cells["s_customer"].Value)).ToString()); slindata.Add("s_costcenter", sl_costcenter2.GetKey(sl_costcenter2.IndexOfValue(dgv_01.SelectedRows[0].Cells["s_costcenter"].Value))); slindata.Add("s_basket", dgv_01.SelectedRows[0].Cells["s_basket"].Value); slindata.Add("s_remarks", dgv_01.SelectedRows[0].Cells["s_remarks"].Value); slindata.Add("s_cabinet", dgv_01.SelectedRows[0].Cells["s_cabinet"].Value); HCSCM_storage_manage_new hcsm = new HCSCM_storage_manage_new(slindata); hcsm.ShowDialog(); if (tb_sel.Text == string.Empty) { if (rb_base.Checked == false && rb_ins.Checked == false) { if (this.cb_customer.Text == "----所有----") { Loaddata(null); } else { Loaddata(sl_customer.GetKey(sl_customer.IndexOfValue(this.cb_customer.Text)).ToString()); } } else { if (rb_ins.Checked == true) { rb_CheckedChanged(null, null); } if (rb_base.Checked == true) { rb_base_CheckedChanged(null, null); } } } else { GetData(); } if (dgv_01.Rows.Count > selectedIndex) { dgv_01.CurrentRow = dgv_01.Rows[selectedIndex]; } } catch { MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("choicechange", EnumPromptMessage.warning, new string[] { "修改", "存储点" }), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } }