Beispiel #1
0
        private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            M_WsCodeTMainDB.WsCodeTMainDB wSvc = null;
            string reCode = "";
            string reMsg  = "";
            string reData = "";

            string colNm = dataGridView2.Columns[e.ColumnIndex].Name;

            if (colNm == "dgv2_BTNADD")
            {
                if (_codeGrp == "1")
                {
                    string reVal = ChkDgv2Param();

                    if (reVal != "")
                    {
                        MessageBox.Show(wRM.GetString("wCheck") + " :: " + reVal);
                    }
                    else
                    {
                        string tCode_val   = dataGridView2.Rows[0].Cells["dgv2_TCODE"].Value.ToString();
                        string tCodeNm_val = dataGridView2.Rows[0].Cells["dgv2_NM"].Value.ToString();

                        string listFlag_val = "0";
                        if (dataGridView2.Rows[0].Cells["dgv2_LIST_FLAG"].Value != null)
                        {
                            listFlag_val = dataGridView2.Rows[0].Cells["dgv2_LIST_FLAG"].Value.ToString();
                        }

                        string requiredFlag_val = "0";
                        if (dataGridView2.Rows[0].Cells["dgv2_REQUIRED_FLAG"].Value != null)
                        {
                            requiredFlag_val = dataGridView2.Rows[0].Cells["dgv2_REQUIRED_FLAG"].Value.ToString();
                        }

                        string numericFlag_val = "0";
                        if (dataGridView2.Rows[0].Cells["dgv2_NUMERIC_FLAG"].Value != null)
                        {
                            numericFlag_val = dataGridView2.Rows[0].Cells["dgv2_NUMERIC_FLAG"].Value.ToString();
                        }

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

                            reCode = wSvc.exCodeT(tCode_val, tCodeNm_val, out reMsg, out reData);
                            if (reCode == "Y" && reData != "0")
                            {
                                MessageBox.Show(msgRM.GetString("msgDuplicated"));
                            }
                            else
                            {
                                reCode = "";
                                reCode = wSvc.aCodeT(tCode_val, _code, tCodeNm_val, listFlag_val, requiredFlag_val, numericFlag_val, AppInfo.SsLabNo, out reMsg, out reData);
                                if (btnSave.Text == wRM.GetString("wApply"))
                                {
                                    string[] param = new string[9];

                                    param[0] = tCode_val;
                                    param[1] = _code;
                                    param[2] = tCodeNm_val;
                                    param[3] = requiredFlag_val;
                                    param[4] = numericFlag_val;
                                    param[5] = listFlag_val;
                                    param[6] = AppInfo.SsLabNo;
                                    param[7] = AppInfo.SsSiteCd;
                                    param[8] = _formCodeTSite.getTgrpCcd();

                                    reCode = wSvc.aCodeTSite(AppInfo.SsDbNm, param, out reMsg, out reData);
                                    _formCodeTSite.Popup_End();
                                }



                                int reCnt = 0;

                                if (reCode == "Y" && reData != "")
                                {
                                    reCnt = Convert.ToInt16(reData);
                                }

                                if (reCnt > 0)
                                {
                                    MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wSuccess") + " : " + reCnt.ToString());
                                }
                                else
                                {
                                    MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wFail"));
                                }

                                SetDataBind_gridView1(_codeGrp, _code);
                            }
                        }
                        catch (Exception ex)
                        {
                            logs.SaveLog("[error]  (page)::FrmCodeTMainDB.cs  (Function)::dataGridView2_CellClick  (Detail):: " + "\r\n" + ex.ToString(), "Error");
                        }
                        finally
                        {
                            if (wSvc != null)
                            {
                                wSvc.Dispose();
                            }
                        }
                    }
                }

                if (_codeGrp == "2")
                {
                    string reVal = ChkDgv2Param();

                    if (reVal != "")
                    {
                        MessageBox.Show(wRM.GetString("wCheck") + " :: " + reVal);
                    }
                    else
                    {
                        string tCode_val    = dataGridView2.Rows[0].Cells["dgv2_TCODE"].Value.ToString();
                        string tscodeNm_val = dataGridView2.Rows[0].Cells["dgv2_NM"].Value.ToString();

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

                            reCode = wSvc.exCodeTSub(tCode_val, tscodeNm_val, out reMsg, out reData);
                            if (reCode == "Y" && reData != "0")
                            {
                                MessageBox.Show(msgRM.GetString("msgDuplicated"));
                            }
                            else
                            {
                                reCode = "";
                                reCode = wSvc.aCodeTSub(tCode_val, tscodeNm_val, "0", AppInfo.SsLabNo, out reMsg, out reData);

                                int reCnt = 0;

                                if (reCode == "Y" && reData != "")
                                {
                                    reCnt = Convert.ToInt16(reData);
                                }

                                if (reCnt > 0)
                                {
                                    MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wSuccess") + " : " + reCnt.ToString());
                                }
                                else
                                {
                                    MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wFail"));
                                }

                                SetDataBind_gridView1(_codeGrp, _code);
                            }
                        }
                        catch (Exception ex)
                        {
                            logs.SaveLog("[error]  (page)::FrmCodeTMainDB.cs  (Function)::dataGridView2_CellClick  (Detail):: " + "\r\n" + ex.ToString(), "Error");
                        }
                        finally
                        {
                            if (wSvc != null)
                            {
                                wSvc.Dispose();
                            }
                        }
                    }
                }
            }
        }