コード例 #1
0
ファイル: SatuanDasarBLL.cs プロジェクト: reyukowpf/alpha
        public bool RemoveSatuanDasar(int id)
        {
            methodName = "RemoveSatuanDasar";
            traceID    = 1;

            using (var uow = new UnitOfWork(AppConfig.Current.ContextName))
            {
                using (var trans = uow.BeginTransaction())
                {
                    try
                    {
                        traceID = 2;
                        SatuanDasar oDBSatuanDasar = uow.SatuanDasar.SingleOrDefault(m => m.Id == id);
                        if (oDBSatuanDasar != null)
                        {
                            traceID = 3;
                            uow.SatuanDasar.Remove(id);
                            uow.Save();
                        }

                        traceID = 5;
                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw new AppException(500, methodName, traceID, ex);
                    }
                }
            }

            return(true);
        }
コード例 #2
0
ファイル: SatuanDasarBLL.cs プロジェクト: reyukowpf/alpha
        public bool EditSatuanDasar(SatuanDasar oData)
        {
            methodName = "EditSatuanDasar";
            traceID    = 1;

            using (var uow = new UnitOfWork(AppConfig.Current.ContextName))
            {
                traceID = 2;
                var oDBData = uow.SatuanDasar.Get(oData.Id);
                if (oDBData != null)
                {
                    using (var trans = uow.BeginTransaction())
                    {
                        try
                        {
                            traceID = 3;
                            oDBData.MapFrom(oData);
                            uow.SatuanDasar.Update(oDBData);
                            uow.Save();

                            traceID = 4;
                            trans.Commit();
                        }
                        catch (Exception ex)
                        {
                            trans.Rollback();
                            throw new AppException(500, methodName, traceID, ex);
                        }
                    }
                }
            }

            return(true);
        }
コード例 #3
0
ファイル: SatuanDasarBLL.cs プロジェクト: reyukowpf/alpha
        public int AddSatuanDasar(SatuanDasar oData)
        {
            methodName = "AddSatuanDasar";
            traceID    = 1;

            using (var uow = new UnitOfWork(AppConfig.Current.ContextName))
            {
                using (var trans = uow.BeginTransaction())
                {
                    try
                    {
                        traceID = 2;
                        SatuanDasar oNewSatuanDasar = new SatuanDasar();
                        oNewSatuanDasar.MapFrom(oData);
                        oNewSatuanDasar = uow.SatuanDasar.Add(oNewSatuanDasar);
                        uow.Save();

                        traceID  = 3;
                        oData.Id = oNewSatuanDasar.Id;
                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw new AppException(500, methodName, traceID, ex);
                    }
                }
            }

            return(oData.Id);
        }
コード例 #4
0
 private void DGMeasurementUnit_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     this.SatuanDasarSelected = null;
     if (DGMeasurementUnit.SelectedItem != null)
     {
         this.SatuanDasarSelected = (SatuanDasar)DGMeasurementUnit.SelectedItem;
     }
 }
コード例 #5
0
        private void ClearForm()
        {
            chkUnitDasar.IsChecked   = false;
            CBTipeUnit.SelectedIndex = -1;
            txtUnitCode.Text         = "";
            txtUnitName.Text         = "";
            txtUnitTotal.Text        = "0";
            txtUnitDetail.Text       = "";
            txtNote.Text             = "";

            this.SatuanDasarSelected = null;
        }
コード例 #6
0
        private void LoadSatuanDasar()
        {
            this.ClearForm();
            if (this.measurementUnitForm != null && this.measurementUnitForm.SatuanDasarSelected != null)
            {
                chkUnitDasar.IsChecked   = this.measurementUnitForm.SatuanDasarSelected.CheckboxUnitDasar;
                CBTipeUnit.SelectedValue = this.measurementUnitForm.SatuanDasarSelected.TipeUnit.GetValueOrDefault(0);
                txtUnitCode.Text         = this.measurementUnitForm.SatuanDasarSelected.KodeSatuan;
                txtUnitName.Text         = this.measurementUnitForm.SatuanDasarSelected.NamaSatuan;
                txtUnitTotal.Text        = this.measurementUnitForm.SatuanDasarSelected.JumlahSatuan.GetValueOrDefault(0).ToString();
                txtUnitDetail.Text       = this.measurementUnitForm.SatuanDasarSelected.DetailSatuan;
                txtNote.Text             = this.measurementUnitForm.SatuanDasarSelected.Keterangan;

                this.SatuanDasarSelected = this.SatuanDasars.Where(m => m.Id == this.measurementUnitForm.SatuanDasarSelected.ParentId.GetValueOrDefault(0)).FirstOrDefault();
            }
        }
コード例 #7
0
 private void Delete_Click(object sender, RoutedEventArgs e)
 {
     if (this.SatuanDasarSelected == null)
     {
         MessageBox.Show("Measurement Unit not selected !");
     }
     else
     {
         SatuanDasarBLL SatuanDasarBLL = new SatuanDasarBLL();
         if (SatuanDasarBLL.RemoveSatuanDasar(this.SatuanDasarSelected.Id) == true)
         {
             MessageBox.Show("Measurement Unit successfully deleted");
             this.LoadSatuanDasar();
             this.SatuanDasarSelected = null;
         }
     }
 }
コード例 #8
0
        private SatuanDasar GetData()
        {
            SatuanDasar oData = new SatuanDasar();

            oData.CheckboxUnitDasar = chkUnitDasar.IsChecked;
            oData.TipeUnit          = int.Parse(CBTipeUnit.SelectedValue.ToString());
            oData.KodeSatuan        = txtUnitCode.Text;
            oData.NamaSatuan        = txtUnitName.Text;
            oData.JumlahSatuan      = double.Parse(txtUnitTotal.Text);
            oData.DetailSatuan      = txtUnitDetail.Text;
            if (this.SatuanDasarSelected != null)
            {
                oData.ParentId = this.SatuanDasarSelected.Id;
            }
            oData.Keterangan = txtNote.Text;
            if (this.measurementUnitForm.SatuanDasarSelected != null)
            {
                oData.Id = this.measurementUnitForm.SatuanDasarSelected.Id;
            }

            return(oData);
        }
コード例 #9
0
 private void ClearForm()
 {
     this.SatuanDasarSelected = null;
 }