/// <summary>
        /// save สร้างใหม่ กรณี ถอนหุ้น Disable เฉพาะ remove sheard
        /// </summary>
        void SaveCommit()
        {
            Member member = new Member();

            member.Code = textBoxCode.Text;
            //if (Singleton.SingletonMember.Instance().Members.FirstOrDefault(w => w.Code == member.Code) != null)
            //{
            //    textBoxCode.SelectAll();
            //    label10.Text = "รหัสสมาชิกซ้ำ";
            //    label10.Visible = true;
            //    return;
            //}
            //label10.Visible = false;
            member.Enable     = true;
            member.Name       = textBoxName.Text;
            member.Address    = textBoxAddress.Text;
            member.CreateDate = DateTime.Now;
            member.CreateBy   = Singleton.SingletonAuthen.Instance().Id;
            member.UpdateDate = DateTime.Now;
            member.UpdateBy   = Singleton.SingletonAuthen.Instance().Id;
            if (radioButtonFemale.Checked == true) //
            {
                member.FKSex = MyConstant.Sex.Female;
            }
            else
            {
                member.FKSex = MyConstant.Sex.male;
            }
            member.TaxId = textBoxTax.Text.Replace("-", "");
            var date = Library.ConvertTHToENDate(textBoxBirthDate.Text);

            if (date == null)
            {
                MessageBox.Show("วันเกิดไม่ถูกต้อง");
                return;
            }
            else
            {
                member.BirthDate = date.Value;
            }
            member.Age = decimal.Parse(textBoxAge.Text);

            if (radioButtonRemove.Checked == true)
            {
                member.IsRemoveShared = true;
            }
            else
            {
                member.IsRemoveShared = false;
            }
            member.Tel = textBoxTel.Text;
            /// มากกว่า 0 ถึง เพิ่ม
            if (this.value > 0)
            {
                MemberShare ms = new MemberShare();
                ms.Enable = true;
                var dateC = Library.ConvertTHToENDate(maskedTextBoxCreateDate.Text);
                if (dateC == null)
                {
                    MessageBox.Show("วันที่เพิ่มหุ้นไม่ถูกต้อง");
                    return;
                }
                ms.CreateDate   = (DateTime)dateC;
                ms.CreateBy     = Singleton.SingletonAuthen.Instance().Id;
                ms.UpdateDate   = DateTime.Now;
                ms.UpdateBy     = Singleton.SingletonAuthen.Instance().Id;
                ms.FKShare      = MyConstant.Shared.General;
                ms.FKBudgetYear = Singleton.SingletonThisBudgetYear.Instance().ThisYear.Id;
                ms.Qty          = value;
                ms.FKAgeOfShare = CheckAgeOfShared(ms.CreateDate);
                // เชค อายุหุ้น
                CheckAgeOfShared(ms.CreateDate);
                member.MemberShare.Add(ms);
            }
            using (SSLsEntities db = new SSLsEntities())
            {
                db.Member.Add(member);
                db.SaveChanges();
                memberNew = new Member();
                string myName = Singleton.SingletonAuthen.Instance().Id;
                memberNew = db.Member.Include("Sex").Include("MemberShare.Share").Include("MemberShare.AgeOfShare")
                            .OrderByDescending(w => w.CreateDate).FirstOrDefault(w => w.CreateBy == myName);
                label10.ForeColor = Color.Red;
                label10.Text      = "* Enter";
                this.value        = 0;
            }
        }
        /// <summary>
        /// Add Member
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("คุณต้องการบันทึกข้อมูล ใช่หรือไม่ ?",
                                              "คำเตือนจากระบบ", MessageBoxButtons.YesNo);

            switch (dr)
            {
            case DialogResult.Yes:
                // แปลว่า add new
                if (textBoxId.Text == "")
                {
                    SaveCommit();
                    reload();
                }
                else
                {
                    // edit
                    using (SSLsEntities db = new SSLsEntities())
                    {
                        int    id     = int.Parse(textBoxId.Text.ToString());
                        Member member = new Member();
                        //member = Singleton.SingletonMember.Instance().Members.SingleOrDefault(w => w.Id == id);
                        member = db.Member.SingleOrDefault(w => w.Id == id);
                        if (radioButtonRemove.Checked == true)
                        {
                            // ถ้าถอนหุ้น วิ่งไปอัพเดท
                            member.IsRemoveShared = true;
                            member.ResignDate     = DateTime.Now;
                            //foreach (var item in member.MemberShare.Where(w => w.Enable == true))
                            //{
                            //    item.UpdateDate = DateTime.Now;
                            //    item.UpdateBy = Singleton.SingletonAuthen.Instance().Id;
                            //    item.Enable = false;
                            //    db.Entry(item).State = EntityState.Modified;
                            //}
                        }
                        else
                        {
                            member.Name       = textBoxName.Text;
                            member.Code       = textBoxCode.Text.Trim();
                            member.CreateDate = (DateTime)Library.ConvertTHToENDate(maskedTextBoxMemberCreate.Text);

                            if (radioButtonFemale.Checked == true)
                            {
                                member.FKSex = MyConstant.Sex.Female;
                            }
                            else
                            {
                                member.FKSex = MyConstant.Sex.male;
                            }
                            member.TaxId = textBoxTax.Text;
                            var date = Library.ConvertTHToENDate(textBoxBirthDate.Text);
                            if (date == null)
                            {
                                MessageBox.Show("วันเกิดไม่ถูกต้อง");
                                return;
                            }
                            else
                            {
                                member.BirthDate = date.Value;
                            }
                            member.Tel     = textBoxTel.Text;
                            member.Age     = decimal.Parse(textBoxAge.Text);
                            member.Address = textBoxAddress.Text;
                            // หุ้นมากกว่า 0 ถึงเพิ่ม
                            if (this.value > 0)
                            {
                                MemberShare ms = new MemberShare();
                                ms.Enable = true;
                                var dateC = Library.ConvertTHToENDate(maskedTextBoxCreateDate.Text);
                                if (dateC == null)
                                {
                                    MessageBox.Show("วันที่เพิ่มหุ้นไม่ถูกต้อง");
                                    return;
                                }
                                ms.CreateDate   = dateC.Value;
                                ms.CreateBy     = Singleton.SingletonAuthen.Instance().Id;
                                ms.UpdateDate   = DateTime.Now;
                                ms.UpdateBy     = Singleton.SingletonAuthen.Instance().Id;
                                ms.FKShare      = MyConstant.Shared.General;
                                ms.FKBudgetYear = Singleton.SingletonThisBudgetYear.Instance().ThisYear.Id;
                                ms.Qty          = value;
                                ms.FKMember     = member.Id;
                                //ms.FKAgeOfShare = this.fkAgeOfShared;
                                ms.FKAgeOfShare = CheckAgeOfShared(ms.CreateDate);
                                db.MemberShare.Add(ms);
                                //db.SaveChanges();
                            }
                            // check edit share
                            for (int i = 0; i < dataGridView2.Rows.Count; i++)
                            {
                                int idShared = int.Parse(dataGridView2.Rows[i].Cells[0].Value.ToString());
                                if (idShared != 0)
                                {
                                    // หุ้น
                                    decimal     shareVal  = decimal.Parse(dataGridView2.Rows[i].Cells[1].Value.ToString());
                                    MemberShare shareEdit = member.MemberShare.SingleOrDefault(w => w.Id == idShared);
                                    if (shareVal < 1)     // ใส่ 0 เพื่อต้องการ ลบ หุ้นออก *Disable
                                    {
                                        shareEdit.Enable     = false;
                                        shareEdit.UpdateDate = DateTime.Now;
                                        shareEdit.UpdateBy   = SingletonAuthen.Instance().Id;
                                    }
                                    else if (shareEdit.Qty != shareVal)
                                    {
                                        // แปลว่าแก้ไข จำนวนหุ้น ให้อัพเดท
                                        shareEdit.Qty        = shareVal;
                                        shareEdit.UpdateDate = DateTime.Now;
                                        shareEdit.UpdateBy   = SingletonAuthen.Instance().Id;
                                    }
                                    db.Entry(shareEdit).State = EntityState.Modified;
                                }
                            }
                        }
                        //db.Member.Attach(member);
                        member.UpdateDate      = DateTime.Now;
                        member.UpdateBy        = Singleton.SingletonAuthen.Instance().Id;
                        db.Entry(member).State = EntityState.Modified;

                        db.SaveChanges();
                        var members = Singleton.SingletonMember.Instance().Members;
                        member = members.SingleOrDefault(w => w.Id == id);
                        members.Remove(member);
                        var lastEditMember = db.Member.Include("Sex").Include("MemberShare.Share").Include("MemberShare.AgeOfShare")
                                             .SingleOrDefault(w => w.Id == member.Id);
                        members.Add(lastEditMember);
                        this.value         = 0;
                        this.fkAgeOfShared = 0;
                        reload();
                    }
                }
                break;

            case DialogResult.No:
                break;
            }
        }