コード例 #1
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            string sub_code = AccCodetxt.Text;
            string sub_desc = AccDestxt.Text.ToUpper();
            string s_type   = "";
            string opbal    = OPBALTXT.Text;
            string s_drcr   = "";
            string sname    = "";
            string stype    = "";

            if (!Validator.IsValidString(sub_code))
            {
                GUIutils.ShowMessage("Account code is not valid");
                return;
            }

            if (sub_code.Length != 5)
            {
                GUIutils.ShowMessage("Account code should be five characters");
                return;
            }

            if (SubGroup.IsSubGroup(sub_code))
            {
                GUIutils.ShowMessage("Account Code already exist");
                return;
            }

            if (!Validator.IsValidString(sub_desc))
            {
                GUIutils.ShowMessage("Account description is not valid");
            }

            if (AccTypeCombo.SelectedIndex == -1)
            {
                GUIutils.ShowMessage("Select an account class");
                return;
            }

            sname = AccTypeCombo.SelectedItem.ToString().ToUpper();
            DataTable dt = Group.ListGroup();

            foreach (DataRow r in dt.Rows)
            {
                if (sname == r[1].ToString().ToUpper())
                {
                    s_type = r[0].ToString();
                    break;
                }
            }


            /* if( !(s_type == "ASSET" || s_type == "LIABILITY" ||
             *   s_type == "EXPENSE" || s_type == "INCOME"))
             * {
             *   GUIutils.ShowMessage("Account class should be selected");
             *   return;
             * }*/

            // s_type = s_type.Substring(0, 1);

            if (!Validator.IsValidNumber(opbal))
            {
                GUIutils.ShowMessage("Opening balance should be numeric");
                return;
            }

            decimal s_opbal = Convert.ToDecimal(opbal);

            if (DRCRCombo.SelectedIndex == -1)
            {
                GUIutils.ShowMessage("Select debit or credit");
                return;
            }

            s_drcr = DRCRCombo.SelectedItem.ToString().ToUpper();

            if (!(s_drcr == "DR" || s_drcr == "CR"))
            {
                GUIutils.ShowMessage("select Debit or Credit");
                return;
            }

            SubGroup.AddSubGroup(sub_code, sub_desc, s_type, s_opbal, s_drcr, "T");
        }