Esempio n. 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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }