Example #1
0
        public void butLuu_Click(object sender, EventArgs e)
        {
            try
            {
                string aid_nhom = "", acomputer = "";
                if (txtMa.Text.Trim() == "")
                {
                    MessageBox.Show(this,
                                    lan.Change_language_MessageText("Nhập mã số!"), m_v.s_AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtMa.Focus();
                    return;
                }
                if (txtTen.Text.Trim() == "")
                {
                    MessageBox.Show(this,
                                    lan.Change_language_MessageText("Nhập tên loại!"), m_v.s_AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtTen.Focus();
                    return;
                }
                try
                {
                    aid_nhom = cbNhomvp.SelectedValue.ToString();
                }
                catch
                {
                    aid_nhom = "";
                }
                if (aid_nhom.Trim() == "")
                {
                    MessageBox.Show(this,
                                    lan.Change_language_MessageText("Chọn nhóm viện phí tương ứng!"), m_v.s_AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cbNhomvp.Focus();
                    SendKeys.Send("{F4}");
                    return;
                }
                if (txtStt.Text.Trim() == "")
                {
                    txtStt.Text = m_v.f_get_stt_v_loaivp(aid_nhom).ToString();
                }

                if (m_id == "")
                {
                    m_id = m_v.get_id_v_loaivp.ToString();
                }
                else
                {
                    try
                    {
                        if (m_v.dadung_v_loaivp(m_id) == -1)
                        {
                            if (!m_v.is_dba_admin(m_userid))
                            {
                                MessageBox.Show(this,
                                                lan.Change_language_MessageText("Thông tin này chỉ xem, không cho phép cập nhật!") + "\n" +
                                                lan.Change_language_MessageText("Liên hệ vơi quản trị hệ thống để được trợ giúp."), m_v.s_AppName, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                return;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                if (m_v.f_get_v_loaivp("", "", "", txtMa.Text.Trim(), "", "", "").Tables[0].Select("id <> " + m_id).Length > 0)
                {
                    MessageBox.Show(this,
                                    lan.Change_language_MessageText("Mã đã tồn tại, chọn mã số khác!"), m_v.s_AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtMa.Focus();
                    return;
                }
                if (m_v.f_get_v_loaivp("", "", "", "", txtTen.Text.Trim(), "", "").Tables[0].Select("id <> " + m_id).Length > 0)
                {
                    MessageBox.Show(this,
                                    lan.Change_language_MessageText("Tên đã tồn tại, chọn tên khác!"), m_v.s_AppName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtTen.Focus();
                    return;
                }
                m_v.upd_v_loaivp(decimal.Parse(m_id), decimal.Parse(aid_nhom), decimal.Parse(txtStt.Text.Trim()), txtMa.Text, txtTen.Text, txtViettat.Text.Trim(), decimal.Parse(m_userid), acomputer, chkReadonly.Checked ? 1 : 0, acomputer);
                f_Enable(false);
                butMoi.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }