private void bindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            if (!ValidateForm())
            {
                return;
            }

            if (customerGroupIdTextBox.Enabled == true)
            {
                custGroup = new MCustomerGroup();
            }
            else
            {
                custGroup = (MCustomerGroup)DataMaster.GetObjectByProperty(typeof(MCustomerGroup), MCustomerGroup.ColumnNames.CustomerGroupId, customerGroupIdTextBox.Text);
            }

            custGroup.CustomerGroupDesc          = customerGroupDescTextBox.Text;
            custGroup.CustomerGroupId            = customerGroupIdTextBox.Text;
            custGroup.CustomerGroupName          = customerGroupNameTextBox.Text;
            custGroup.CustomerGroupPercentage    = customerGroupPercentageNumericUpDown.Value;
            custGroup.CustomerGroupUsePercentage = customerGroupUsePercentageCheckBox.Checked;

            custGroup.ModifiedBy   = lbl_UserName.Text;
            custGroup.ModifiedDate = DateTime.Now;

            if (customerGroupIdTextBox.Enabled == true)
            {
                try
                {
                    DataMaster.SavePersistence(custGroup);
                }
                catch (NHibernate.NonUniqueObjectException)
                {
                    RecreateBalloon();
                    balloonHelp.Caption = "Validasi data kurang";
                    balloonHelp.Content = "Golongan Pelanggan dengan kode " + customerGroupIdTextBox.Text + " sudah pernah diinput, silahkan input dengan kode yang lain";
                    balloonHelp.ShowBalloon(customerGroupIdTextBox);
                    customerGroupIdTextBox.Focus();
                    return;
                }
                ModuleControlSettings.SaveLog(ListOfAction.Insert, customerGroupIdTextBox.Text, ListOfTable.MCustomerGroup, lbl_UserName.Text);
            }
            else
            {
                DataMaster.UpdatePersistence(custGroup);
                ModuleControlSettings.SaveLog(ListOfAction.Update, customerGroupIdTextBox.Text, ListOfTable.MCustomerGroup, lbl_UserName.Text);
            }


            BindData();
        }
        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(customerGroupIdTextBox.Text.Trim()))
            {
                if (MessageBox.Show("Anda yakin menghapus data?", "Konfirmasi Hapus Data", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    custGroup = (MCustomerGroup)DataMaster.GetObjectByProperty(typeof(MCustomerGroup), MCustomerGroup.ColumnNames.CustomerGroupId, customerGroupIdTextBox.Text);
                    DataMaster.Delete(custGroup);

                    ModuleControlSettings.SaveLog(ListOfAction.Delete, customerGroupIdTextBox.Text, ListOfTable.MCustomerGroup, lbl_UserName.Text);

                    BindData();
                }
            }
        }
Beispiel #3
0
        private void itemIdTextBox_Validating(object sender, CancelEventArgs e)
        {
            if (!string.IsNullOrEmpty(itemIdTextBox.Text.Trim()))
            {
                MItem item = (MItem)DataMaster.GetObjectByProperty(typeof(MItem), MItem.ColumnNames.ItemId, itemIdTextBox.Text);

                if (item != null)
                {
                    itemNameTextBox.Text = item.ItemName;

                    if (trans.Equals(ListOfTransaction.Sales))
                    {
                        if (transactionByNameComboBox.SelectedIndex != -1)
                        {
                            MCustomerGroup custGroup = (MCustomerGroup)DataMaster.GetObjectByProperty(typeof(MCustomerGroup), MCustomerGroup.ColumnNames.CustomerGroupId, transactionByNameComboBox.SelectedValue.ToString());
                            decimal        persen    = 0;
                            if (custGroup != null)
                            {
                                persen = custGroup.CustomerGroupPercentage;
                            }
                            priceNumericUpDown.Value = item.ItemPricePurchase * (1 + (persen / 100));
                        }
                        else
                        {
                            MessageBox.Show("Kategori Pelanggan belum dipilih!", "Error !!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            ResetTransactionDetail();
                            transactionByNameComboBox.Select();
                        }
                    }
                    else if (trans.Equals(ListOfTransaction.Purchase) || trans.Equals(ListOfTransaction.ReturPurchase))
                    {
                        priceNumericUpDown.Value = item.ItemPricePurchase;
                    }

                    //if (!trans.Equals(ListOfTransaction.Correction))
                    //    num_Price.Value = item.ItemPriceMax;
                }
            }
        }