Beispiel #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Store.IsPeriodClosed)
            {
                MessageBox.Show("Tidak dapat menambah/ubah \n\n Periode : " + Store.GetMonthName(Store.ActiveMonth) + " " + Store.ActiveYear + "\n\n" + "Sudah Tutup Buku", "Perhatian",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                var productQty = productQtyRepository.GetByMonthAndYear(Store.ActiveMonth, Store.ActiveYear, new Guid(lblID.Text));
                if (productQty != null)
                {
                    int qtyBegin = (productQty.QtyBegin - productQty.QtyBegin) + int.Parse(txtQtyBegin.Text);
                    int qtyIn    = productQty.QtyIn;
                    int qtyOut   = (productQty.QtyOut - productQty.QtyPlusCorrection) + productQty.QtyMinusCorrection;

                    lblQtyEnd.Text = ((qtyBegin + qtyIn) - qtyOut).ToString();
                }
                else
                {
                    lblQtyEnd.Text = txtQtyBegin.Text;
                }

                if (Store.IsAdministrator)
                {
                    frmProduct.UpdateProductQty(lblID.Text, lblYear.Text, lblMonth.Text,
                                                txtQtyBegin.Text, txtValueBegin.Text,
                                                lblQtyIn.Text, txtPurchasePrice.Text,
                                                lblQtyAvailable.Text, txtValueAverage.Text, lblValueAvailable.Text,
                                                lblQtyOut.Text, txtSalesPrice.Text,
                                                lblQtyEnd.Text, lblValueEnd.Text,
                                                lblQtyPlusCorrection.Text, lblQtyMinusCorrection.Text,
                                                lblValuePlusCorrection.Text, lblValueMinusCorrection.Text);
                }
                else
                {
                    frmProduct.UpdateProductQty2(lblID.Text, lblYear.Text, lblMonth.Text,
                                                 txtQtyBegin.Text, txtValueBegin.Text,
                                                 lblQtyIn.Text, txtPurchasePrice.Text,
                                                 lblQtyAvailable.Text, txtValueAverage.Text, lblValueAvailable.Text,
                                                 lblQtyOut.Text, txtSalesPrice.Text,
                                                 lblQtyEnd.Text, lblValueEnd.Text,
                                                 lblQtyPlusCorrection.Text, lblQtyMinusCorrection.Text,
                                                 lblValuePlusCorrection.Text, lblValueMinusCorrection.Text);
                }
                this.Close();
            }
        }