//nút sửa (sửa chi tiết phiếu nhập) private void button29_Click(object sender, EventArgs e) { button29.Enabled = false; TONKHO entity = new TONKHO(); tonkhobus bus = new tonkhobus(); entity.STT = Int32.Parse(lblmatonkho.Text); entity.MANHAPHANG = madonnhap; entity.MASP = label53.Text; if (dateTimePicker3.Enabled == false) { } else { entity.NGAYHETHAN = dateTimePicker3.Value.Date; } entity.SOLUONGNHAP = (int)numericUpDown2.Value; entity.DONGIANHAP = common.ktdecimal(textBox10.Text); entity.SOLUONGTON = entity.SOLUONGNHAP - Int32.Parse(lblslxuat.Text); bool update = bus.update(entity); common.successorerror(update); if (update) { thongtindonnhap1dgv.DataSource = bus.findall(madonnhap); thongtindonnhap1dgv.Columns["PHIEUNHAPHANG"].Visible = false; thongtindonnhap1dgv.Columns["SANPHAM"].Visible = false; thongtindonnhap1dgv.Columns["XUATKHOes"].Visible = false; label53.Text = "Mã sản phẩm"; numericUpDown2.Value = 0; textBox10.Clear(); dateTimePicker3.ResetText(); lblmatonkho.Text = "0"; } else { } }
//button sửa private void button22_Click(object sender, EventArgs e) { TONKHO entity = new TONKHO(); tonkhobus bus = new tonkhobus(); entity.STT = Int32.Parse(thongtindonnhapdgv.SelectedCells[0].Value.ToString()); entity.MANHAPHANG = Int32.Parse(thongtindonnhapdgv.SelectedCells[1].Value.ToString()); entity.MASP = masplbl.Text; if (ngayhethan.Enabled == false) { } else { entity.NGAYHETHAN = ngayhethan.Value.Date; } entity.SOLUONGNHAP = (int)soluongnhap.Value; entity.DONGIANHAP = common.ktdecimal(dongianhaptxt.Text); entity.SOLUONGTON = (int)soluongnhap.Value; bool update = bus.update(entity); common.successorerror(update); if (update) { thongtindonnhapdgv.DataSource = bus.find((int)thongtindonnhapdgv.SelectedCells[0].Value); thongtindonnhapdgv.Columns["PHIEUNHAPHANG"].Visible = false; thongtindonnhapdgv.Columns["SANPHAM"].Visible = false; thongtindonnhapdgv.Columns["XUATKHOes"].Visible = false; masplbl.Text = "Mã sản phẩm"; soluongnhap.Value = 0; dongianhaptxt.Clear(); ngayhethan.ResetText(); } else { } }