Beispiel #1
0
        private void chooseMemberNameData()
        {
            MembersScData msds = FormMembersList.ReceiveItems(msd);

            if (msds == null)
            {
                return;
            }
            textBoxMemberCode.Text = msds.MemberCode;
        }
Beispiel #2
0
        /// <summary>
        /// データグリッドビュー変更処理
        /// </summary>
        /// <param name="TargetPoint"></param>
        private void DataGridViewChange(Point TargetPoint)
        {
            DataGridViewRow TargetdgvRow = this.dataGridViewList.Rows[TargetPoint.Y];

            switch (TargetPoint.X)
            {
            // Wakamatsu 20170302
            case 2:                 // 原価コード
                if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I")
                {
                    TargetdgvRow.Cells[2].Value = CostKey.CostCodeH + CostKey.CostCodeNum;
                    TargetdgvRow.Dispose();
                    return;
                }

                // 入力確認
                string CheckCodeU  = Convert.ToString(TargetdgvRow.Cells[2].Value).ToUpper();
                string CheckResult = CostCodeCheck(CheckCodeU, TargetPoint.Y);
                if (CheckResult != "")
                {
                    MessageBox.Show(CheckResult);
                    TargetdgvRow.Cells[2].Value = CostKey.CostCodeH + CostKey.CostCodeNum;
                    TargetdgvRow.Dispose();
                    return;
                }

                TargetdgvRow.Cells[1].Value = CheckCodeU.Substring(0, 1);
                TargetdgvRow.Cells[2].Value = CheckCodeU;
                string CheckCodeH = "";

                if (CostKey.CostCodeH == "A" || CostKey.CostCodeH == "B")
                {
                    if (CostKey.CostCodeH == "A")
                    {
                        CheckCodeH = "B";
                    }
                    else
                    {
                        CheckCodeH = "A";
                    }

                    if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A" || Convert.ToString(TargetdgvRow.Cells[1].Value) == "B")
                    {
                        // 変更前も変更後も原価コードの先頭文字列が"A"または"B"の場合
                        for (int i = 0; i < this.dataGridViewList.Rows.Count; i++)
                        {
                            if (Convert.ToString(this.dataGridViewList.Rows[i].Cells[2].Value) == CheckCodeH + CostKey.CostCodeNum &&
                                Convert.ToString(this.dataGridViewList.Rows[i].Cells[7].Value) == CostKey.MemberCode)
                            {
                                if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A")
                                {
                                    CheckCodeH = "B";
                                }
                                else
                                {
                                    CheckCodeH = "A";
                                }

                                this.dataGridViewList.Rows[i].Cells[1].Value = CheckCodeH;
                                this.dataGridViewList.Rows[i].Cells[2].Value = CheckCodeH + Convert.ToString(TargetdgvRow.Cells[2].Value).Substring(1);
                            }
                        }
                    }
                    else
                    {
                        // 変更前の原価コードの先頭文字列が"A"または"B"で変更後の原価コードの先頭文字列が"A"または"B"でない場合
                        for (int i = 0; i < this.dataGridViewList.Rows.Count; i++)
                        {
                            if (Convert.ToString(this.dataGridViewList.Rows[i].Cells[2].Value) == CheckCodeH + CostKey.CostCodeNum &&
                                Convert.ToString(this.dataGridViewList.Rows[i].Cells[7].Value) == CostKey.MemberCode)
                            {
                                this.dataGridViewList.Rows.RemoveAt(i);
                            }
                        }
                        TargetdgvRow.Cells[7].Value = "";
                    }
                }
                else
                {
                    if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A" || Convert.ToString(TargetdgvRow.Cells[1].Value) == "B")
                    {
                        // 変更前の原価コードの先頭文字列が"A"または"B"でなく変更後の原価コードの先頭文字列が"A"または"B"場合
                        if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A")
                        {
                            CheckCodeH = "B";
                        }
                        else
                        {
                            CheckCodeH = "A";
                        }

                        TargetdgvRow.Cells[3].Value  = "";
                        TargetdgvRow.Cells[6].Value  = CheckDecimal("0");
                        TargetdgvRow.Cells[7].Value  = "";
                        TargetdgvRow.Cells[10].Value = "[原価名称]を入力してください。";
                        this.dataGridViewList.Rows.Insert(TargetPoint.Y + 1);
                        this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[1].Value  = CheckCodeH;
                        this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[2].Value  = CheckCodeH + Convert.ToString(TargetdgvRow.Cells[2].Value).Substring(1);
                        this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[3].Value  = "";
                        this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[6].Value  = CheckDecimal("0");
                        this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[7].Value  = "";
                        this.dataGridViewList.Rows[TargetPoint.Y + 1].Cells[10].Value = "[原価名称]を入力してください。";
                    }
                }

                if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "K")
                {
                    if (Convert.ToString(TargetdgvRow.Cells[3].Value) == "" || Convert.ToString(TargetdgvRow.Cells[3].Value) == CODEL)
                    {
                        TargetdgvRow.Cells[3].Value = CODEK;
                    }
                }
                else if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "L" && Convert.ToString(TargetdgvRow.Cells[3].Value) == "")
                {
                    if (Convert.ToString(TargetdgvRow.Cells[3].Value) == "" || Convert.ToString(TargetdgvRow.Cells[3].Value) == CODEK)
                    {
                        TargetdgvRow.Cells[3].Value = CODEL;
                    }
                }

                break;

            // Wakamatsu 20170302
            case 3:                 // 原価名称
                if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I")
                {
                    TargetdgvRow.Cells[3].Value = CostKey.CostName;
                    TargetdgvRow.Dispose();
                    return;
                }

                if (Convert.ToString(TargetdgvRow.Cells[3].Value) == "")
                {
                    // 社員番号を空欄とする
                    TargetdgvRow.Cells[7].Value = "";
                    if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A" ||
                        Convert.ToString(TargetdgvRow.Cells[1].Value) == "B")
                    {
                        // 対となる原価コード変更
                        PairCostControl("", "");
                    }
                }
                else
                {
                    if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "A" ||
                        Convert.ToString(TargetdgvRow.Cells[1].Value) == "B")
                    {
                        // 原価名称編集後
                        ListFormDataOp lo = new ListFormDataOp();
                        // メンバー取得
                        MembersScData[] msdl = lo.SelectMembersScData(Convert.ToString(TargetdgvRow.Cells[3].Value), 0);
                        MembersScData   msd  = null;
                        if (msdl != null)
                        {
                            msd = FormMembersList.ReceiveItems(msdl);
                        }
                        if (msd == null)
                        {
                            // 選択されなかった場合
                            msd            = new MembersScData();
                            msd.Name       = "";
                            msd.MemberCode = "";
                            TargetdgvRow.Cells[3].Value = msd.Name;
                            TargetdgvRow.Cells[7].Value = msd.MemberCode;
                        }
                        else
                        {
                            // 選択された社員情報を格納
                            TargetdgvRow.Cells[3].Value = msd.Name;
                            TargetdgvRow.Cells[7].Value = msd.MemberCode;

                            string   OverlapCode = "";                  // 重複原価コード格納用
                            string[] OverlapCodeList;                   // 重複原価コード格納用(配列)
                            bool     OverlapFlag = false;               // 重複社員番号フラグ

                            // 選択された場合
                            for (int i = 0; i < this.dataGridViewList.Rows.Count; i++)
                            {
                                if (Convert.ToString(this.dataGridViewList.Rows[i].Cells[1].Value) == "A" ||
                                    Convert.ToString(this.dataGridViewList.Rows[i].Cells[1].Value) == "B")
                                {
                                    // 原価コードが"A"または"B"の場合
                                    if (Convert.ToString(this.dataGridViewList.Rows[i].Cells[7].Value) == msd.MemberCode)
                                    {
                                        // 社員番号が同じ場合
                                        OverlapCode += Convert.ToString(this.dataGridViewList.Rows[i].Cells[2].Value) + ",";
                                    }
                                }
                            }

                            // 社員番号重複確認
                            if (OverlapCode.Length != 0)
                            {
                                // 末尾の","を外す
                                OverlapCode = OverlapCode.Substring(0, OverlapCode.Length - 1);
                            }
                            OverlapCodeList = OverlapCode.Split(',');
                            if (OverlapCodeList.Length == 2)
                            {
                                // 社員番号の重複が2つの場合
                                if (OverlapCodeList[0].Substring(0, 1) == OverlapCodeList[1].Substring(0, 1))
                                {
                                    // 社員番号が重複している行の原価コードの先頭が同じ場合登録不可
                                    OverlapFlag = true;
                                }
                                else if (OverlapCodeList[0].Substring(1) != OverlapCodeList[1].Substring(1))
                                {
                                    // 社員番号が重複している行の原価コードの先頭以外が異なる場合登録不可
                                    OverlapFlag = true;
                                }
                            }
                            else if (OverlapCodeList.Length > 2)
                            {
                                // 社員番号が重複している行が3行以上の場合登録不可
                                OverlapFlag = true;
                            }

                            if (OverlapFlag == true)
                            {
                                MessageBox.Show("原価コード:" + Convert.ToString(TargetdgvRow.Cells[2].Value) + "\r\n" +
                                                "原価名称:" + Convert.ToString(TargetdgvRow.Cells[3].Value) + "\r\n" +
                                                "すでに登録されている社員番号です。");
                                TargetdgvRow.Cells[3].Value = "";
                                TargetdgvRow.Cells[7].Value = "";
                                msd.Name       = "";
                                msd.MemberCode = "";
                            }
                        }

                        if (Convert.ToString(TargetdgvRow.Cells[1].Value) == "B" && msd.Name != "")
                        {
                            TargetdgvRow.Cells[3].Value += CODEB;
                        }

                        // 対となる原価コード変更
                        PairCostControl(msd.Name, msd.MemberCode);
                    }
                }
                // 変更確認
                if (Convert.ToString(TargetdgvRow.Cells[3].Value) != CostKey.CostName)
                {
                    if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I")
                    {
                        TargetdgvRow.Cells[9].Value = "U";
                    }
                }
                break;

            case 4:                 // 細別
                // 変更確認
                if (Convert.ToString(TargetdgvRow.Cells[4].Value) != CostKey.CostDetail)
                {
                    if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I")
                    {
                        TargetdgvRow.Cells[9].Value = "U";
                    }
                }
                break;

            case 5:                 // 単位
                // 変更確認
                if (Convert.ToString(TargetdgvRow.Cells[5].Value) != CostKey.CostUnit)
                {
                    if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I")
                    {
                        TargetdgvRow.Cells[9].Value = "U";
                    }
                }
                break;

            case 6:                 // 原価
                TargetdgvRow.Cells[6].Value = CheckDecimal(Convert.ToString(TargetdgvRow.Cells[6].Value));
                // 変更確認
                if (Convert.ToString(TargetdgvRow.Cells[6].Value) != CostKey.SetCost)
                {
                    if (Convert.ToString(TargetdgvRow.Cells[9].Value) != "I")
                    {
                        TargetdgvRow.Cells[9].Value = "U";
                    }
                }
                break;

            default:                // その他
                break;
            }

            // 入力確認
            InputCheck(TargetPoint.Y);
            TargetdgvRow.Dispose();
        }
