public Form1()
        {
            InitializeComponent();

            //Register Custom Aggregates
            STDEVPCustomAggregate.Register();
            CountDistinctCustomAggregate.Register();

            //Load data with XPView
            XPView xpView = new XPView(session1, typeof(Customer));

            xpView.AddProperty("ContactName", CriteriaOperator.Parse("[FirstName] + ' ' + [LastName]"));
            xpView.AddProperty("DistinctProducts", CriteriaOperator.Parse("[Orders][].CountDistinct([ProductName])"));
            xpView.AddProperty("QuantityVariance", CriteriaOperator.Parse("[Orders][].STDEVP([Quantity])"));
            xpView.AddProperty("PriceVariance", CriteriaOperator.Parse("[Orders][].STDEVP([Price])"));
            xpView.Sorting.Add(new SortProperty("ContactName", DevExpress.Xpo.DB.SortingDirection.Ascending));
            gridControl1.DataSource = xpView;

            //Load data using XPQuery
            gridControl2.DataSource = new XPQuery <Customer>(session1)
                                      .Select(t => new {
                ContactName      = t.ContactName,
                DistinctProducts = (int)CountDistinctCustomAggregate.CountDistinct(t.Orders, o => o.ProductName),
                QuantityVariance = (double?)STDEVPCustomAggregate.STDEVP(t.Orders, o => o.Quantity),
                PriceVariance    = (double?)STDEVPCustomAggregate.STDEVP(t.Orders, o => o.Price),
            })
                                      .OrderBy(t => t.ContactName)
                                      .ToList();
        }
Esempio n. 2
0
        public void CalcularPolizaVigente()
        {
            CalcularVersionesVigentes(typeof(DocumentoItem), typeof(PolizaItem), "PolizaItem", "Documento",
                                      "ItemVigente");
            CalcularVersionesVigentes(typeof(DocumentoInterviniente), typeof(PolizaInterviniente),
                                      "PolizaInterviniente", "Documento", "IntervinienteVigente");
            CalcularVersionesVigentes(typeof(DocumentoIntervinienteItem), typeof(PolizaIntervinienteItem),
                                      "PolizaIntervinienteItem", "DocumentoItem.Documento", "IntervinienteItemVigente");
            CalcularVersionesVigentes(typeof(DocumentoItemDetalle), typeof(PolizaItemDetalle), "PolizaItemDetalle",
                                      "DocumentoItem.Documento", "DetalleVigente");
            CalcularVersionesVigentes(typeof(DocumentoPlan), typeof(PolizaPlan), "PolizaPlan", "Documento",
                                      "PlanVigente");
            CalcularVersionesVigentes(typeof(DocumentoPlanDetalle), typeof(PolizaPlanDetalle), "PolizaPlanDetalle",
                                      "DocumentoPlan.Documento", "DetalleVigente");

            //Calcular fecha
            var v = new XPView(Session, typeof(Documento))
            {
                Criteria = CriteriaOperator.Parse("Poliza = ? AND NOT ISNULL(EmitidaFecha)", this)
            };

            v.AddProperty("MaxVigenciaInicio", CriteriaOperator.Parse("MAX(VigenciaInicio)"));
            v.AddProperty("MaxVigenciaFin", CriteriaOperator.Parse("MAX(VigenciaFin)"));

            foreach (ViewRecord version in v)
            {
                if (version["MaxVigenciaInicio"] != null)
                {
                    VigenciaInicio = (DateTime)version["MaxVigenciaInicio"];
                }
                VigenciaFin = version["MaxVigenciaFin"] as DateTime?;
            }
            Save();
        }
Esempio n. 3
0
        private void CalcularVersionesVigentes(Type tipoObjMovimiento,
                                               Type tipoObjActual,
                                               string propName,
                                               string rutaDocumento,
                                               string propVigente)
        {
            var historial = new Dictionary <int, int>();

            var v = new XPView(Session, tipoObjMovimiento)
            {
                Criteria = CriteriaOperator.Parse($"{rutaDocumento}.Poliza = ? AND NOT ISNULL({propName})", this)
            };

            v.AddProperty(propName, propName, false, true, SortDirection.Ascending);
            v.AddProperty("EmitidaFecha", $"{rutaDocumento}.EmitidaFecha", false, true, SortDirection.Ascending);
            v.AddProperty("NumeroSolicitud", $"{rutaDocumento}.NumeroSolicitud", false, true, SortDirection.Ascending);
            v.AddProperty("Oid", "Oid", false, true, SortDirection.None);

            foreach (ViewRecord version in v)
            {
                var pi = (int)version[0];
                if (!historial.ContainsKey(pi))
                {
                    historial[pi] = -1;
                }
                historial[pi] = (int)version[3];
            }

            foreach (var elemento in historial)
            {
                var pi = (BasicObject)Session.GetObjectByKey(tipoObjActual, elemento.Key);
                pi.SetMemberValue(propVigente, Session.GetObjectByKey(tipoObjMovimiento, elemento.Value));
            }
        }
