Exemplo n.º 1
0
        public bool UpdateData(Classhanghoa hh)
        {
            cmd.CommandText = "update tb_sim set TenNhaMang= N'" + hh.Ten + "',SDTSim=N'" + hh.SO + "',Loai=N'" + hh.LOAI + "',DonGia='" + hh.DONGIA + "' where MaSim='" + hh.Ma + "'";

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con.Connection;
            try
            {
                con.OpenConn();
                cmd.ExecuteNonQuery();
                con.CloseConn();
                return(true);
            }
            catch (Exception ex)
            {
                string mex = ex.Message;
                cmd.Dispose();
                con.CloseConn();
            }
            return(false);
        }
Exemplo n.º 2
0
        public bool AddData(Classhanghoa hh)
        {
            DataTable dt = new DataTable();

            cmd.CommandText = "insert into  tb_sim values ('" + hh.Ma + "',N'" + hh.Ten + "',N'" + hh.SO + "',N'" + hh.LOAI + "','" + hh.DONGIA + "')";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = con.Connection;
            try
            {
                con.OpenConn();
                cmd.ExecuteNonQuery();
                con.CloseConn();
                return(true);
            }
            catch (Exception ex)
            {
                string mex = ex.Message;
                cmd.Dispose();
                con.CloseConn();
            }
            return(false);
        }
Exemplo n.º 3
0
        void gandulieu(Classhanghoa hh)
        {
            hh.Ma = txtMaSim.Text.Trim();
            if (cbtenNM.SelectedIndex == 0)
            {
                hh.Ten = "VIETTEL";
            }
            if (cbtenNM.SelectedIndex == 1)
            {
                hh.Ten = "VINA";
            }
            if (cbtenNM.SelectedIndex == 2)
            {
                hh.Ten = "MOBI";
            }


            hh.SO = txtso.Text.Trim();
            if (cbloai.SelectedIndex == 0)
            {
                hh.LOAI   = "Thường";
                hh.DONGIA = int.Parse(txtdongia.Text.Trim());
            }

            if (cbloai.SelectedIndex == 1)
            {
                hh.LOAI   = "Số đẹp";
                hh.DONGIA = int.Parse(txtdongia.Text.Trim()) * (float)3.0;
            }

            if (cbloai.SelectedIndex == 2)
            {
                hh.LOAI   = "Số tứ quý";
                hh.DONGIA = int.Parse(txtdongia.Text.Trim()) * (float)5.0;
            }
            hh.Ten  = cbtenNM.Text.Trim();
            hh.LOAI = cbloai.Text.Trim();
        }
Exemplo n.º 4
0
        private void btnluu_Click(object sender, EventArgs e)
        {
            Classhanghoa hh2 = new Classhanghoa();

            gandulieu(hh2);

            if (txtMaSim.Text == "" || txtso.Text == "" || txtdongia.Text == "" || cbloai.Text == "" || cbtenNM.Text == "")
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (flag == 0)
                {
                    if (hhctrl.AddData(hh2))
                    {
                        MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Thêm không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    if (hhctrl.UpdData(hh2))
                    {
                        MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Sửa không thành công!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                dis_end(false);
                frmhanghoa_Load(sender, e);
            }
        }
Exemplo n.º 5
0
 public bool UpdData(Classhanghoa hh)
 {
     return(hhMod.UpdateData(hh));
 }
Exemplo n.º 6
0
 public bool AddData(Classhanghoa hh)
 {
     return(hhMod.AddData(hh));
 }