Example #1
0
        private bool ValidateMandatoryFields()
        {
            if (string.IsNullOrEmpty(txtCustomerCode.Text) || string.IsNullOrEmpty(txtCustomerName.Text) || string.IsNullOrEmpty(txtAddress.Text))
            {
                CommonMessageHelper.DataCannotBeEmpty("Kode, Nama Pelanggan dan Alamat");
                return(false);
            }

            if (cbOutletType.SelectedItem.ToString().Contains("Pilih"))
            {
                CommonMessageHelper.DataCannotBeEmpty("Jenis Outlet");
                return(false);
            }

            if (cbOutletType.Items.Count <= 1 || cbSalesArea.Items.Count <= 1)
            {
                var emptyRefData = cbOutletType.Items.Count <= 1 ? "Jenis Outlet" : "Sales Area";
                CommonMessageHelper.ReferredDataNotSet(emptyRefData);
                return(false);
            }

            var customerCode = txtCustomerCode.Text.Trim();
            var customerName = txtCustomerName.Text.Trim();
            var existingCust = uowCust.Repository.GetAll().FirstOrDefault(c => c.CustomerName == customerName && c.CustomerCode != customerCode);

            if (existingCust != null)
            {
                MessageBox.Show($"Pelanggan dengan nama '{customerName}' sudah ada, silakan gunakan nama pelanggan lain.", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            return(true);
        }
Example #2
0
 private bool ValidateMandatoryFields()
 {
     if (string.IsNullOrEmpty(txtPrincipalCode.Text) || string.IsNullOrEmpty(txtPrincipalName.Text))
     {
         CommonMessageHelper.DataCannotBeEmpty("Kode Principal dan Nama Principal");
         return(false);
     }
     return(true);
 }
Example #3
0
 private bool ValidateMandatoryFields()
 {
     if (string.IsNullOrEmpty(txtTermCode.Text) || string.IsNullOrEmpty(txtDescription.Text))
     {
         CommonMessageHelper.DataCannotBeEmpty("Kode Term dan Keterangan");
         return(false);
     }
     return(true);
 }
Example #4
0
 private bool ValidateMandatoryFields()
 {
     if (string.IsNullOrEmpty(txtRepresentativeCode.Text) || string.IsNullOrEmpty(txtRepresentative.Text))
     {
         CommonMessageHelper.DataCannotBeEmpty("Kode Representative dan Nama Representative");
         return(false);
     }
     return(true);
 }
Example #5
0
 private bool ValidateMandatoryFields()
 {
     if (string.IsNullOrEmpty(txtOutletCode.Text) || string.IsNullOrEmpty(txtOutlet.Text))
     {
         CommonMessageHelper.DataCannotBeEmpty("Kode Outlet dan Jenis Outlet");
         return(false);
     }
     return(true);
 }
Example #6
0
 private bool ValidateMandatoryFields()
 {
     if (string.IsNullOrEmpty(txtUsageTypeCode.Text) || string.IsNullOrEmpty(txtUsageDesc.Text))
     {
         CommonMessageHelper.DataCannotBeEmpty("Kode Pemakaian dan Jenis Pemakaian");
         return(false);
     }
     return(true);
 }
 private bool ValidateMandatoryFields()
 {
     if (string.IsNullOrEmpty(txtMedCatCode.Text) || string.IsNullOrEmpty(txtMedCat.Text))
     {
         CommonMessageHelper.DataCannotBeEmpty("Kode Kategori dan Kategori Obat");
         return(false);
     }
     return(true);
 }
Example #8
0
 private bool ValidateMandatoryFields()
 {
     if (string.IsNullOrEmpty(txtSalesmanCode.Text) || string.IsNullOrEmpty(txtFullName.Text))
     {
         CommonMessageHelper.DataCannotBeEmpty("Kode Sales dan Nama Lengkap");
         return(false);
     }
     return(true);
 }
Example #9
0
        private bool ValidateMandatoryFields()
        {
            if (string.IsNullOrEmpty(txtAreaCode.Text) || string.IsNullOrEmpty(txtDescription.Text))
            {
                CommonMessageHelper.DataCannotBeEmpty("Kode Area dan Keterangan");
                return(false);
            }

            if (cbRepresentative.Items.Count <= 1)
            {
                CommonMessageHelper.ReferredDataNotSet("Perwakilan");
                return(false);
            }
            return(true);
        }
Example #10
0
        private bool ValidateMandatoryFields()
        {
            if (string.IsNullOrEmpty(txtBatchCode.Text) || cbProductCode.Items.Count <= 1)
            {
                CommonMessageHelper.DataCannotBeEmpty("Kode Batch dan Nama Produk");
                return(false);
            }

            if (cbProductCode.Items.Count <= 1)
            {
                var emptyRefData = "Produk";
                CommonMessageHelper.ReferredDataNotSet(emptyRefData);
                return(false);
            }

            return(true);
        }
Example #11
0
        private bool ValidateMandatoryFields()
        {
            if (string.IsNullOrEmpty(txtUsername.Text) ||
                string.IsNullOrEmpty(txtPassword.Text) ||
                string.IsNullOrEmpty(txtFullName.Text))
            {
                CommonMessageHelper.DataCannotBeEmpty("Username, Password dan Nama Lengkap");
                return(false);
            }

            if (cbRole.Items.Count <= 1)
            {
                var emptyRefData = "User Role";
                CommonMessageHelper.ReferredDataNotSet(emptyRefData);
                return(false);
            }
            return(true);
        }
Example #12
0
        private bool ValidateMandatoryFields()
        {
            if (cbCustomer.SelectedValue.ToString() == "0" ||
                cbSalesman.SelectedValue.ToString() == "0" ||
                cbTermOfPayment.SelectedValue.ToString() == "0")
            {
                CommonMessageHelper.DataCannotBeEmpty("Pelanggan, Salesman, dan Term of Payment");
                return(false);
            }

            if (string.IsNullOrEmpty(txtDeliveryAddress.Text) ||
                cbSalesArea.SelectedValue.ToString() == "0" ||
                cbProvince.SelectedValue.ToString() == "0")
            {
                CommonMessageHelper.DataCannotBeEmpty("Alamat, Sales Area, dan Provinsi");
                return(false);
            }

            return(true);
        }
Example #13
0
        private bool ValidateMandatoryFields()
        {
            if (string.IsNullOrEmpty(txtManualCode.Text) || string.IsNullOrEmpty(txtProductName.Text))
            {
                CommonMessageHelper.DataCannotBeEmpty("Kode Produk dan Nama Produk");
                return(false);
            }

            if (cbMedCat.Items.Count <= 1 || cbUsageType.Items.Count <= 1 || cbPrincipal.Items.Count <= 1)
            {
                var emptyRefData = cbMedCat.Items.Count <= 1 ? "Kategori Obat" : (cbUsageType.Items.Count <= 1 ? "Jenis Pemakaian" : (cbPrincipal.Items.Count <= 1 ? "Principal" : "Satuan Unit"));
                CommonMessageHelper.ReferredDataNotSet(emptyRefData);
                return(false);
            }

            if (cbMedCat.SelectedValue.ToString() == "0" || cbUsageType.SelectedValue.ToString() == "0" ||
                cbPrincipal.SelectedValue.ToString() == "0" || cbUom.SelectedValue.ToString() == "0")
            {
                CommonMessageHelper.DataCannotBeEmpty("Satuan Unit, Kategori Obat, Jenis Pemakaian dan Principal");
                return(false);
            }

            if (txtManualCode.Text.Trim().Length != 2)
            {
                MessageBox.Show("Kode Inisial Barang harus 2 karakter", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            var productCode     = string.Concat(txtManualCode.Text.Trim(), txtAutoCode.Text.Trim());
            var productName     = txtProductName.Text.Trim();
            var existingProduct = uowProduct.Repository.GetAll().FirstOrDefault(p => p.ProductName == productName && p.ProductCode != productCode);

            if (existingProduct != null)
            {
                MessageBox.Show($"Produk dengan nama '{productName}' sudah ada, silakan gunakan nama produk lain.", "Informasi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            return(true);
        }
Example #14
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            if (cbProduct.SelectedValue.ToString() == "0")
            {
                CommonMessageHelper.DataCannotBeEmpty("Kode Barang");
                return;
            }

            if (string.IsNullOrEmpty(txtQty.Text.Trim()) || txtQty.Text.Trim() == "0")
            {
                CommonMessageHelper.DataCannotBeEmpty("Qty");
                return;
            }

            UnitOfWork <Product> uowProduct = new UnitOfWork <Product>(dbContext);
            var product = uowProduct.Repository.GetById(cbProduct.SelectedValue.ToString());
            UnitOfWork <Batch> uowBatch = new UnitOfWork <Batch>(dbContext);
            var batch = uowBatch.Repository.GetAll().Where(b => b.BatchCode.Equals(txtBatch.Text.Trim())).FirstOrDefault();
            UnitOfWork <UnitOfMeasurement> uowUom = new UnitOfWork <UnitOfMeasurement>(dbContext);
            var  uom           = uowUom.Repository.GetById(product.UnitId);
            int  rowId         = dgvSalesOrderItem.Rows.Count;
            bool duplicateItem = false;

            // if any existing data, then update
            for (int i = 0; i < dgvSalesOrderItem.Rows.Count; ++i)
            {
                if (dgvSalesOrderItem.Rows[i].Cells["productId"].Value == null)
                {
                    continue;
                }

                if (dgvSalesOrderItem.Rows[i].Cells["productId"].Value.ToString() == cbProduct.SelectedValue.ToString() &&
                    (dgvSalesOrderItem.Rows[i].Cells["batchCode"].Value.ToString() == txtBatch.Text.Trim() || string.IsNullOrEmpty(dgvSalesOrderItem.Rows[i].Cells["batchId"].Value.ToString())) &&
                    commonHelper.GetEndOfMonth(DateTime.Parse(dgvSalesOrderItem.Rows[i].Cells["expDate"].Value.ToString())) == commonHelper.GetEndOfMonth(dtpExpiredDate.Value))
                {
                    rowId         = i;
                    duplicateItem = true;
                    break;
                }
            }

            if (!duplicateItem)
            {
                rowId = dgvSalesOrderItem.Rows.Add();
            }

            DataGridViewRow row = dgvSalesOrderItem.Rows[rowId];

            // Add the data
            var qty                = Convert.ToDecimal(txtQty.Text.Trim());
            var nettPrice          = Convert.ToDecimal(txtPrice.Text.Trim());
            var discountPercentage = Math.Round(Convert.ToDecimal(ValidateDiscount(txtDiscount.Text.Trim())) / 100, 5, MidpointRounding.AwayFromZero);
            var taxBaseAmount      = salesOrderHelper.CalculateTaxBaseAmount(qty, nettPrice, discountPercentage);

            row.Cells["productId"].Value   = product.Id;
            row.Cells["productCode"].Value = product.ProductCode;
            row.Cells["productName"].Value = product.ProductName;
            row.Cells["batchId"].Value     = batch != null ? batch.Id : string.Empty;
            row.Cells["batchCode"].Value   = txtBatch.Text.Trim();
            row.Cells["expDate"].Value     = commonHelper.GetEndOfMonth(dtpExpiredDate.Value).ToString("MM/yyyy");
            row.Cells["qty"].Value         = string.Format("{0:n0}", qty);
            row.Cells["uomId"].Value       = uom.Id;
            row.Cells["uomCode"].Value     = uom.UomCode;
            row.Cells["price"].Value       = string.Format("{0:n0}", nettPrice);
            row.Cells["discPercent"].Value = string.Format("{0:n2}", ValidateDiscount(txtDiscount.Text.Trim())) + "%";
            row.Cells["subTotal"].Value    = string.Format("{0:n0}", taxBaseAmount);

            // hidden
            row.Cells["priceReal"].Value = string.Format("{0:n10}", nettPrice);;

            SetTotalSalesOrder();

            // reset back the add item
            cbProduct.SelectedValue = "0";
            txtBatch.Text           = string.Empty;
            dtpExpiredDate.Value    = DateTime.Today;
            txtQty.Text             = "0";
            txtPrice.Text           = "0";
            txtDiscount.Text        = "0";
            cbProduct.Focus();
        }