Esempio n. 4
0
        public ActionResult Index()
        {
            XPView customers = new XPView(new Session(), typeof(Customer));

            customers.AddProperty("Name");
            customers.AddProperty("CompanyName");

            return(View(customers));
        }
        public override void  guardar(object sender, EventArgs e)
        {
            int ln_tipo = 0;

            if (int.TryParse(lookUp_tipo.gridLookUpEdit1.EditValue.ToString().Trim(), out ln_tipo))
            {
                decimal ln_valor = decimal.Zero;
                if (decimal.TryParse(textBox_valor.textEdit1.EditValue.ToString().Trim(), out ln_valor))
                {
                    try
                    {
                        //NumberFormatInfo nfi = new NumberFormatInfo();
                        //nfi.NumberGroupSeparator = ",";
                        //nfi.NumberDecimalSeparator = ".";
                        //ln_valor = decimal.Parse(ln_valor.ToString(nfi));

                        XPView valida_moneda = new XPView(XpoDefault.Session, typeof(Fundraising_PTDM.FUNDRAISING_PT.Denominacion_Monedas));
                        valida_moneda.AddProperty("oid", "oid", false, true, DevExpress.Xpo.SortDirection.None);
                        valida_moneda.AddProperty("codigo", "codigo", false, true, DevExpress.Xpo.SortDirection.None);
                        valida_moneda.AddProperty("tipo", "tipo", false, true, DevExpress.Xpo.SortDirection.None);
                        valida_moneda.AddProperty("valor", "valor", false, true, DevExpress.Xpo.SortDirection.None);
                        valida_moneda.AddProperty("status", "status", false, true, DevExpress.Xpo.SortDirection.None);
                        valida_moneda.Criteria = CriteriaOperator.Parse(string.Format("oid != '{0}' and tipo = {1} and valor = {2} and status = 1", ((Fundraising_PTDM.FUNDRAISING_PT.Denominacion_Monedas)bindingSource1.Current).oid, ln_tipo, ln_valor));
                        //
                        if (valida_moneda != null & valida_moneda.Count > 0)
                        {
                            MessageBox.Show("Ya existe un registro con este Tipo y Denominación, favor cambiar los datos e intentar de nuevo...", "Guardar");
                        }
                        else
                        {
                            ((Fundraising_PTDM.FUNDRAISING_PT.Denominacion_Monedas)this_primary_object_persistent_current).sucursal = 0;  //Fundraising_PT.Properties.Settings.Default.sucursal;
                            if (lAccion == "Insertar")
                            {
                                ((Fundraising_PTDM.FUNDRAISING_PT.Denominacion_Monedas)this_primary_object_persistent_current).status = 1;
                            }
                            base.guardar(sender, e);
                        }
                    }
                    catch (Exception oerror)
                    {
                        MessageBox.Show("Ocurrio un ERROR validando que no existan denominaciones de monedas repetidas..." + "\n" + "Error: " + oerror.Message, "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        base.cancelar(sender, e);
                    }
                }
                else
                {
                    MessageBox.Show("Ocurrio un ERROR evaluando el valor de la denominación de la moneda...", "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    base.cancelar(sender, e);
                }
            }
            else
            {
                MessageBox.Show("Ocurrio un ERROR evaluando el tipo de la denominación de la moneda...", "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Error);
                base.cancelar(sender, e);
            }
        }
        public RandevuAl()
        {
            InitializeComponent();
            dtpRandevuTarih.Anchor = AnchorStyles.Top | AnchorStyles.Right;
            XPView xPView = new XPView(XpoDefault.Session, typeof(Doktor));

            xPView.AddProperty("Concat([Ad],' ' ,[Soyad])");
            xPView.AddProperty("");
            xPView.AddProperty("RandevuAdet", new AggregateOperand("Randevular", "RandevuTarih", Aggregate.Max));
        }
Esempio n. 7
0
        public XPView CalcularSaldosValores( )
        {
            var subtotalesVal = new XPView(Session, typeof(Fondos.ComprobanteItem));

            subtotalesVal.AddProperty("Importe", CriteriaOperator.Parse("SUM(Importe * DebeHaber)"));
            subtotalesVal.AddProperty("Moneda", "Especie.Moneda", true);
            subtotalesVal.Criteria = CriteriaOperator.Parse("Autogenerado = FALSE AND Comprobante = ?", Oid); //recordar que yo (Pago) también es un Comprobante de fondos

            return(subtotalesVal);
        }
Esempio n. 8
0
        public XPView CalcularSaldosAplicaciones( )
        {
            var subtotalesAplic = new XPView(Session, typeof(PagoAplicacion));

            subtotalesAplic.AddProperty("Importe", CriteriaOperator.Parse("SUM(Importe)"));
            subtotalesAplic.AddProperty("Moneda", "Moneda", true);
            subtotalesAplic.Criteria = CriteriaOperator.Parse("Pago = ?", Oid);

            return(subtotalesAplic);
        }
Esempio n. 9
0
        void GroupBuild(Action <IEnumerable <string>, bool> itemsCalculated)
        {
            var xpView = new XPView(((XPObjectSpace)_propertyEditor.View.ObjectSpace).Session, _propertyEditor.MemberInfo.GetOwnerInstance(_propertyEditor.CurrentObject).GetType());

            xpView.AddProperty(_propertyEditor.PropertyName, _propertyEditor.PropertyName, true);
            itemsCalculated.Invoke(xpView.OfType <ViewRecord>().Select(record => record[0]).OfType <string>(), false);
        }
Esempio n. 10
0
        private object GetCustomerTypes()
        {
            XPView view = new XPView(XpoSession, typeof(AdventureWorks.Customer));

            view.AddProperty("CustomerType", "CustomerType", true);
            return(view);
        }
Esempio n. 11
0
 void GroupBuild(Action<IEnumerable<string>, bool> itemsCalculated) {
     if (_propertyEditor.View == null)
         return;
     var xpView = new XPView(((XPObjectSpace)_propertyEditor.View.ObjectSpace).Session, _propertyEditor.MemberInfo.GetOwnerInstance(_propertyEditor.CurrentObject).GetType());
     xpView.AddProperty(_propertyEditor.PropertyName, _propertyEditor.PropertyName, true);
     itemsCalculated.Invoke(xpView.OfType<ViewRecord>().Select(record => record[0]).OfType<string>(), false);
 }
        static void Main()
        {
            ConnectionProviderSql provider =
                (ConnectionProviderSql)XpoDefault.GetConnectionProvider(SQLiteConnectionProvider.GetConnectionString(@"CustomCommand.sqlite"),
                                                                        AutoCreateOption.DatabaseAndSchema);

            provider.RegisterCustomFunctionOperator(new GetMonthFunction());
            XPDictionary dict = new ReflectionDictionary();

            dict.CustomFunctionOperators.Add(new GetMonthFunction());
            XpoDefault.DataLayer = new SimpleDataLayer(dict, provider);
            CreateData();

            using (Session session = new Session()) {
                XPView view = new XPView(session, typeof(Order));
                view.AddProperty("Month", "custom('GetMonth', OrderDate)");

                foreach (ViewRecord prop in view)
                {
                    Console.WriteLine(prop["Month"]);
                }

                var list = from o in new XPQuery <Order>(session)
                           where o.OrderName == "Chai"
                           select new { Month = GetMonthFunction.GetMonth(o.OrderDate) };

                foreach (var item in list)
                {
                    Console.WriteLine(item.Month);
                }
            }
            Console.WriteLine("done\npress any key to exit ..");
            Console.ReadKey();
        }
        static bool valida_fechahora_sesion(DateTime ld_fecha, Fundraising_PTDM.FUNDRAISING_PT.Cajas lo_caja)
        {
            bool   pass_fechahora    = true;
            int    total_minutes_new = (ld_fecha.Hour * 60) + ld_fecha.Minute;
            int    time_new_sesion   = Fundraising_PT.Properties.Settings.Default.time_new_sesion;
            XPView vhora_sesion      = new XPView(XpoDefault.Session, typeof(Fundraising_PTDM.FUNDRAISING_PT.Sesiones));

            vhora_sesion.AddProperty("fecha_hora", "fecha_hora", false, true, DevExpress.Xpo.SortDirection.Descending);
            vhora_sesion.Criteria = CriteriaOperator.Parse(string.Format("GetDay(fecha_hora) = {0} and GetMonth(fecha_hora) = {1} and GetYear(fecha_hora) = {2} and caja.oid = '{3}'", ld_fecha.Day, ld_fecha.Month, ld_fecha.Year, lo_caja.oid));
            //
            if (vhora_sesion.Count > 0)
            {
                int time_diff          = 0;
                int total_minutes_exis = 0;
                foreach (ViewRecord items in vhora_sesion)
                {
                    DateTime fecha_hora = (DateTime)items["fecha_hora"];
                    total_minutes_exis = (fecha_hora.Hour * 60) + fecha_hora.Minute;
                    time_diff          = total_minutes_new - total_minutes_exis;
                    if (time_diff < time_new_sesion)
                    {
                        pass_fechahora = false;
                        break;
                    }
                }
            }
            //
            vhora_sesion.Dispose();
            //
            return(pass_fechahora);
        }
        void textBox_buscacodigointegrado_Validated(object sender, EventArgs e)
        {
            bool sw1 = true;

            if (textBox_buscacodigointegrado.lValue.Trim() != string.Empty)
            {
                //
                XPView vbuscacodigo = new XPView(XpoDefault.Session, typeof(Fundraising_PTDM.FUNDRAISING_PT.Cajas));
                vbuscacodigo.AddProperty("void", "oid", true, true, DevExpress.Xpo.SortDirection.None);
                vbuscacodigo.AddProperty("vcodigo_integrado", "Trim(ToStr(sucursal))+Trim(codigo)", true, true, DevExpress.Xpo.SortDirection.None);
                vbuscacodigo.CriteriaString = string.Format("Trim(ToStr(sucursal))+Trim(codigo) = '{0}'", textBox_buscacodigointegrado.lValue.Trim());
                //
                int    seek_position      = -1;
                Guid   v_oid              = Guid.Empty;
                string v_codigo_integrado = string.Empty;
                foreach (ViewRecord item_buscacodigo in vbuscacodigo)
                {
                    v_oid = (item_buscacodigo["void"] == null ? Guid.Empty : (Guid)item_buscacodigo["void"]);
                    v_codigo_integrado      = (item_buscacodigo["vcodigo_integrado"] == null ? string.Empty : (String)item_buscacodigo["vcodigo_integrado"]);
                    seek_position           = bindingSource1.Find("oid", v_oid);
                    bindingSource1.Position = seek_position;
                }
                //
                textBox_buscacodigointegrado.Enabled = false;
                textBox_buscacodigointegrado.Visible = false;
                //
                if (vbuscacodigo.Count <= 0 | seek_position < 0)
                {
                    MessageBox.Show("No se encontro ningun registro con el Código Integrado: " + textBox_buscacodigointegrado.lValue.Trim(), "Buscar Código Integrado.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    sw1 = false;
                }
                //
                vbuscacodigo.Dispose();
                //
            }
            else
            {
                textBox_buscacodigointegrado.Enabled = false;
                textBox_buscacodigointegrado.Visible = false;
                sw1 = false;
            }
            //
            textBox_buscacodigointegrado.lValue         = string.Empty;
            textBox_buscacodigointegrado.textEdit1.Text = string.Empty;
            //
        }
Esempio n. 15
0
        void GroupBuild(Action <IEnumerable <string>, bool> itemsCalculated)
        {
            var xpView          = new XPView(((XPObjectSpace)((IObjectSpaceHolder)_propertyEditor).ObjectSpace).Session, _propertyEditor.ObjectTypeInfo.Type);
            var columnSortOrder = ((IModelMemberViewItemSortOrder)_propertyEditor.Model).SortingDirection;

            xpView.Sorting = new SortingCollection(new SortProperty(_propertyEditor.PropertyName, columnSortOrder));
            xpView.AddProperty(_propertyEditor.PropertyName, _propertyEditor.PropertyName, true);
            itemsCalculated.Invoke(xpView.OfType <ViewRecord>().Select(record => record[0]).OfType <string>(), false);
        }
Esempio n. 16
0
        public virtual void CalcularEstado( )
        {
            //calcular ultimo movimiento del valor (en comprobantes de fondos)

            //ejecutamos una vista, a los vinculos del valor con comprobantes (ComprobanteItemValor), ordenando los comprobantes de manera:
            //FECHA DESC, OID CAB DESC, DEBEHABER DESC, OID ITEM DESC
            //El primero devuelto es el ultimo movimiento
            var viewUltimoMovimiento = new XPView(Session, typeof(ComprobanteItemValor))
            {
                Criteria = CriteriaOperator.Parse("Valor = ?", this)
            };

            viewUltimoMovimiento.AddProperty("ComprobanteFecha", "ComprobanteItem.Comprobante.Fecha", false, true, SortDirection.Descending);
            viewUltimoMovimiento.AddProperty("ComprobanteId", "ComprobanteItem.Comprobante.Oid", false, true, SortDirection.Descending);
            viewUltimoMovimiento.AddProperty("ComprobanteItemDebeHaber", "ComprobanteItem.DebeHaber", false, true, SortDirection.Descending);
            viewUltimoMovimiento.AddProperty("ComprobanteItemId", "ComprobanteItem.Oid", false, true, SortDirection.Descending);

            UltimoMovimiento = viewUltimoMovimiento.Count == 0 ? null : Session.GetObjectByKey <ComprobanteItem>(( int )viewUltimoMovimiento[0]["ComprobanteItemId"]);
        }
Esempio n. 17
0
        public void Filtrar( )
        {
            Items.Clear( );

            if (FechaDesde == null || FechaHasta == null)
            {
                return;
            }

            var fechaSaldoInicial = FechaDesde.Value.AddDays(-1);

            var viewSaldoInicial = new XPView(Session, typeof(CuentaCorrienteItem));

            viewSaldoInicial.AddProperty("Saldo");
            viewSaldoInicial.AddProperty("Oid");
            viewSaldoInicial.Criteria = CriteriaOperator.Parse("Destinatario = ? AND Fecha <= ?", Cliente, fechaSaldoInicial);
            viewSaldoInicial.Sorting.Add(new SortProperty(CriteriaOperator.Parse("Oid"), SortingDirection.Descending));

            var saldoInicial = viewSaldoInicial.Count > 0 ? ( decimal )viewSaldoInicial[0]["Saldo"] : 0;

            var itemSaldoInicial = new CuentaCorrienteItem(Session)
            {
                Destinatario = Cliente, Fecha = fechaSaldoInicial, Debitos = 0, Creditos = 0, Saldo = saldoInicial
            };

            Items.Add(itemSaldoInicial);

            var itemsPeriodo = new XPCollection <CuentaCorrienteItem>(Session)
            {
                Criteria = CriteriaOperator.Parse("Destinatario = ? AND Fecha >= ? AND Fecha <= ?", Cliente, FechaDesde, FechaHasta)
            };

            itemsPeriodo.Reload( );

            foreach (var item in itemsPeriodo)
            {
                Items.Add(item);
            }

            OnChanged("Items");
        }
        public void GetGroupingInfo(GridViewCustomBindingGetGroupingInfoArgs e)
        {
            XPView data = new XPView(Session, ClassInfo);

            data.Criteria = CriteriaOperator.Parse(e.FilterExpression) & GetGroupFilter(e.GroupInfoList);
            SortDirection sorting = GetSortDirection(e.SortOrder);

            data.AddProperty(e.FieldName, e.FieldName, true, true, sorting);
            data.AddProperty("Count", "count", false);
            List <GridViewGroupInfo> groupInfo = new List <GridViewGroupInfo>();

            foreach (ViewRecord rec in data)
            {
                GridViewGroupInfo gi = new GridViewGroupInfo();
                gi.FieldName    = e.FieldName;
                gi.KeyValue     = rec[e.FieldName];
                gi.DataRowCount = (int)rec["Count"];
                groupInfo.Add(gi);
            }
            e.Data = groupInfo;
        }
        public void GetUniqueHeaderFilterValues(GridViewCustomBindingGetUniqueHeaderFilterValuesArgs e)
        {
            XPView data = new XPView(Session, ClassInfo);

            data.CriteriaString = e.FilterExpression;
            data.AddProperty(e.FieldName, e.FieldName, true);
            ArrayList result = new ArrayList();

            foreach (ViewRecord rec in data)
            {
                result.Add(rec[e.FieldName]);
            }
            e.Data = result;
        }
        public void GetSummaryValues(GridViewCustomBindingGetSummaryValuesArgs e)
        {
            XPView data = new XPView(Session, ClassInfo);

            data.Criteria = CriteriaOperator.Parse(e.FilterExpression) & GetGroupFilter(e.GroupInfoList);
            foreach (GridViewSummaryItemState summaryItem in e.SummaryItems)
            {
                Aggregate        aggregateType        = GetAggregateType(summaryItem.SummaryType);
                CriteriaOperator aggregatedExpression = new OperandProperty(summaryItem.FieldName);
                CriteriaOperator property             = new AggregateOperand(null, aggregatedExpression, aggregateType, null);
                string           name = string.Concat(summaryItem.FieldName, summaryItem.SummaryType);
                data.AddProperty(name, property);
            }
            ArrayList  result = new ArrayList();
            ViewRecord rec    = data[0];

            for (int i = 0; i < data.Properties.Count; i++)
            {
                result.Add(rec[i]);
            }
            e.Data = result;
        }
Esempio n. 21
0
        private void frmSST30IA_Load(object sender, EventArgs e)
        {
            // Set Code Box...
            fastColoredTextBox1.Language = Language.VB;

            // Load Card Details
            obj = Session.DefaultSession.FindObject<Cards>(CriteriaOperator.Parse("[CardSerialNumber] == ? AND [CardModel] == ? AND [CardRevision] == ?", _CardSerialNumber, _CardModel, _CardRevision));
            Text = obj.CardName;

            // Card Details
            LogEvent("Card Model Number: " + _CardModel, "X001", clsEventLogType.EventLogType.Info);
            LogEvent("Card Revision: " + _CardRevision, "X002", clsEventLogType.EventLogType.Info);
            LogEvent("Card Serial Number: " + _CardSerialNumber, "X003", clsEventLogType.EventLogType.Info);

            // Check to see if the card details exist in the database
            XPView CardDetails = new XPView(Session.DefaultSession, typeof(Database.AnalogInputConfiguration));
            CardDetails.AddProperty("Serial", "CardSerial");
            CardDetails.Criteria = CriteriaOperator.Parse(String.Format("[CardRevision] = '{0}' And [CardModel] = '{1}' And [CardSerial] == {2}", _CardRevision, _CardModel, _CardSerialNumber), null);

            bool CardAdded;
            if (CardDetails.Count > 0)
                CardAdded = true;
            else
                CardAdded = false;

            if (!CardAdded)
            {
                for (int i = 1; i <= 30; i++)
                {
                    Database.AnalogInputConfiguration dbConfiguration = new Database.AnalogInputConfiguration();
                    dbConfiguration.Input = i;
                    dbConfiguration.InputName = "Input #" + i;
                    dbConfiguration.InputStatus = false;
                    dbConfiguration.CodeButtonUp = "";
                    dbConfiguration.CodeButtonDown = "";
                    dbConfiguration.CardSerial = _CardSerialNumber;
                    dbConfiguration.CardRevision = _CardRevision;
                    dbConfiguration.CardModel = _CardModel;
                    dbConfiguration.Save();
                }
            }

            xpCollectionCardInfo.Criteria = CriteriaOperator.Parse(String.Format("[CardModel] = '{0}' And [CardRevision] = '{1}' And [CardSerialNumber] = {2}", _CardModel, _CardRevision, _CardSerialNumber), null);

            xpCollectionConfiguration.Criteria = CriteriaOperator.Parse(String.Format("[CardRevision] = '{0}' And [CardModel] = '{1}' And [CardSerial] = {2}", _CardRevision, _CardModel, _CardSerialNumber), null);

            // Setup Code Dropdown
            SetupFunctionDropdown();

            // Setup Group Control Boxes
            gcCardConfiguration.Dock = DockStyle.Fill;
            gcCardSettings.Dock = DockStyle.Fill;
            gcDebugLog.Dock = DockStyle.Fill;
            gcInputScripts.Dock = DockStyle.Fill;

            // Hide Group Control Boxes
            gcCardConfiguration.Visible = false;
            gcDebugLog.Visible = false;
            gcInputScripts.Visible = false;

            // Enable Timers
            tmrInputConfigRefresh.Enabled = true;
            tmrCheckUSB.Enabled = true;
            tmrCheckFormDetails.Enabled = true;

            // Set Form Details
            objCardsDB = Session.DefaultSession.FindObject<Cards>(CriteriaOperator.Parse("[CardSerialNumber] == ? AND [CardModel] == ? AND [CardRevision] == ?", _CardSerialNumber, _CardModel, _CardRevision));
            DataBindings.Add("Text", objCardsDB, "CardName");
            chkUSBConnected.DataBindings.Add("Text", objCardsDB, "CardConnected");
        }
Esempio n. 22
0
        public UI_Depositos_Bancarios_Det(object form_padre, int lntpago)
        {
            WaitForm1 WaitForm1 = new WaitForm1();

            DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(WaitForm1, typeof(WaitForm1), false, false, false);
            DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormCaption("Saldos Pendientes para Depósitar...");
            DevExpress.XtraSplashScreen.SplashScreenManager.Default.SetWaitFormDescription("Espere un momento por favor... Cargando y Validando Datos...   .");
            //
            // asignacion de valores a objetos publicos //
            Form_padre = form_padre;
            //totales_deposito_aux = ((Fundraising_PT.Formularios.UI_Depositos_Bancarios)Form_padre).totales_deposito;
            //Totales_deposito = totales_deposito;
            lg_deposito_bancario = ((Fundraising_PTDM.FUNDRAISING_PT.Depositos_Bancarios)((Fundraising_PT.Formularios.UI_Depositos_Bancarios)form_padre).bindingSource1.Current).oid;
            ln_status_deposito   = ((Fundraising_PTDM.FUNDRAISING_PT.Depositos_Bancarios)((Fundraising_PT.Formularios.UI_Depositos_Bancarios)form_padre).bindingSource1.Current).status;
            ln_sucursal_dep_det  = ((Fundraising_PTDM.FUNDRAISING_PT.Depositos_Bancarios)((Fundraising_PT.Formularios.UI_Depositos_Bancarios)form_padre).bindingSource1.Current).sucursal;
            obj_headerMenu_ant   = ((Fundraising_PT.Formularios.UI_Depositos_Bancarios)form_padre).HeaderMenu;
            lHeader_ant          = ((Fundraising_PT.Formularios.UI_Depositos_Bancarios)form_padre).HeaderMenu.Caption;
            lAccion  = "Detalle del depósito por forma de pago";
            ln_modo  = (((Fundraising_PT.Formularios.UI_Depositos_Bancarios)form_padre).lAccion == "Insertar" ? 1 : ((Fundraising_PT.Formularios.UI_Depositos_Bancarios)form_padre).lAccion == "Editar" ? 2 : 0);
            ln_tpago = lntpago;
            //
            InitializeComponent();
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            //
            // llena los datos de la coleccion de las formas de pago y usuarios //
            CriteriaOperator filtro_status = (new OperandProperty("status") == new OperandValue(1));

            DevExpress.Xpo.SortProperty orden_formas_pagos = (new DevExpress.Xpo.SortProperty("codigo", DevExpress.Xpo.DB.SortingDirection.Ascending));
            DevExpress.Xpo.SortProperty orden_usuarios     = (new DevExpress.Xpo.SortProperty("usuario", DevExpress.Xpo.DB.SortingDirection.Ascending));
            //
            formas_pagos = new DevExpress.Xpo.XPCollection <Fundraising_PTDM.FUNDRAISING_PT.Formas_Pagos>(DevExpress.Xpo.XpoDefault.Session, filtro_status, orden_formas_pagos);

            // se crean las columnas al datatable de saldos ///
            saldos_formas_pagos.Columns.Add("oid_forma_pago", typeof(Guid));
            saldos_formas_pagos.Columns.Add("oid_recaudador", typeof(Guid));
            saldos_formas_pagos.Columns.Add("cod_forma_pago", typeof(string));
            saldos_formas_pagos.Columns.Add("recaudador", typeof(string));
            saldos_formas_pagos.Columns.Add("forma_pago", typeof(string));
            saldos_formas_pagos.Columns.Add("monto_precargado", typeof(decimal));
            saldos_formas_pagos.Columns.Add("monto", typeof(decimal));
            saldos_formas_pagos.Columns.Add("saldo", typeof(decimal));
            saldos_formas_pagos.PrimaryKey = new DataColumn[] { saldos_formas_pagos.Columns["oid_forma_pago"], saldos_formas_pagos.Columns["oid_recaudador"] };

            // se crean las columnas a la vista que llenara los datos del datatable de saldos ///
            vsaldos_formas_pagos = new XPView(XpoDefault.Session, typeof(Fundraising_PTDM.FUNDRAISING_PT.Saldos_Recauda_dep));
            vsaldos_formas_pagos.AddProperty("oid_forma_pago", "forma_pago.oid", true, true, DevExpress.Xpo.SortDirection.None);
            vsaldos_formas_pagos.AddProperty("oid_recaudador", "recaudador.oid", true, true, DevExpress.Xpo.SortDirection.None);
            vsaldos_formas_pagos.AddProperty("cod_forma_pago", "forma_pago.codigo", true, true, DevExpress.Xpo.SortDirection.Ascending);
            vsaldos_formas_pagos.AddProperty("recaudador", "recaudador.usuario", true, true, DevExpress.Xpo.SortDirection.Ascending);
            vsaldos_formas_pagos.AddProperty("forma_pago", "forma_pago.nombre", true, true, DevExpress.Xpo.SortDirection.None);
            vsaldos_formas_pagos.AddProperty("recaudado", "Sum(recaudado)", false, true, DevExpress.Xpo.SortDirection.None);
            vsaldos_formas_pagos.AddProperty("depositado", "Sum(depositado)", false, true, DevExpress.Xpo.SortDirection.None);
            vsaldos_formas_pagos.AddProperty("saldo", "Sum(recaudado-depositado)", false, true, DevExpress.Xpo.SortDirection.None);

            // llena los datos de la coleccion del detalle del deposito //
            filtro_deposito_bancario_det = (new OperandProperty("deposito_bancario.oid") == new OperandValue(lg_deposito_bancario) & new OperandProperty("forma_pago.tpago") == new OperandValue(ln_tpago));
            DevExpress.Xpo.SortProperty      orden_deposito_bancario_det  = (new DevExpress.Xpo.SortProperty("forma_pago.tpago", DevExpress.Xpo.DB.SortingDirection.Ascending));
            DevExpress.Xpo.SortingCollection orden_deposito_bancario_det1 = new DevExpress.Xpo.SortingCollection(new DevExpress.Xpo.SortProperty("forma_pago.tpago", DevExpress.Xpo.DB.SortingDirection.Ascending));
            orden_deposito_bancario_det1.Add(new DevExpress.Xpo.SortProperty("forma_pago.codigo", DevExpress.Xpo.DB.SortingDirection.Ascending));
            orden_deposito_bancario_det1.Add(new DevExpress.Xpo.SortProperty("recaudador.usuario", DevExpress.Xpo.DB.SortingDirection.Ascending));
            //
            depositos_bancarios_det         = new DevExpress.Xpo.XPCollection <Fundraising_PTDM.FUNDRAISING_PT.Depositos_Bancarios_Det>(DevExpress.Xpo.XpoDefault.Session, filtro_deposito_bancario_det, orden_deposito_bancario_det);
            depositos_bancarios_det.Sorting = orden_deposito_bancario_det1;
            //
            seteo_nivel_seguridad();
            //
            // bindeo de datos a los bindingsource principales //
            bindingSource_recaudador.DataSource = usuarios;
            bindingSource_depositos_bancarios_det.DataSource = depositos_bancarios_det;
        }
Esempio n. 23
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            richEditControl1.LoadDocument("About Smart Sim Tech.rtf");

            Version vrs = new Version(Application.ProductVersion);
            _AppVersion = String.Format("{0}.{1}.{2}", vrs.Major, vrs.Minor, vrs.Build);

            try
            {
                WebClient getrtf = new WebClient();
                richEditControl2.RtfText = getrtf.DownloadString(_BaseURL + _BaseFile + _AppVersion + _ExtInfo);
            }
            catch (Exception)
            {
                // No Internet Connection
                richEditControl2.Text = "Release notes file not found...";
            }

            // Load USB Device List DataTable
            _usbDeviceList = new DataTable();

            _usbDeviceList.Columns.Add("usbGUID", typeof(string));
            _usbDeviceList.Columns.Add("GUID", typeof(string));
            _usbDeviceList.Columns.Add("cardtype", typeof(string));
            _usbDeviceList.Columns.Add("serial", typeof(int));
            _usbDeviceList.Columns.Add("deviceid", typeof(int));
            _usbDeviceList.Columns.Add("connected", typeof(bool));

            tmrEnumerateUSB.Enabled = true;
            tmrCheckFSUIPC.Enabled = true;

            // Set Application Version
            lblAppVersion.Caption = String.Format("Version: {0}", _AppVersion);

            // Load Start Page
            frmStartPage frm = new frmStartPage();
            frm.MdiParent = this;
            frm.ParentFrm = this;
            frm.Show();

            // Load Registration Details
            XPView view = new XPView(Session.DefaultSession, typeof(Database.Registration));
            view.AddProperty("Name", "Name");
            view.AddProperty("Company", "Company");
            bool registered = false;
            foreach (ViewRecord record in view)
            {
                lblRegisteredName.Caption = "Registered To: " + (string)record["Name"];
                registered = true;
            }

            if (!registered)
                lblRegisteredName.Caption = "Registered To: Unregistered";

            // Load Child Forms
            LoadChildrenForms();

            // Set Start Page as Default Page
            foreach (Form mdi in MdiChildren)
            {
                if (mdi is frmStartPage)
                {
                    mdi.Activate();
                }
            }

            // Set Notification Icon
            notifyIcon1.Icon = Icon;

            // Set CardConnected = false to all records in the cards database
            XPCollection cardsdb = new XPCollection(typeof(Database.Cards));
            foreach (Database.Cards record in cardsdb)
            {
                record.CardConnected = false;
                record.Save();
            }

            loaded = true;

            // Show Window
            Show();
            Refresh();

            _LaunchProcess.ApplicationLoading();

            tmrCloseSplash.Enabled = true;
        }
Esempio n. 24
0
 void GroupBuild(Action<IEnumerable<string>, bool> itemsCalculated) {
     var xpView = new XPView(((XPObjectSpace) ((IObjectSpaceHolder) _propertyEditor).ObjectSpace).Session, _propertyEditor.ObjectTypeInfo.Type);
     xpView.AddProperty(_propertyEditor.PropertyName, _propertyEditor.PropertyName, true);
     itemsCalculated.Invoke(xpView.OfType<ViewRecord>().Select(record => record[0]).OfType<string>(), false);
 }
Esempio n. 25
0
 private void LoadChildrenForms()
 {
     XPView cards = new XPView(Session.DefaultSession, typeof(Database.Cards));
     cards.AddProperty("Model", "CardModel");
     cards.AddProperty("Rev", "CardRevision");
     cards.AddProperty("Serial", "CardSerialNumber");
     foreach (ViewRecord record in cards)
     {
         LoadForm((string)record["Model"], (string)record["Rev"], record["Serial"].ToString());
     }
 }
        public override void eliminar(object sender, EventArgs e)
        {
            if (this_primary_object_persistent_current != null)
            {
                try
                {
                    this_primary_object_persistent_current.Reload();
                    //
                    XPView vcuentas_bancarias = new XPView(XpoDefault.Session, typeof(Fundraising_PTDM.FUNDRAISING_PT.Bancos_Cuentas));
                    vcuentas_bancarias.AddProperty("void", "oid", true, true, DevExpress.Xpo.SortDirection.None);
                    //
                    XPView vcajas = new XPView(XpoDefault.Session, typeof(Fundraising_PTDM.FUNDRAISING_PT.Cajas));
                    vcajas.AddProperty("void", "oid", true, true, DevExpress.Xpo.SortDirection.None);
                    //
                    XPView vdepositos = new XPView(XpoDefault.Session, typeof(Fundraising_PTDM.FUNDRAISING_PT.Depositos_Bancarios));
                    vdepositos.AddProperty("void", "oid", true, true, DevExpress.Xpo.SortDirection.None);
                    //
                    XPView vpuntos_bancarios = new XPView(XpoDefault.Session, typeof(Fundraising_PTDM.FUNDRAISING_PT.Puntos_Bancarios));
                    vpuntos_bancarios.AddProperty("void", "oid", true, true, DevExpress.Xpo.SortDirection.None);
                    //
                    XPView vsesiones = new XPView(XpoDefault.Session, typeof(Fundraising_PTDM.FUNDRAISING_PT.Sesiones));
                    vsesiones.AddProperty("void", "oid", true, true, DevExpress.Xpo.SortDirection.None);
                    //
                    XPView vrecaudaciones = new XPView(XpoDefault.Session, typeof(Fundraising_PTDM.FUNDRAISING_PT.Recaudaciones));
                    vrecaudaciones.AddProperty("void", "oid", true, true, DevExpress.Xpo.SortDirection.None);
                    //
                    vcuentas_bancarias.Criteria = CriteriaOperator.Parse(string.Format("sucursal = {0}", ((Fundraising_PTDM.FUNDRAISING_PT.Sucursales)this_primary_object_persistent_current).codigo));
                    vcajas.Criteria             = CriteriaOperator.Parse(string.Format("sucursal = {0}", ((Fundraising_PTDM.FUNDRAISING_PT.Sucursales)this_primary_object_persistent_current).codigo));
                    vdepositos.Criteria         = CriteriaOperator.Parse(string.Format("sucursal = {0}", ((Fundraising_PTDM.FUNDRAISING_PT.Sucursales)this_primary_object_persistent_current).codigo));
                    vpuntos_bancarios.Criteria  = CriteriaOperator.Parse(string.Format("sucursal = {0}", ((Fundraising_PTDM.FUNDRAISING_PT.Sucursales)this_primary_object_persistent_current).codigo));
                    vsesiones.Criteria          = CriteriaOperator.Parse(string.Format("sucursal = {0}", ((Fundraising_PTDM.FUNDRAISING_PT.Sucursales)this_primary_object_persistent_current).codigo));
                    vrecaudaciones.Criteria     = CriteriaOperator.Parse(string.Format("sucursal = {0}", ((Fundraising_PTDM.FUNDRAISING_PT.Sucursales)this_primary_object_persistent_current).codigo));
                    //
                    int cantidad_asociaciones = vcuentas_bancarias.Count + vcajas.Count + vdepositos.Count + vpuntos_bancarios.Count + vsesiones.Count + vrecaudaciones.Count;
                    //
                    if (cantidad_asociaciones > 0 | ((Fundraising_PTDM.FUNDRAISING_PT.Sucursales)this_primary_object_persistent_current).codigo == Fundraising_PT.Properties.Settings.Default.sucursal)
                    {
                        if (MessageBox.Show("NO se puede Eliminar la sucursal porque existen asociaciones de datos con la sucursal seleccionada." + Environment.NewLine + "Desea cambiar el estatus de la sucursal a InActiva ?", "Eliminar Sucursal", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.OK)
                        {
                            ((Fundraising_PTDM.FUNDRAISING_PT.Bancos)this_primary_object_persistent_current).status = 2;
                            this_primary_object_persistent_current.Save();
                            lookUp_status.gridLookUpEdit1.Refresh();
                        }
                    }
                    else
                    {
                        base.eliminar(sender, e);
                    }
                    //
                    vcuentas_bancarias.Dispose();
                    vcajas.Dispose();
                    vdepositos.Dispose();
                    vpuntos_bancarios.Dispose();
                    vsesiones.Dispose();
                    vrecaudaciones.Dispose();
                }
                catch (Exception)
                {
                    Fundraising_PT.Clases.MsgBoxUtil.HackMessageBox("Data Reload", "Continuar", "Ignorar");
                    switch (MessageBox.Show("No se pudo leer los datos desde el servidor para el registro actual..." + Environment.NewLine + Environment.NewLine + "Posiblemente otro usuario lo elimino mientras usted lo tenia seleccionado para eliminarno !!!" + Environment.NewLine + Environment.NewLine + "Seleccione una opción para continuar ?" + Environment.NewLine + Environment.NewLine + "Data Reload : Ejecutar (Data Reload) Vuelve a cargar todas las colecciones de datos desde el servidor." + Environment.NewLine + Environment.NewLine + "Cancelar : Cancela la eliminación de datos del registro actual y salta al siguiente registro. " + Environment.NewLine + Environment.NewLine + "Ignorar : Ignora la lectura de los datos del registro desde el servidor y permanece sobre el.", "Data Reload (Eliminar)", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1))
                    {
                    case DialogResult.Yes:
                        this.datareload();
                        bindingSource1.MoveFirst();
                        this_primary_object_persistent_current = ((XPBaseObject)bindingSource1.Current);
                        break;

                    case DialogResult.No:
                        if (bindingSource1.Count <= 0)
                        {
                            bindingSource1.MoveFirst();
                            this_primary_object_persistent_current = ((XPBaseObject)bindingSource1.Current);
                            break;
                        }
                        if (bindingSource1.Count > 0 & bindingSource1.Position >= bindingSource1.Count)
                        {
                            bindingSource1.MovePrevious();
                            this_primary_object_persistent_current = ((XPBaseObject)bindingSource1.Current);
                            break;
                        }
                        if (bindingSource1.Count > 0 & bindingSource1.Position == 0)
                        {
                            bindingSource1.MoveNext();
                            this_primary_object_persistent_current = ((XPBaseObject)bindingSource1.Current);
                            break;
                        }
                        if (bindingSource1.Count > 0 & (bindingSource1.Position > 0 & bindingSource1.Position < bindingSource1.Count))
                        {
                            bindingSource1.MoveNext();
                            this_primary_object_persistent_current = ((XPBaseObject)bindingSource1.Current);
                            break;
                        }
                        else
                        {
                            bindingSource1.MoveFirst();
                            this_primary_object_persistent_current = ((XPBaseObject)bindingSource1.Current);
                            break;
                        }
                    }
                    Fundraising_PT.Clases.MsgBoxUtil.UnHackMessageBox();
                }
            }
        }
Esempio n. 27
0
        private void bbtnRegisterSoftware_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmRegistrationDetails frm = new frmRegistrationDetails();
            frm.ShowDialog();

            // Load Registration Details
            XPView view = new XPView(Session.DefaultSession, typeof(Database.Registration));
            view.AddProperty("Name", "Name");
            view.AddProperty("Company", "Company");
            bool registered = false;
            foreach (ViewRecord record in view)
            {
                lblRegisteredName.Caption = "Registered To: " + (string)record["Name"];
                registered = true;
            }

            if (!registered)
                lblRegisteredName.Caption = "Registered To: Unregistered";
        }
        private void frmMain_Load(object sender, EventArgs e)
        {
            // Set template
            UserLookAndFeel.Default.SetSkinStyle("Sharp Plus");

            // Set Application Version
            Version vrs = new Version(Application.ProductVersion);
            lblAppVersion.Caption = String.Format("Version: {0}.{1}.{2}", vrs.Major, vrs.Minor, vrs.Build);

            // Load Start Page
            frmStartPage frm = new frmStartPage();
            frm.MdiParent = this;
            frm.ParentFrm = this;
            frm.Show();

            // Load Registration Details
            XPView view = new XPView(Session.DefaultSession, typeof(Database.Registration));
            view.AddProperty("Name", "Name");
            view.AddProperty("Company", "Company");
            bool registered = false;
            foreach (ViewRecord record in view)
            {
                lblRegisteredName.Caption = "Registered To: " + (string)record["Name"];
                registered = true;
            }

            if (!registered)
                lblRegisteredName.Caption = "Registered To: Unregistered";

            // Load Child Forms
            LoadChildrenForms();

            // Set Start Page as Default Page
            foreach (Form mdi in MdiChildren)
            {
                if (mdi is frmStartPage)
                {
                    mdi.Activate();
                }
            }

            // Set Notification Icon
            notifyIcon1.Icon = Icon;

            loaded = true;
        }
Esempio n. 29
0
        static void Main()
        {
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.Skins.SkinManager.EnableFormSkins();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Add the event handler for handling UI thread exceptions to the event.
            Application.ThreadException += new ThreadExceptionEventHandler(Form1_UIThreadException);

            // Set the unhandled exception mode to force all Windows Forms errors to go through
            // our handler.
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // Add the event handler for handling non-UI thread exceptions to the event.
            //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            //Forms.frmSplash frm = new Forms.frmSplash();
            Forms.frmTransparentSplash launch = new Forms.frmTransparentSplash();
            launch.Show();
            launch.Refresh();

            // Check for latest version
            Version vrs = new Version(Application.ProductVersion);
            //lblAppVersion.Caption = String.Format("Version: {0}.{1}.{2}", vrs.Major, vrs.Minor, vrs.Build);
            try
            {
                string latestversion;
                WebClient getversion = new WebClient();
                latestversion = getversion.DownloadString("http://www.smartsimtech.com/software/sstcp-latestversion.txt");
                Version latver = new Version(latestversion);
                getversion.Dispose();
                if (latver > vrs)
                {
                    Forms.frmAutoUpdate update = new Forms.frmAutoUpdate();
                    update.AppVersion = latestversion;
                    update.ShowDialog();
                    if (update.ApplyUpdate)
                        return;
                }
            }
            catch (Exception)
            {
                // No internet access to check for updates
            }

            launch.CheckDatabase();
            //MessageBox.Show(XpoDefault.Session.ConnectionString);
            //XpoDefault.Session.ConnectionString = "data source=localhost\\SQLEXPRESS;integrated security=true;initial catalog=SSTCP2;";
            //XpoDefault.Session.ConnectionString = String.Format("data source=tcp:{0}.database.windows.net;initial catalog={1};user id={2};password={3};", serverName, databaseName, userName, password);

            launch.CheckRegistration();
            XPView view = new XPView(Session.DefaultSession, typeof(Database.Registration));
            view.AddProperty("Name", "Name");
            view.AddProperty("Company", "Company");
            bool registered = false;
            foreach (ViewRecord record in view)
            {
                registered = true;
            }

            if (!registered)
            {
                Forms.frmRegistrationDetails register = new Forms.frmRegistrationDetails();
                register.ShowDialog();
                register.Dispose();
            }

            launch.LaunchApplication();

            if (launch.RunApplication)
            {
                Forms.frmMain MainApp = new Forms.frmMain();
                MainApp.LaunchProcess = launch;
                Application.Run(MainApp);
            }
            else
            {
                launch.Dispose();
            }
        }
Esempio n. 30
0
        public void load_data()
        {
            if (!hfReportAudit.Contains("id"))
            {
                return;
            }

            #region header và dòng đầu gridview
            header_column_GridView();
            DataTable data_table = table_template();
            #endregion

            // truyền tham số mã kho và mã phiếu kiểm kê
            string code_repository, code_inventory;

            InventoryAuditArtifact a = session.GetObjectByKey <InventoryAuditArtifact>(Guid.Parse(hfReportAudit.Get("id").ToString()));

            code_repository = a.InventoryId.Code; //"KHO_TNTX";
            code_inventory  = a.Code;             //"BB01";

            #region xử lý data
            int    STT             = 1;
            XPView list_ItemUnitId = new XPView(session, typeof(InventoryAuditItemUnit));
            list_ItemUnitId.AddProperty("itemUnit", "ItemUnitId", true);

            double sum_thanh_tien_kt = 0, sum_thanh_tien_kk = 0, sum_thanh_tien_thua = 0, sum_thanh_tien_thieu = 0;
            foreach (ViewRecord each_ItemUnitId in list_ItemUnitId)
            {
                XPCollection <InventoryAuditItemUnit> iaiu = new XPCollection <InventoryAuditItemUnit>(session, CriteriaOperator.Parse("ItemUnitId = '" + each_ItemUnitId["itemUnit"].ToString() + "'"));
                foreach (InventoryAuditItemUnit each_iaiu in iaiu)
                {
                    try
                    {
                        if (each_iaiu.InventoryAuditArtifactId.InventoryId.Code == code_repository && each_iaiu.InventoryAuditArtifactId.RowStatus >= 1 && each_iaiu.InventoryAuditArtifactId.Code == code_inventory) //xét kho
                        {
                            XPCollection <QualityItem> qi = each_iaiu.QualityItems;
                            double kem = 0, mat = 0;
                            foreach (QualityItem each_qi in qi)
                            {
                                if (each_qi.QualityItemType.Name == "LOSS_QUANLITY")
                                {
                                    mat += each_qi.AuditAmount;
                                }
                                else if (each_qi.QualityItemType.Name == "LESS_QUANLITY")
                                {
                                    kem += each_qi.AuditAmount;
                                }
                            }

                            double so_luong_kt       = each_iaiu.BookingAmount;
                            double so_luong_kk       = each_iaiu.RealAmount;
                            XPCollection <COGS> cogs = new XPCollection <COGS>(session, CriteriaOperator.Parse("InventoryId='" + each_iaiu.InventoryAuditArtifactId.InventoryId.InventoryId + "' AND ItemUnitId='" + each_iaiu.ItemUnitId.ItemUnitId + "'"));
                            double money;
                            try { money = cogs[0].COGSPrice; }
                            catch { money = 0; }

                            sum_thanh_tien_kk += money * so_luong_kk;
                            sum_thanh_tien_kt += money * so_luong_kt;

                            DataRow dr = data_table.NewRow();
                            dr["stt"]           = STT++;
                            dr["ten"]           = each_iaiu.ItemUnitId.ItemId.Name;
                            dr["ma_so"]         = each_iaiu.ItemUnitId.ItemId.Code;
                            dr["don_vi_tinh"]   = each_iaiu.ItemUnitId.UnitId.Name;
                            dr["don_gia"]       = money;
                            dr["so_luong_kt"]   = so_luong_kt;
                            dr["thanh_tien_kt"] = money * so_luong_kt;
                            dr["so_luong_kk"]   = so_luong_kk;
                            dr["thanh_tien_kk"] = money * so_luong_kk;
                            if (so_luong_kk > so_luong_kt)
                            {
                                dr["so_luong_thua"]   = so_luong_kk - so_luong_kt;
                                dr["thanh_tien_thua"] = money * (so_luong_kk - so_luong_kt);
                                sum_thanh_tien_thua  += money * (so_luong_kk - so_luong_kt);
                            }
                            else if (so_luong_kk < so_luong_kt)
                            {
                                dr["so_luong_thieu"]   = so_luong_kt - so_luong_kk;
                                dr["thanh_tien_thieu"] = money * (so_luong_kt - so_luong_kk);
                                sum_thanh_tien_thieu  += money * (so_luong_kt - so_luong_kk);
                            }
                            dr["tot"] = so_luong_kk - kem - mat;
                            dr["kem"] = kem;
                            dr["mat"] = mat;
                            data_table.Rows.Add(dr);
                        }
                    }
                    catch { }
                }
            }
            DataRow dr_sum = data_table.NewRow();
            dr_sum["ten"]              = "Cộng  ";
            dr_sum["thanh_tien_kt"]    = sum_thanh_tien_kt + "  ";
            dr_sum["thanh_tien_kk"]    = sum_thanh_tien_kk + "  ";
            dr_sum["thanh_tien_thua"]  = sum_thanh_tien_thua + "  ";
            dr_sum["thanh_tien_thieu"] = sum_thanh_tien_thieu + "  ";
            data_table.Rows.Add(dr_sum);

            #endregion


            #region bind data vào gridview

            xGridView.DataSource = data_table;
            xGridView.DataBind();
            #endregion

            #region xuất report

            WebModule.Warehouse.Report._05_VT _05_VT = new WebModule.Warehouse.Report._05_VT();
            xGridViewExporter.GridViewID          = "xGridView";
            _05_VT.printableCC.PrintableComponent = new PrintableComponentLinkBase()
            {
                Component = xGridViewExporter
            };
            ReportViewer.Report = _05_VT;

            #endregion
        }
        static void Main(string[] args)
        {
            XPDictionary dict = new ReflectionDictionary();

            //Create dynamic classes and members
            XPClassInfo ciEngineer = dict.CreateClass("Engineer");

            ciEngineer.CreateMember("UserID", typeof(string), new KeyAttribute(), new SizeAttribute(8));
            ciEngineer.CreateMember("PublicName", typeof(string), new SizeAttribute(32));

            XPClassInfo ciProject = dict.CreateClass("Project");

            ciProject.CreateMember("ProjectID", typeof(string), new KeyAttribute(), new SizeAttribute(4));
            ciProject.CreateMember("Title", typeof(string), new SizeAttribute(255));
            ciProject.CreateMember("Description", typeof(string), new SizeAttribute(SizeAttribute.Unlimited));
            ciProject.CreateMember("Assignments", typeof(XPCollection), true, new AssociationAttribute("R1", null, "Assignment"));

            XPClassInfo ciAssignment = dict.CreateClass("Assignment");
            XPComplexCustomMemberInfo miAssignmentKey = new XPComplexCustomMemberInfo(ciAssignment, "Key", typeof(object), new KeyAttribute());

            miAssignmentKey.AddSubMember("Engineer", ciEngineer, new PersistentAttribute("Engineer"));
            miAssignmentKey.AddSubMember("Project", ciProject, new PersistentAttribute("Project"), new AssociationAttribute("R1"));
            ciAssignment.CreateMember("Role", typeof(string), new SizeAttribute(32));
            ciAssignment.CreateMember("Rank", typeof(int));

            XPClassInfo ciTask = dict.CreateClass("Task");
            XPComplexCustomMemberInfo miTaskKey = new XPComplexCustomMemberInfo(ciTask, "Key", typeof(object), new KeyAttribute());

            miTaskKey.AddSubMember("Project", ciProject, new PersistentAttribute("Project"));
            miTaskKey.AddSubMember("TaskNo", typeof(int), new PersistentAttribute("TaskNo"));
            ciTask.CreateMember("Description", typeof(string), new SizeAttribute(SizeAttribute.Unlimited));

            //Initialize the data layer
            //XpoDefault.DataLayer = XpoDefault.GetDataLayer(DevExpress.Xpo.DB.MSSqlConnectionProvider.GetConnectionString("(local)", "E4606"), dict, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);
            XpoDefault.DataLayer = new SimpleDataLayer(dict, new DevExpress.Xpo.DB.InMemoryDataStore());

            //Create DB and some sample data
            using (UnitOfWork uow = new UnitOfWork()) {
                uow.UpdateSchema();
                IList <object> engineers = CreateObjects(uow, ciEngineer, new string[] { "UserID", "PublicName" }, new object[][] {
                    new object[] { "U1", "John" },
                    new object[] { "PAUL", "Paul" },
                    new object[] { "XFR", "Fred" },
                });
                IList <object> projects = CreateObjects(uow, ciProject, new string[] { "ProjectID", "Title", "Description" }, new object[][] {
                    new object[] { "P1", "DemoApp", "bla-bla-bla" },
                    new object[] { "P2", "MegaApp", "duh!" },
                    new object[] { "PNEW", "KillerApp", "wow!" },
                });
                IList <object> assignments = CreateObjects(uow, ciAssignment, new string[] { "Key.Engineer", "Key.Project", "Role", "Rank" }, new object[][] {
                    new object[] { engineers[1], projects[0], "Developer", 6 },
                    new object[] { engineers[2], projects[0], "Developer", 8 },
                    new object[] { engineers[0], projects[1], "Leader", 10 },
                    new object[] { engineers[2], projects[1], "Developer", 8 },
                    new object[] { engineers[1], projects[1], "Consultant", 3 },
                    new object[] { engineers[1], projects[2], "Developer", 8 },
                    new object[] { engineers[2], projects[2], "Developer", 7 },
                    new object[] { engineers[0], projects[2], "Tester", 5 },
                });
                IList <object> tasks = CreateObjects(uow, ciTask, new string[] { "Key.Project", "Key.TaskNo", "Description" }, new object[][] {
                    new object[] { projects[0], 1, "Start" },
                    new object[] { projects[0], 2, "Finish" },
                    new object[] { projects[1], 0, "Framework" },
                    new object[] { projects[1], 1, "Feature1" },
                    new object[] { projects[1], 2, "Feature2" },
                    new object[] { projects[1], 3, "Feature3" },
                    new object[] { projects[1], 4, "Feature4" },
                    new object[] { projects[1], 5, "Feature5" },
                    new object[] { projects[1], 6, "Polish" },
                    new object[] { projects[2], 1, "ready" },
                    new object[] { projects[2], 2, "steady" },
                    new object[] { projects[2], 3, "go" },
                });
                uow.CommitChanges();
            }

            //read data
            using (UnitOfWork uow = new UnitOfWork()) {
                //
                XPView xpv = new XPView(uow, ciTask);
                xpv.Sorting.Add(new SortProperty("Project", DevExpress.Xpo.DB.SortingDirection.Ascending));
                xpv.Sorting.Add(new SortProperty("No", DevExpress.Xpo.DB.SortingDirection.Ascending));
                xpv.AddProperty("Project", "Key.Project.Title");
                xpv.AddProperty("No", "Key.TaskNo");
                xpv.AddProperty("Task", "Description");
                foreach (ViewRecord r in xpv)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (ViewProperty p in xpv.Properties)
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append(", ");
                        }
                        sb.Append(r[p.Name]);
                    }
                    Console.WriteLine(sb.ToString());
                }
                Console.WriteLine();
            }
            using (UnitOfWork uow = new UnitOfWork()) {
                //
                XPCollection xpc = new XPCollection(uow, ciProject);
                foreach (object o in xpc)
                {
                    Console.WriteLine(DumpValues(ciProject, o, new string[] { "Title", "Description" }));
                    XPCollection xpc2 = ciProject.GetMember("Assignments").GetValue(o) as XPCollection;
                    foreach (object o2 in xpc2)
                    {
                        Console.WriteLine("    " + DumpValues(ciAssignment, o2, new string[] { "Role", "Rank", "Key.Engineer.PublicName" }));
                    }
                }
                Console.WriteLine();
            }
            using (UnitOfWork uow = new UnitOfWork()) {
                //
                object project = uow.FindObject(ciProject, CriteriaOperator.Parse("ProjectID=?", "P2"));
                DevExpress.Xpo.Helpers.IdList taskKey = new DevExpress.Xpo.Helpers.IdList();
                taskKey.Add(project);
                taskKey.Add(2);
                object task = uow.GetObjectByKey(ciTask, taskKey);
                Console.WriteLine(DumpValues(ciTask, task, new string[] { "Key.Project.Title", "Key.TaskNo", "Description" }));
                Console.WriteLine();
            }
            Console.ReadLine();
        }
