Exemple #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!ValidateMandatoryFields())
            {
                return;
            }

            var existingProduct = uowBatch.Repository.GetAll().Where(p => p.BatchCode == txtBatchCode.Text.Trim()).FirstOrDefault();

            if (existingProduct != null)
            {
                CommonMessageHelper.DataAlreadyExist(txtBatchCode.Text.Trim());
            }
            else
            {
                var batchToAdd = new Batch
                {
                    BatchCode   = txtBatchCode.Text.Trim(),
                    ProductId   = cbProductCode.SelectedValue.ToString(),
                    Quantity    = Convert.ToInt32(txtQuantity.Text.Trim()),
                    EntryDate   = DateTime.Parse(dtpEntryDate.Value.ToString("yyyy-MM-dd")),
                    ExpiredDate = DateTime.Parse(dtpExpiredDate.Value.ToString("yyyy-MM-dd")),

                    // Audit Fields
                    CreatedBy  = Properties.Settings.Default.CurrentUserId,
                    CreatedAt  = DateTime.Now,
                    ModifiedBy = Properties.Settings.Default.CurrentUserId,
                    ModifiedAt = DateTime.Now
                };
                uowBatch.Repository.Add(batchToAdd);
                uowBatch.Commit();
                btnReload.PerformClick();
                CommonMessageHelper.DataSavedSuccessfully();
            }
        }
Exemple #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!ValidateMandatoryFields())
            {
                return;
            }

            var existingTop = uowTop.Repository.GetAll().Where(t => t.TermCode == txtTermCode.Text.Trim()).FirstOrDefault();

            if (existingTop != null)
            {
                CommonMessageHelper.DataAlreadyExist(txtTermCode.Text.Trim());
            }
            else
            {
                var topToAdd = new TermOfPayment
                {
                    TermCode    = txtTermCode.Text.Trim(),
                    Description = txtDescription.Text.Trim(),

                    // Audit Fields
                    CreatedBy  = Properties.Settings.Default.CurrentUserId,
                    CreatedAt  = DateTime.Now,
                    ModifiedBy = Properties.Settings.Default.CurrentUserId,
                    ModifiedAt = DateTime.Now
                };
                uowTop.Repository.Add(topToAdd);
                uowTop.Commit();
                btnReload.PerformClick();
                CommonMessageHelper.DataSavedSuccessfully();
            }
        }
Exemple #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!ValidateMandatoryFields())
            {
                return;
            }
            var existingUom = uowUom.Repository.GetAll().Where(u => u.UomCode == txtUomCode.Text.Trim()).FirstOrDefault();

            if (existingUom != null)
            {
                CommonMessageHelper.DataAlreadyExist(txtUomCode.Text.Trim());
            }
            else
            {
                var uomToAdd = new UnitOfMeasurement
                {
                    UomCode     = txtUomCode.Text.Trim(),
                    Description = txtUomDesc.Text.Trim(),

                    // Audit Fields
                    CreatedBy  = Properties.Settings.Default.CurrentUserId,
                    CreatedAt  = DateTime.Now,
                    ModifiedBy = Properties.Settings.Default.CurrentUserId,
                    ModifiedAt = DateTime.Now
                };
                uowUom.Repository.Add(uomToAdd);
                uowUom.Commit();
                btnReload.PerformClick();
                CommonMessageHelper.DataSavedSuccessfully();
            }
        }
Exemple #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!ValidateMandatoryFields())
            {
                return;
            }
            var existingRole = uowArea.Repository.GetAll().Where(r => r.AreaCode == txtAreaCode.Text.Trim()).FirstOrDefault();

            if (existingRole != null)
            {
                CommonMessageHelper.DataAlreadyExist(txtAreaCode.Text.Trim());
            }
            else
            {
                var areaToAdd = new SalesArea
                {
                    AreaCode         = txtAreaCode.Text.Trim(),
                    Description      = txtDescription.Text.Trim(),
                    RepresentativeId = cbRepresentative.SelectedValue.ToString(),

                    // Audit Fields
                    CreatedBy  = Properties.Settings.Default.CurrentUserId,
                    CreatedAt  = DateTime.Now,
                    ModifiedBy = Properties.Settings.Default.CurrentUserId,
                    ModifiedAt = DateTime.Now
                };
                uowArea.Repository.Add(areaToAdd);
                uowArea.Commit();
                isAdd = true;
                btnReload.PerformClick();
                CommonMessageHelper.DataSavedSuccessfully();
            }
        }
