コード例 #1
0
ファイル: Condition.xaml.cs プロジェクト: mercaditu/ERP
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
     {
         if (!isExternalCall)
         {
             stackFields.DataContext = conditionViewSource;
         }
         else
         {
             MainViewSource.View.MoveCurrentTo(curObject);
             if (operationMode == Class.clsCommon.Mode.Add)
             {
                 entity.app_condition newCondition = new entity.app_condition();
                 mydb.db.app_condition.Add(newCondition);
                 myViewSource.Source = mydb.db.app_condition.Local;
                 myViewSource.View.Refresh();
                 myViewSource.View.MoveCurrentTo(newCondition);
                 stackFields.DataContext = myViewSource;
                 btnDelete.Visibility    = System.Windows.Visibility.Collapsed;
             }
             else if (operationMode == Class.clsCommon.Mode.Edit)
             {
                 conditionViewSource.View.MoveCurrentTo(app_conditionobject);
                 stackFields.DataContext = conditionViewSource;
             }
         }
     }
 }
コード例 #2
0
ファイル: Condition.xaml.cs プロジェクト: mercaditu/ERP
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!isExternalCall)
                {
                    IEnumerable <DbEntityValidationResult> validationresult = entity.db.GetValidationErrors();
                    if (validationresult.Count() == 0)
                    {
                        entity.db.SaveChanges();
                        btnCancel_Click(sender, e);
                    }
                }
                else
                {
                    IEnumerable <DbEntityValidationResult> validationresult = mydb.db.GetValidationErrors();
                    if (validationresult.Count() == 0)
                    {
                        if (operationMode == Class.clsCommon.Mode.Add)
                        {
                            mydb.SaveChanges();
                            entity.app_condition app_condition = myViewSource.View.CurrentItem as entity.app_condition;
                            mydb.db.Entry(app_condition).State = EntityState.Detached;
                            _entity.db.app_condition.Attach(app_condition);
                            conditionViewSource.View.Refresh();
                            conditionViewSource.View.MoveCurrentTo(app_condition);
                            MainViewSource.View.Refresh();
                            MainViewSource.View.MoveCurrentTo(curObject);
                            btnCancel_Click(sender, e);
                        }
                        else if (operationMode == Class.clsCommon.Mode.Edit)
                        {
                            btnCancel_Click(sender, e);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            CurrentSession.Load_BasicData();
        }
コード例 #3
0
ファイル: SalesInvoiceDB.cs プロジェクト: mercaditu/ERP
        public sales_invoice New(int TransDate_OffSet, bool IsMigration)
        {
            sales_invoice sales_invoice = new sales_invoice();

            sales_invoice.State      = EntityState.Added;
            sales_invoice.status     = Status.Documents_General.Pending;
            sales_invoice.IsSelected = true;
            sales_invoice.trans_type = Status.TransactionTypes.Normal;
            sales_invoice.trans_date = DateTime.Now.AddDays(TransDate_OffSet);
            sales_invoice.timestamp  = DateTime.Now;

            //Navigation Properties
            sales_invoice.id_currencyfx = Brillo.Currency.get_DefaultFX(this).id_currencyfx;

            sales_invoice.app_branch = app_branch.Where(x => x.id_branch == CurrentSession.Id_Branch).FirstOrDefault();

            //This is to skip query code in case of Migration. Helps speed up migrations.
            if (IsMigration == false)
            {
                app_document_range app_document_range = entity.Brillo.Logic.Range.List_Range(this, entity.App.Names.SalesInvoice, CurrentSession.Id_Branch, CurrentSession.Id_Terminal).FirstOrDefault();
                if (app_document_range != null)
                {
                    //Gets List of Ranges avaiable for this Document.
                    sales_invoice.id_range = app_document_range.id_range;
                }

                app_contract _app_contract = app_contract.Where(x => x.is_active && x.id_company == CurrentSession.Id_Company && x.is_default && x.app_contract_detail.Sum(y => y.coefficient) > 0).FirstOrDefault();
                if (_app_contract != null)
                {
                    app_condition _app_condition = _app_contract.app_condition;
                    if (_app_condition != null)
                    {
                        sales_invoice.app_condition = _app_condition;
                        sales_invoice.app_contract  = _app_contract;
                    }
                }
            }

            return(sales_invoice);
        }