private void button3_Click(object sender, EventArgs e) { decimal costPer = 0; string desc = ""; string quan = ""; FrmKeyboardNumber frmKeyboardNumber = new FrmKeyboardNumber("Số lượng"); if (frmKeyboardNumber.ShowDialog() == DialogResult.OK) { quan = frmKeyboardNumber.value; FrmKeyBoard frmKeyBoard = new FrmKeyBoard(); frmKeyBoard.label1.Text = "Ghi chú"; if (frmKeyBoard.ShowDialog() == DialogResult.OK) { desc = frmKeyBoard.value; FrmKeyboardNumber frmKeyboardNumber1 = new FrmKeyboardNumber("Giá", txtGia.Text); if (frmKeyboardNumber1.ShowDialog() == DialogResult.OK) { costPer = Convert.ToDecimal(frmKeyboardNumber1.value); decimal newCostPer = (Convert.ToDecimal(txtKho.Text) * Convert.ToDecimal(txtGia.Text) + Convert.ToDecimal(quan) * costPer) / (Convert.ToDecimal(txtKho.Text) + Convert.ToDecimal(quan)); decimal sumQuan = Convert.ToDecimal(txtKho.Text) + Convert.ToDecimal(quan); get_service.UpdateInStock(StaticClass.storeId, txtInvenId.Text, sumQuan.ToString()); get_service.UpdateCostPer(StaticClass.storeId, txtInvenId.Text, newCostPer.ToString()); get_service.InsertInventory_In(txtInvenId.Text, StaticClass.storeId, quan, costPer.ToString(), DateTime.Now.ToString(), "True", desc, StaticClass.cashierId); txtKho.Text = String.Format("{0:0.##}", sumQuan); txtGia.Text = String.Format("{0:#,#}", newCostPer); inventory = get_service.GetAllInventory(StaticClass.storeId); } } } }