Exemple #5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!ValidateMandatoryFields())
            {
                return;
            }
            var existingCust = uowCust.Repository.GetAll()
                               .Where(r => r.CustomerCode == txtCustomerCode.Text.Trim() &&
                                      r.Address == txtAddress.Text.Trim())
                               .FirstOrDefault();

            if (existingCust != null)
            {
                CommonMessageHelper.DataAlreadyExist(txtCustomerCode.Text.Trim() + " dengan alamat " + txtAddress.Text.Trim());
            }
            else
            {
                var custToAdd = new Customer
                {
                    CustomerCode    = txtCustomerCode.Text.Trim(),
                    CustomerName    = txtCustomerName.Text.Trim(),
                    Address         = txtAddress.Text.Trim(),
                    ProvinceId      = cbProvince.SelectedValue.ToString(),
                    DistrictId      = cbDistrict.SelectedValue.ToString(),
                    PostalCode      = txtPostCode.Text.Trim(),
                    Phone           = txtPhone.Text.Trim(),
                    Email           = txtEmail.Text.Trim(),
                    Npwp            = txtNpwp.Text.Trim(),
                    PharmacistName  = txtPharmacistName.Text.Trim(),
                    SipaNo          = txtSipaNo.Text.Trim(),
                    SipaExpiredDate = DateTime.Parse(dtpSipaExpiredDate.Value.ToString("yyyy-MM-dd")),
                    SiaNo           = txtSiaNo.Text.Trim(),
                    OutletTypeId    = cbOutletType.SelectedValue.ToString(),
                    SalesAreaId     = cbSalesArea.SelectedValue.ToString(),


                    // Audit Fields
                    CreatedBy  = Properties.Settings.Default.CurrentUserId,
                    CreatedAt  = DateTime.Now,
                    ModifiedBy = Properties.Settings.Default.CurrentUserId,
                    ModifiedAt = DateTime.Now
                };
                uowCust.Repository.Add(custToAdd);
                uowCust.Commit();
                isAdd = false;
                cbSalesArea.Enabled = isAdd;
                btnReload.PerformClick();
                CommonMessageHelper.DataSavedSuccessfully();
            }
        }
Exemple #6
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!ValidateMandatoryFields())
            {
                return;
            }
            var existingRole = uowRole.Repository.GetAll().Where(r => r.RoleCode == txtRoleCode.Text.Trim()).FirstOrDefault();

            if (existingRole != null)
            {
                CommonMessageHelper.DataAlreadyExist(txtRoleCode.Text.Trim());
            }
            else
            {
                using (var dbContextTransaction = dbContext.Database.BeginTransaction())
                {
                    var roleToAdd = new Role
                    {
                        RoleCode    = txtRoleCode.Text.Trim(),
                        Description = txtDescription.Text.Trim(),

                        // Audit Fields
                        CreatedBy  = Properties.Settings.Default.CurrentUserId,
                        CreatedAt  = DateTime.Now,
                        ModifiedBy = Properties.Settings.Default.CurrentUserId,
                        ModifiedAt = DateTime.Now
                    };
                    var uwRole = new UnitOfWork <Role>(dbContext);
                    uwRole.Repository.Add(roleToAdd);
                    uwRole.Commit();

                    var permRolesToAdd = GetSelectedRolePermisions(roleToAdd.Id);
                    var uwPermRole     = new UnitOfWork <PermissionRole>(dbContext);
                    uwPermRole.Repository.Add(permRolesToAdd);
                    uwPermRole.Commit();

                    dbContextTransaction.Commit();
                }


                btnReload.PerformClick();
                CommonMessageHelper.DataSavedSuccessfully();
            }
        }
Exemple #7
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!ValidateMandatoryFields())
            {
                return;
            }
            var productCode     = GetCurrentProductCode();
            var existingProduct = uowProduct.Repository.GetAll().Where(p => p.ProductCode == productCode).FirstOrDefault();

            if (existingProduct != null)
            {
                CommonMessageHelper.DataAlreadyExist(GetCurrentProductCode());
            }
            else
            {
                var prodToAdd = new Product
                {
                    ProductCode     = GetCurrentProductCode(),
                    ProductName     = txtProductName.Text.Trim(),
                    Price           = decimal.Parse(txtPrice.Text.Trim(), System.Globalization.NumberStyles.Currency),
                    PriceDecreeDate = DateTime.Parse(dtpDecreeDate.Value.ToString("yyyy-MM-dd")),
                    Discount        = float.Parse(txtDiscount.Text.Trim()),
                    RestockLevel    = Convert.ToInt32(txtRestock.Text.Trim()),
                    UnitId          = cbUom.SelectedValue.ToString(),
                    MedicineCatId   = cbMedCat.SelectedValue.ToString(),
                    UsageTypeId     = cbUsageType.SelectedValue.ToString(),
                    PrincipalId     = cbPrincipal.SelectedValue.ToString(),

                    // Audit Fields
                    CreatedBy  = Properties.Settings.Default.CurrentUserId,
                    CreatedAt  = DateTime.Now,
                    ModifiedBy = Properties.Settings.Default.CurrentUserId,
                    ModifiedAt = DateTime.Now
                };
                uowProduct.Repository.Add(prodToAdd);
                uowProduct.Commit();
                btnReload.PerformClick();
                CommonMessageHelper.DataSavedSuccessfully();
            }
        }