Beispiel #3
0
        private void returnValue(DataGridView dgv)
        {
            msds = (MembersScData)msd[dgv.CurrentCellAddress.Y].Clone();

            this.Close();
        }
Beispiel #4
0
        //---------------------------------------------------------------------
        //      Property
        //---------------------------------------------------------------------
        //---------------------------------------------------------------------
        //      Method
        //---------------------------------------------------------------------
        /// <summary>
        /// フォームロード時
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormImpAuthority_Load(object sender, EventArgs e)
        {
            // M_Membersから現職のメンバーを取得する
            MembersScData msd = new MembersScData();
            DataTable     dt  = msd.SelectMembersData();

            if (dt == null)
            {
                return;
            }
            fintMember = dt.Rows.Count;

            MembersScData[] msda = new MembersScData[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                msda[i] = new MembersScData(dt.Rows[i]);
                // データグリッドビューに社員名列を追加
                this.dgvSetting.Columns.Add("Member" + msda[i].MemberCode, msda[i].Name + $"\n({msda[i].MemberCode})");
                this.dgvSetting.Columns[i + 3].ReadOnly = true;
                this.dgvSetting.Columns[i + 3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }

            // M_Authorizationからプログラムを取得
            AuthorizationData ad = new AuthorizationData();

            dt = ad.SelectAuthMaster();
            if (dt == null)
            {
                // 行の追加
                this.dgvSetting.Rows.Add(1);
            }
            else
            {
                // 行の追加
                this.dgvSetting.Rows.Add(dt.Rows.Count);
            }

            UiHandling uih = new UiHandling(this.dgvSetting);

            // ヘッダ背景色設定
            uih.DgvReadyNoRHeader();

            // M_Authorizationのレコードを表示
            string[] strMemberCode;             // 社員番号格納用
            if (dt != null)
            {
                Array.Resize(ref fintCheckNum, Convert.ToInt32(dt.Rows[dt.Rows.Count - 1]["AuthID"]) + 1);

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    // ID
                    this.dgvSetting.Rows[i].Cells[0].Value = Convert.ToString(dt.Rows[i]["AuthID"]);
                    // 使用済みID設定
                    fintCheckNum[Convert.ToInt32(dt.Rows[i]["AuthID"])] = 1;
                    // ラベル
                    this.dgvSetting.Rows[i].Cells[1].Value = Convert.ToString(dt.Rows[i]["ModuleLabel"]);
                    // プログラム
                    this.dgvSetting.Rows[i].Cells[2].Value = Convert.ToString(dt.Rows[i]["ModuleName"]);
                    // 各社員番号設定
                    strMemberCode = Convert.ToString(dt.Rows[i]["AuthMember"]).Split(',');

                    for (int j = 0; j < strMemberCode.Length; j++)
                    {
                        // 登録済み社員番号分繰り返す
                        for (int k = 3; k < fintMember + 3; k++)
                        {
                            // 全社員番号分繰り返す
                            if (this.dgvSetting.Columns[k].Name == "Member" + strMemberCode[j])
                            {
                                this.dgvSetting.Rows[i].Cells[k].Value = "YES";
                            }
                            else if (Convert.ToString(this.dgvSetting.Rows[i].Cells[k].Value) != "YES")
                            {
                                this.dgvSetting.Rows[i].Cells[k].Value = "NO";
                            }
                        }
                    }
                }
            }
            else
            {
                for (int i = 3; i < fintMember + 3; i++)
                {
                    // 社員番号の全設定をNOとする
                    this.dgvSetting.Rows[0].Cells[i].Value = "NO";
                }
            }
        }