Esempio n. 32
0
        private void frmSST24OA_Load(object sender, EventArgs e)
        {
            // Set Code Box...
            fastColoredTextBox1.Language = Language.VB;

            // Load Card Details
            obj = Session.DefaultSession.FindObject<Cards>(CriteriaOperator.Parse("[CardSerialNumber] == ? AND [CardModel] == ? AND [CardRevision] == ?", _CardSerialNumber, _CardModel, _CardRevision));
            Text = obj.CardName;
            //lblCardDescription.Text = obj.CardDescription;

            // Card Details
            LogEvent("Card Model Number: " + _CardModel, "X001", clsEventLogType.EventLogType.Info);
            LogEvent("Card Revision: " + _CardRevision, "X002", clsEventLogType.EventLogType.Info);
            LogEvent("Card Serial Number: " + _CardSerialNumber, "X003", clsEventLogType.EventLogType.Info);

            // Check to see if the card details exist in the database
            XPView CardDetails = new XPView(Session.DefaultSession, typeof(Database.AnalogOutputConfiguration));
            CardDetails.AddProperty("Serial", "CardSerial");
            CardDetails.Criteria = CriteriaOperator.Parse(String.Format("[CardRevision] = '{0}' And [CardModel] = '{1}' And [CardSerial] == {2}", _CardRevision, _CardModel, _CardSerialNumber), null);

            bool CardAdded;
            if (CardDetails.Count > 0)
                CardAdded = true;
            else
                CardAdded = false;

            if (!CardAdded)
            {
                for (int i = 1; i <= 24; i++)
                {
                    Database.AnalogOutputConfiguration dbConfiguration = new Database.AnalogOutputConfiguration();
                    dbConfiguration.Output = i;
                    dbConfiguration.OutputName = "Output #" + i;
                    dbConfiguration.OutputStatus = false;
                    dbConfiguration.CardSerial = _CardSerialNumber;
                    dbConfiguration.CardRevision = _CardRevision;
                    dbConfiguration.CardModel = _CardModel;
                    dbConfiguration.Save();
                }
            }

            // Initilize Datatable
            _dtOutputs = new DataTable();

            _dtOutputs.Columns.Add("output", typeof(int));
            _dtOutputs.Columns.Add("value", typeof(bool));
            DataRow row;
            for (int i = 1; i <= 24; i++)
            {
                row = _dtOutputs.NewRow();
                row["output"] = i;
                row["value"] = false;
                _dtOutputs.Rows.Add(row);
            }

            _dtOffsets = new DataTable();
            _dtOffsets.Columns.Add("offset", typeof(string));
            _dtOffsets.Columns.Add("bytes", typeof(int));
            _dtOffsets.Columns.Add("bit", typeof(int));
            _dtOffsets.Columns.Add("value", typeof(int));
            SetupScriptDatatable();

            xpCollectionCardInfo.Criteria = CriteriaOperator.Parse(String.Format("[CardModel] = '{0}' And [CardRevision] = '{1}' And [CardSerialNumber] = {2}", _CardModel, _CardRevision, _CardSerialNumber), null);

            xpCollectionConfiguration.Criteria = CriteriaOperator.Parse(String.Format("[CardRevision] = '{0}' And [CardModel] = '{1}' And [CardSerial] = {2}", _CardRevision, _CardModel, _CardSerialNumber), null);

            // Setup Group Control Boxes
            gcCardConfiguration.Dock = DockStyle.Fill;
            gcCardSettings.Dock = DockStyle.Fill;
            gcDebugLog.Dock = DockStyle.Fill;
            gcScripts.Dock = DockStyle.Fill;

            // Hide Group Control Boxes
            gcCardConfiguration.Visible = false;
            gcDebugLog.Visible = false;
            gcScripts.Visible = false;

            // Set Form Details
            objCardsDB = Session.DefaultSession.FindObject<Cards>(CriteriaOperator.Parse("[CardSerialNumber] == ? AND [CardModel] == ? AND [CardRevision] == ?", _CardSerialNumber, _CardModel, _CardRevision));
            DataBindings.Add("Text", objCardsDB, "CardName");
            //lblCardDescription.DataBindings.Add("Text", objCardsDB, "CardDescription");
            chkUSBConnected.DataBindings.Add("Text", objCardsDB, "CardConnected");
            xpCollectionConfiguration.Load();
            gridControl1.DataSource = xpCollectionConfiguration;
            gridControl1.ForceInitialize();

            SetupScriptDropDown();

            // Enable Timers
            //tmrInputConfigRefresh.Enabled = true;
            tmrCheckUSB.Enabled = true;
            tmrCheckFormDetails.Enabled = true;
        }
        private void LoadChildrenForms()
        {
            XPView cards = new XPView(Session.DefaultSession, typeof(Database.Cards));
            cards.AddProperty("Model", "CardModel");
            cards.AddProperty("Rev", "CardRevision");
            cards.AddProperty("Serial", "CardSerialNumber");
            foreach (ViewRecord record in cards)
            {
                switch ((string)record["Model"] + (string)record["Rev"])
                {
                    // Smart Sim Tech 30 Input Cards
                    case "SST30IBeta":
                        Boards.SST30I.Beta.frmSST30IBeta SST30IBeta = new Boards.SST30I.Beta.frmSST30IBeta();
                        SST30IBeta.MdiParent = this;
                        SST30IBeta.ParentFrm = this;
                        SST30IBeta.CardSerialNumber = (int)record["Serial"];
                        SST30IBeta.Show();
                        break;

                    case "SST30IR1":
                        Boards.SST30I.Rev1.frmSST30IR1 SST30IR1 = new Boards.SST30I.Rev1.frmSST30IR1();
                        SST30IR1.MdiParent = this;
                        SST30IR1.CardSerialNumber = (int)record["Serial"];
                        SST30IR1.Show();
                        break;

                    default:
                        break;
                }
            }
        }