Exemple #8
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!ValidateMandatoryFields())
            {
                return;
            }
            var existingSalesman = uowSalesman.Repository.GetAll().Where(r => r.SalesmanCode == txtSalesmanCode.Text.Trim()).FirstOrDefault();

            if (existingSalesman != null)
            {
                CommonMessageHelper.DataAlreadyExist(txtSalesmanCode.Text.Trim());
            }
            else
            {
                var salesmanToAdd = new Salesman
                {
                    SalesmanCode = txtSalesmanCode.Text.Trim(),
                    FullName     = txtFullName.Text.Trim(),
                    Gender       = rbFemale.Checked ? Constant.Gender.Female : Constant.Gender.Male,
                    Address      = txtAddress.Text.Trim(),
                    PostalCode   = txtPostCode.Text.Trim(),
                    Phone        = txtPhone.Text.Trim(),
                    Email        = txtEmail.Text.Trim(),
                    ProvinceId   = cbProvince.SelectedValue.ToString(),
                    DistrictId   = cbDistrict.SelectedValue.ToString(),

                    // Audit Fields
                    CreatedBy  = Properties.Settings.Default.CurrentUserId,
                    CreatedAt  = DateTime.Now,
                    ModifiedBy = Properties.Settings.Default.CurrentUserId,
                    ModifiedAt = DateTime.Now
                };
                uowSalesman.Repository.Add(salesmanToAdd);
                uowSalesman.Commit();
                btnReload.PerformClick();
                CommonMessageHelper.DataSavedSuccessfully();
            }
        }
Exemple #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!ValidateMandatoryFields())
            {
                return;
            }
            var existingRole = uowUser.Repository.GetAll().Where(u => u.Username == txtUsername.Text.Trim()).FirstOrDefault();

            if (existingRole != null)
            {
                CommonMessageHelper.DataAlreadyExist(txtUsername.Text.Trim());
            }
            else
            {
                using (var dbContextTransaction = dbContext.Database.BeginTransaction())
                {
                    var userToAdd = new User
                    {
                        Username = txtUsername.Text.Trim(),
                        Password = new UserHelper().HashPassword(txtPassword.Text.Trim()),
                        FullName = txtFullName.Text.Trim(),

                        // Audit Fields
                        CreatedBy  = Properties.Settings.Default.CurrentUserId,
                        CreatedAt  = DateTime.Now,
                        ModifiedBy = Properties.Settings.Default.CurrentUserId,
                        ModifiedAt = DateTime.Now
                    };
                    var uowUsr = new UnitOfWork <User>(dbContext);

                    uowUsr.Repository.Add(userToAdd);
                    uowUsr.Commit();

                    var uowUsrRole = new UnitOfWork <UserRole>(dbContext);
                    //var existingUsrRole = uowUsrRole.Repository.GetAll().
                    //    Where(u => u.UserId == txtUserId.Text.Trim() && u.RoleId == txtRoleId.Text.Trim()).FirstOrDefault();
                    //if (existingUsrRole != null)
                    //{
                    //    CommonMessageHelper.DataAlreadyExist(txtUsername.Text.Trim() + " dan " + cbRole.SelectedText);
                    //    return;
                    //}

                    var userRoleToAdd = new UserRole
                    {
                        UserId = userToAdd.Id.ToString().ToUpper(),
                        RoleId = cbRole.SelectedValue.ToString().ToUpper(),

                        // Audit Fields
                        CreatedBy  = Properties.Settings.Default.CurrentUserId,
                        CreatedAt  = DateTime.Now,
                        ModifiedBy = Properties.Settings.Default.CurrentUserId,
                        ModifiedAt = DateTime.Now
                    };
                    uowUsrRole.Repository.Add(userRoleToAdd);
                    uowUsrRole.Commit();

                    dbContextTransaction.Commit();
                }

                btnReload.PerformClick();
                CommonMessageHelper.DataSavedSuccessfully();
                chkChangePassword.Visible = false;
            }
        }