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

            M_WsCodeTMainDB.DataCodeTSub[] getData = null;

            //_formCodeT.btnSearch_Click
            try
            {
                wSvc         = new M_WsCodeTMainDB.WsCodeTMainDB();
                wSvc.Url     = "http://" + AppInfo.SsWsvcServer2 + "/WebSvc/Sys/CodeT/WsCodeTMainDB.svc";
                wSvc.Timeout = 1000;
                int reCnt = 0;
                for (int i = 0; i < dataGridView1.Rows.Count; i++)
                {
                    if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value != null)
                    {
                        if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value.ToString() == "1")
                        {
                            reCnt++;
                        }
                    }
                }
                if (reCnt < 1)
                {
                    MessageBox.Show(msgRM.GetString("msgNotSelected"));
                    return;
                }

                reCnt = 0;

                if (btnSave.Text == wRM.GetString("wApply"))
                {
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value != null)
                        {
                            if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value.ToString() == "1")
                            {
                                string[] param = new string[9];

                                param[0] = dataGridView1.Rows[i].Cells["dgv1_TCODE"].Value.ToString();
                                param[1] = dataGridView1.Rows[i].Cells["dgv1_TTYPE_SCD"].Value.ToString();
                                param[2] = dataGridView1.Rows[i].Cells["dgv1_NM"].Value.ToString();
                                param[3] = dataGridView1.Rows[i].Cells["dgv1_REQUIRED_FLAG"].Value.ToString();
                                param[4] = dataGridView1.Rows[i].Cells["dgv1_NUMERIC_FLAG"].Value.ToString();
                                param[5] = dataGridView1.Rows[i].Cells["dgv1_LIST_FLAG"].Value.ToString();
                                param[6] = AppInfo.SsLabNo;
                                param[7] = AppInfo.SsSiteCd;
                                param[8] = _formCodeTSite.getTgrpCcd();

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

                                if (reData == "2")
                                {
                                    MessageBox.Show(msgRM.GetString("msgAlreadyUsed"));
                                    return;
                                }
                                else
                                {
                                    if (dataGridView1.Rows[i].Cells["dgv1_TTYPE_SCD"].Value.ToString() == "Combobox")
                                    {
                                        reCode = wSvc.sCodeTSubTscode(param[0], out getData, out reMsg);
                                        if (reCode == "Y")
                                        {
                                            if (getData != null && getData.Length > 0)
                                            {
                                                for (int j = 0; j < getData.Length; j++)
                                                {
                                                    string[] paramSub = new string[5];

                                                    paramSub[0] = param[0];
                                                    paramSub[1] = getData[j].TSCODE.ToString();
                                                    paramSub[2] = getData[j].TSCODE_NM.ToString();
                                                    paramSub[3] = AppInfo.SsLabNo;
                                                    paramSub[4] = AppInfo.SsSiteCd;

                                                    reCode = wSvc.aCodeTSubSite(AppInfo.SsDbNm, paramSub, out reMsg, out reData);
                                                }
                                            }
                                        }
                                    }
                                    if (reCode == "Y" && reData != "" && reData != "2")
                                    {
                                        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"));
                    }

                    _formCodeTSite.Popup_End();
                    SetDataBind_gridView1(_codeGrp, _code);
                }
                else if (_codeGrp == "1")
                {
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value != null)
                        {
                            if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value.ToString() == "1")
                            {
                                string tcode_val        = dataGridView1.Rows[i].Cells["dgv1_TCODE"].Value.ToString();
                                string listFlag_val     = dataGridView1.Rows[i].Cells["dgv1_LIST_FLAG"].Value.ToString();
                                string requiredFlag_val = dataGridView1.Rows[i].Cells["dgv1_REQUIRED_FLAG"].Value.ToString();
                                string numericFlag_val  = dataGridView1.Rows[i].Cells["dgv1_NUMERIC_FLAG"].Value.ToString();

                                reCode = wSvc.mCodeT(tcode_val, listFlag_val, requiredFlag_val, numericFlag_val, out reMsg, out reData);

                                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)::btnSave_Click  (Detail):: " + "\r\n" + ex.ToString(), "Error");
            }
            finally
            {
                if (wSvc != null)
                {
                    wSvc.Dispose();
                }
            }
        }