示例#1
0
        private void SetDataBind_gridView1(string codeGrp, string code_val)
        {
            M_WsCodeTMainDB.WsCodeTMainDB wSvc = null;
            string reCode = "";
            string reMsg  = "";

            M_WsCodeTMainDB.DataCodeT[]    getData1 = null;
            M_WsCodeTMainDB.DataCodeTSub[] getData2 = null;

            try
            {
                wSvc         = new M_WsCodeTMainDB.WsCodeTMainDB();
                wSvc.Url     = "http://" + AppInfo.SsWsvcServer2 + "/WebSvc/Sys/CodeT/WsCodeTMainDB.svc";
                wSvc.Timeout = 1000;

                dataGridView2.Enabled = false;
                btnSave.Enabled       = false;

                if (codeGrp == "1")
                {
                    dataGridView2.Enabled = true;
                    btnSave.Enabled       = true;

                    dataGridView1.Columns["dgv1_TTYPE_SCD"].Visible     = true;
                    dataGridView1.Columns["dgv1_LIST_FLAG"].Visible     = true;
                    dataGridView1.Columns["dgv1_REQUIRED_FLAG"].Visible = true;
                    dataGridView1.Columns["dgv1_NUMERIC_FLAG"].Visible  = true;
                    dataGridView1.Columns["dgv1_USING_CNT"].Visible     = false;
                    dataGridView2.Columns["dgv2_LIST_FLAG"].Visible     = true;
                    dataGridView2.Columns["dgv2_REQUIRED_FLAG"].Visible = true;
                    dataGridView2.Columns["dgv2_NUMERIC_FLAG"].Visible  = true;
                    dataGridView2.Columns["dgv2_TCODE"].ReadOnly        = false;


                    reCode = wSvc.sCodeT(code_val, out getData1, out reMsg);
                    if (reCode == "Y")
                    {
                        if (getData1 != null && getData1.Length > 0)
                        {
                            dataGridView1.Rows.Clear();
                            for (int i = 0; i < getData1.Length; i++)
                            {
                                dataGridView1.Rows.Add();
                                dataGridView1.Rows[i].Cells["dgv1_TCODE"].Value         = getData1[i].TCODE.ToString();
                                dataGridView1.Rows[i].Cells["dgv1_TTYPE_SCD"].Value     = getData1[i].TTYPE_SCD.ToString();
                                dataGridView1.Rows[i].Cells["dgv1_NM"].Value            = getData1[i].TCODE_NM.ToString();
                                dataGridView1.Rows[i].Cells["dgv1_LIST_FLAG"].Value     = getData1[i].LIST_FLAG.ToString();
                                dataGridView1.Rows[i].Cells["dgv1_REQUIRED_FLAG"].Value = getData1[i].REQUIRED_FLAG.ToString();
                                dataGridView1.Rows[i].Cells["dgv1_NUMERIC_FLAG"].Value  = getData1[i].NUMERIC_FLAG.ToString();
                            }

                            SetRowNumber(dataGridView1);
                        }
                        else
                        {
                            dataGridView1.Rows.Clear();
                        }
                    }
                }
                else if (codeGrp == "2")
                {
                    dataGridView1.Columns["dgv1_TTYPE_SCD"].Visible     = false;
                    dataGridView1.Columns["dgv1_LIST_FLAG"].Visible     = false;
                    dataGridView1.Columns["dgv1_REQUIRED_FLAG"].Visible = false;
                    dataGridView1.Columns["dgv1_NUMERIC_FLAG"].Visible  = false;
                    dataGridView1.Columns["dgv1_USING_CNT"].Visible     = true;
                    dataGridView2.Columns["dgv2_LIST_FLAG"].Visible     = false;
                    dataGridView2.Columns["dgv2_REQUIRED_FLAG"].Visible = false;
                    dataGridView2.Columns["dgv2_NUMERIC_FLAG"].Visible  = false;

                    if (code_val == "InspectionMethod" || code_val == "CarSize")
                    {
                        dataGridView2.Enabled = true;
                        btnSave.Enabled       = true;

                        if (btnSave.Text == wRM.GetString("wApply"))
                        {
                            btnSave.Enabled       = false;
                            dataGridView2.Enabled = false;
                        }

                        dataGridView2.Rows[0].Cells["dgv2_TCODE"].Value = code_val;
                        dataGridView2.Columns["dgv2_TCODE"].ReadOnly    = true;

                        reCode = wSvc.sCodeTSub(code_val, out getData2, out reMsg);
                        if (reCode == "Y")
                        {
                            if (getData2 != null && getData2.Length > 0)
                            {
                                dataGridView1.Rows.Clear();

                                for (int i = 0; i < getData2.Length; i++)
                                {
                                    dataGridView1.Rows.Add();
                                    dataGridView1.Rows[i].Cells["dgv1_TCODE"].Value     = getData2[i].TCODE.ToString();
                                    dataGridView1.Rows[i].Cells["dgv1_NM"].Value        = getData2[i].TSCODE_NM.ToString();
                                    dataGridView1.Rows[i].Cells["dgv1_USING_CNT"].Value = getData2[i].USING_CNT.ToString();
                                }

                                SetRowNumber(dataGridView1);
                            }
                            else
                            {
                                dataGridView1.Rows.Clear();
                                //MessageBox.Show("데이터가 없습니다");
                            }
                        }
                    }
                    else
                    {
                        dataGridView1.Rows.Clear();
                        lblName.Text = null;
                    }
                }
                else
                {
                    dataGridView1.Rows.Clear();
                    lblName.Text = null;
                }
            }
            catch (Exception ex)
            {
                logs.SaveLog("[error]  (page)::FrmCodeTMainDB.cs  (Function)::SetDataBind_gridView1  (Detail)::codeGrp=[" + codeGrp + "], code_val=[" + code_val + "]", "Error");
                logs.SaveLog("[error]  (page)::FrmCodeTMainDB.cs  (Function)::SetDataBind_gridView1  (Detail)::reMsg=[" + reMsg + "]", "Error");
                logs.SaveLog("[error]  (page)::FrmCodeTMainDB.cs  (Function)::SetDataBind_gridView1  (Detail):: " + "\r\n" + ex.ToString(), "Error");
            }
            finally
            {
                if (wSvc != null)
                {
                    wSvc.Dispose();
                }
            }
        }