Exemplo n.º 1
0
        private void cboMaNL_SelectedIndexChanged(object sender, EventArgs e)
        {
            NguyenLieuNhap ma = (NguyenLieuNhap)nl.timMaNL(cboMaNL.SelectedValue.ToString());

            if (ma != null)
            {
                txtTen.Text    = ma.TenNguyenLieu.ToString();
                txtDonGia.Text = ma.DonGia.ToString();
                cboDVT.Text    = ma.DonViTinh.ToString();
            }
        }
        public decimal getDonGiaByMaNL(string maNL)
        {
            NguyenLieuNhap nl = ql.NguyenLieuNhaps.FirstOrDefault(t => t.MaNguyenLieu.Equals(maNL));

            if (nl != null)
            {
                return((decimal)nl.DonGia);
            }
            else
            {
                return(-1);
            }
        }
Exemplo n.º 3
0
        private void btnTao_Click(object sender, EventArgs e)
        {
            try
            {
                btnTao.Enabled  = false;
                btnThem.Enabled = true;
                cboMaNL.Enabled = false;
                string ma = nl.phatSinhMaTuDong();
                cboMaNL.Text        = ma;
                pTemp               = new NguyenLieuNhap();
                pTemp.MaNguyenLieu  = cboMaNL.Text;
                pTemp.TenNguyenLieu = txtTen.Text;
                pTemp.DonViTinh     = cboDVT.SelectedValue.ToString();

                pTemp.DonGia   = Convert.ToDecimal(txtDonGia.Text.ToString());
                txtTen.Text    = " ";
                txtDonGia.Text = " ";

                txtTen.Focus();
            }catch (Exception ex)
            {
            }
        }
Exemplo n.º 4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            btnTao.Enabled = true;

            try
            {
                DialogResult r = MessageBox.Show("Muốn lưu tất cả?", "Không thể sửa xóa nữa", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (r == DialogResult.Yes)
                {
                    dgvNguyenLieu.Enabled = true;

                    bool kq = nl.them(lstNL);
                    if (kq == true)
                    {
                        btnTao.Enabled = true;
                        btnLuu.Enabled = false;
                        load_cboMaNL();
                        load_dgvNL();
                        pTemp = null;

                        MessageBox.Show("Thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        btnThem.Enabled = false;
                        btnXoa.Enabled  = false;
                        cboMaNL.Enabled = true;
                        lstNL.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Lưu thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }