Esempio n. 1
0
        /// <summary>
        /// 図番をマスターに登録されていない場合
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtBUHIN_Leave(object sender, EventArgs e)
        {
            if (getFlag)
            {
                return;
            }
            if (txtBUHIN.Text == "")
            {
                return;
            }
            if (txtBUHIN.Text.Length < 3)
            {
                return;
            }

            ///富士宮サーバーに製品図番を登録されていない場合
            ///小田原サーバーで製品情報を取得する
            if (txtSEIHIN.Text == "" || txtSEIHIN.Text == null)
            {
                getFlag = true;
                DataTable dtResult   = new DataTable();
                string    ConString2 = "Data Source=" + Properties.Settings.Default.OTAServer + ";Initial Catalog=TESC;Persist Security Info=True;User ID=TESCWIN;";
                using (SqlConnection con = new SqlConnection(ConString2))
                {
                    SqlCommand cmd = new SqlCommand("SELECT RTRIM(M0100A.ZUBAN) ZUBAN,RTRIM(M0100A.NAME) NAME,M0100A.KISYU,M0100A.TANKA,RTRIM(M0100B.ZUBAN) BUHIN,M0100A.ZAIKB " +
                                                    "FROM M0100 M0100A " +
                                                    "LEFT JOIN M0120 M0120 ON M0100A.ZAICD = M0120.ZAICD " +
                                                    "INNER JOIN M0100 M0100B ON M0120.KABUH = M0100B.ZAICD " +
                                                    "WHERE M0100B.ZUBAN ='" + txtBUHIN.Text + "'", con);
                    con.Open();
                    SqlDataAdapter ada = new SqlDataAdapter(cmd);
                    dtResult = new DataTable();
                    ada.Fill(dtResult);
                    Clipboard.SetText(cmd.CommandText);
                    con.Close();
                }


                if (dtResult.Rows.Count == 0)
                {
                    getFlag = false;
                    return;
                }
                if (dtResult.Rows.Count == 1)
                {
                    txtSEIHIN.Text = dtResult.Rows[0][0].ToString();
                    currentSeihin  = dtResult.Rows[0][0].ToString();
                    txtSNAME.Text  = dtResult.Rows[0][1].ToString();
                    txtKISYU.Text  = dtResult.Rows[0][2].ToString();
                    txtTANKA.Text  = dtResult.Rows[0][3].ToString();
                    getFlag        = false;
                    return;
                }
                getFlag = false;

                if (Application.OpenForms.Cast <Form>().Any(form => form.Name == "図番マスター"))
                {
                    seihinForm = (図番マスター)Application.OpenForms["図番マスター"];
                }
                else
                {
                    seihinForm = new 図番マスター();
                }

                var UniqueRows = dtResult.AsEnumerable().Distinct(DataRowComparer.Default);
                seihinForm.dtValue = UniqueRows.CopyToDataTable();
                seihinForm.reloadDT();
                seihinForm.Show();
            }

            checkOK();
        }
Esempio n. 2
0
        /// <summary>
        /// 部品図番をに入力する
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtBUHIN_TextChanged(object sender, EventArgs e)
        {
            if (getFlag)
            {
                return;
            }
            if (SEIFlag)
            {
                return;
            }

            //if (txtBUHIN.Text.Length < 3) return;

            if (cbxTOKCD.Text != "001")
            {
                return;
            }

            BUFlag = true;
            if (txtBUHIN.Text == "" || txtBUHIN.Text == null  || txtBUHIN.Text.Length < 3)
            {
                txtSEIHIN.Text = "";
                txtSNAME.Text  = "";
                txtTANKA.Text  = "";
                txtKISYU.Text  = "";
                lblzuban.Text  = "";
                if (Application.OpenForms.Cast <Form>().Any(form => form.Name == "図番マスター"))
                {
                    if (Application.OpenForms["図番マスター"].Visible)
                    {
                        Application.OpenForms["図番マスター"].Hide();
                    }
                }
                BUFlag = false;
                return;
            }

            ///製品図番の確認
            DataTable dtResult  = new DataTable();
            string    ConString = "Data Source=" + Properties.Settings.Default.FUJIServer + ";Initial Catalog=TESC;Persist Security Info=True;User ID=TESCWIN;";

            using (SqlConnection con = new SqlConnection(ConString))
            {
                SqlCommand cmd = new SqlCommand("SELECT RTRIM(M0100A.ZUBAN) ZUBAN,RTRIM(M0100A.NAME) NAME,M0100A.KISYU,M0100A.TANKA, RTRIM(M0100B.ZUBAN) BUHIN " +
                                                "FROM M0100 M0100A " +
                                                "LEFT JOIN M0120 M0120 ON M0100A.ZAICD = M0120.ZAICD " +
                                                "INNER JOIN M0100 M0100B ON M0120.KABUH = M0100B.ZAICD " +
                                                "WHERE M0100B.ZUBAN ='" + txtBUHIN.Text + "'", con);
                con.Open();
                SqlDataAdapter ada = new SqlDataAdapter(cmd);
                dtResult = new DataTable();
                ada.Fill(dtResult);
                con.Close();
            }

            if (dtResult.Rows.Count == 0)
            {
                txtSNAME.Text  = "";
                txtTANKA.Text  = "";
                txtKISYU.Text  = "";
                txtSEIHIN.Text = "";
                lblzuban.Text  = "*図番をマスターに登録されていません。";
            }
            else if (dtResult.Rows.Count == 1)
            {
                lblzuban.Text  = "";
                txtSEIHIN.Text = dtResult.Rows[0][0].ToString();
                currentSeihin  = dtResult.Rows[0][0].ToString();
                txtSNAME.Text  = dtResult.Rows[0][1].ToString();
                txtKISYU.Text  = dtResult.Rows[0][2].ToString();
                txtTANKA.Text  = dtResult.Rows[0][3].ToString();
            }
            else
            {
                lblzuban.Text  = "";
                txtSNAME.Text  = "";
                txtTANKA.Text  = "";
                txtKISYU.Text  = "";
                txtSEIHIN.Text = "";
                if (Application.OpenForms.Cast <Form>().Any(form => form.Name == "図番マスター"))
                {
                    seihinForm = (図番マスター)Application.OpenForms["図番マスター"];
                }
                else
                {
                    seihinForm = new 図番マスター();
                }

                var UniqueRows = dtResult.AsEnumerable().Distinct(DataRowComparer.Default);
                seihinForm.dtValue = UniqueRows.CopyToDataTable();
                seihinForm.reloadDT();
                seihinForm.Show();
            }
            BUFlag = false;

            checkOK();
        }