コード例 #1
0
        //private void GetData()
        //{
        //    dgv_01.Rows.Clear();
        //    dgv_01.ClearSelection();
        //    string strsecdata = tb_select.Text.Trim().ToUpper();

        //    string str_usertp = sl_customer.GetKey(sl_customer.IndexOfValue(this.cb_customer.Text)).ToString();
        //    CnasRemotCall reCnasRemotCall = new CnasRemotCall();
        //    DataTable getdt = reCnasRemotCall.RemotInterface.SelectData("HCS-use-location-sec001", null);


        //    if (str_usertp == "0")//查询所有客户的基本包
        //    {
        //        arrayDR = getdt.Select(" u_uname like '%" + strsecdata + "%' or u_barcode like '%" + strsecdata + "%'");
        //    }
        //    else
        //    {
        //        arrayDR = getdt.Select("u_customer=" + "'" + str_usertp + "'" + " and ( u_uname like '%" + strsecdata + "%' or u_barcode like '%" + strsecdata + "%' )");//根据客户查询包
        //    }
        //    int ii = arrayDR.Length;
        //    if (ii <= 0) return;
        //    dgv_01.RowCount = ii;
        //    int i = 0;
        //    foreach (DataRow dr in arrayDR)
        //    {
        //        if (getdt.Columns.Contains("id") && !string.IsNullOrEmpty(getdt.Rows[i]["id"].ToString())) dgv_01.Rows[i].Cells["id"].Value = dr["id"].ToString();
        //        if (getdt.Columns.Contains("u_barcode") && !string.IsNullOrEmpty(getdt.Rows[i]["u_barcode"].ToString())) dgv_01.Rows[i].Cells["u_barcode"].Value = dr["u_barcode"].ToString();
        //        if (getdt.Columns.Contains("u_uname") && !string.IsNullOrEmpty(getdt.Rows[i]["u_uname"].ToString())) dgv_01.Rows[i].Cells["u_uname"].Value = dr["u_uname"].ToString();
        //        if (getdt.Columns.Contains("u_customer") && !string.IsNullOrEmpty(getdt.Rows[i]["u_customer"].ToString())) dgv_01.Rows[i].Cells["u_customer"].Value = sl_customer[dr["u_customer"].ToString()].ToString();
        //        if (getdt.Columns.Contains("u_locationtype") && !string.IsNullOrEmpty(getdt.Rows[i]["u_locationtype"].ToString())) dgv_01.Rows[i].Cells["u_locationtype"].Value = sl_type[dr["u_locationtype"].ToString()].ToString();
        //        if (getdt.Columns.Contains("u_costcenter") && !string.IsNullOrEmpty(getdt.Rows[i]["u_costcenter"].ToString())) dgv_01.Rows[i].Cells["u_costcenter"].Value = sl_costcenter[dr["u_costcenter"].ToString()].ToString();
        //        if (getdt.Columns.Contains("u_remarks") && !string.IsNullOrEmpty(getdt.Rows[i]["u_remarks"].ToString())) dgv_01.Rows[i].Cells["u_remarks"].Value = dr["u_remarks"].ToString();
        //        i++;
        //    }
        //    if (dgv_01.Rows.Count > 0)
        //    {
        //        dgv_01.CurrentRow = dgv_01.Rows[0];
        //    }
        //}

        private void but_new_Click(object sender, EventArgs e)
        {
            HCSCM_location_manage_new hcsm = new HCSCM_location_manage_new(DTcostcenter, DTcustomer, null);

            //获取一个值,指是否在Windows任务栏中显示窗体。
            hcsm.ShowInTaskbar = false;
            hcsm.ShowDialog();
            Loaddata();
            if (dgv_01.Rows.Count > 0)
            {
                dgv_01.CurrentRow = dgv_01.Rows[dgv_01.RowCount - 1];
            }
        }
コード例 #2
0
        private void but_edit_Click(object sender, EventArgs e)
        {
            if (this.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();

            try
            {
                slindata.Add("id", dgv_01.SelectedRows[0].Cells["id"].Value == null ? string.Empty : dgv_01.SelectedRows[0].Cells["id"].Value);
                slindata.Add("bar_code", dgv_01.SelectedRows[0].Cells["u_barcode"].Value == null ? string.Empty : dgv_01.SelectedRows[0].Cells["u_barcode"].Value);
                slindata.Add("u_uname", dgv_01.SelectedRows[0].Cells["u_uname"].Value == null ? string.Empty : dgv_01.SelectedRows[0].Cells["u_uname"].Value);
                slindata.Add("u_barcode", dgv_01.SelectedRows[0].Cells["u_barcode"].Value == null ? string.Empty : dgv_01.SelectedRows[0].Cells["u_barcode"].Value);
                slindata.Add("u_customer", dgv_01.SelectedRows[0].Cells["u_customer"].Value == null ? string.Empty : dgv_01.SelectedRows[0].Cells["u_customer"].Value);
                slindata.Add("u_costcenter", dgv_01.SelectedRows[0].Cells["u_costcenter"].Value == null ? string.Empty : dgv_01.SelectedRows[0].Cells["u_costcenter"].Value);
                slindata.Add("u_locationtype", dgv_01.SelectedRows[0].Cells["u_locationtype"].Value == null ? string.Empty : dgv_01.SelectedRows[0].Cells["u_locationtype"].Value);
                slindata.Add("u_remarks", dgv_01.SelectedRows[0].Cells["u_remarks"].Value == null ? string.Empty : dgv_01.SelectedRows[0].Cells["u_remarks"].Value);
            }
            catch (Exception ex)
            {
                MessageBox.Show(PromptMessageXmlHelper.Instance.GetPromptMessage("unknowerror", EnumPromptMessage.error, new string[] { ex.Message }), "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            HCSCM_location_manage_new hcsm = new HCSCM_location_manage_new(DTcostcenter, DTcustomer, slindata);

            //获取一个值,指是否在Windows任务栏中显示窗体。
            hcsm.ShowInTaskbar = false;
            hcsm.ShowDialog();


            Loaddata();

            if (dgv_01.Rows.Count > selectedIndex)
            {
                dgv_01.CurrentRow = dgv_01.Rows[selectedIndex];
            }
        }