예제 #1
0
        private void SetCityLookup()
        {
            CityItem             = new SaldoItem();
            CityItem.Name        = "Град ПК";
            CityItem.SysLookup   = true;
            CityItem.RCODELOOKUP = 6;
            CityItem.Relookup    = 6;
            var firstOrDefault = _Cities.FirstOrDefault(e => e.Id == CurrentFirma.City);

            if (firstOrDefault != null)
            {
                CityItem.Lookupval = firstOrDefault.Zip;
                CityItem.Value     = firstOrDefault.Name;
            }
            CityItem.LiD          = CurrentFirma.City;
            CityItem1             = new SaldoItem();
            CityItem1.SysLookup   = true;
            CityItem1.Name        = "Град ПК";
            CityItem1.RCODELOOKUP = 6;
            CityItem1.Relookup    = 6;
            CityItem1.LiD         = CurrentFirma.City1;
            firstOrDefault        = _Cities.FirstOrDefault(e => e.Id == CurrentFirma.City1);
            if (firstOrDefault != null)
            {
                CityItem1.Lookupval = firstOrDefault.Zip;
                CityItem1.Value     = firstOrDefault.Name;
            }
        }
예제 #2
0
 public LookUpSelector(SaldoItem fields)
 {
     vm          = new LookUpSelectorViewModel(fields);
     DataContext = vm;
     InitializeComponent();
     this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
 }
예제 #3
0
        public DdsViewModel(DdsDnevnikModel ddsmodel)
        {
            ddsDnevnikModel = ddsmodel;
            KindDocLookup   = new ObservableCollection <LookUpSpecific>(Context.GetAllDocTypes());
            if (ddsDnevnikModel.CodeDoc == null)
            {
                ddsDnevnikModel.CodeDoc = "01";
            }
            KindDoc            = KindDocLookup.FirstOrDefault(e => e.CodetId == ddsDnevnikModel.CodeDoc);
            ActivityTypeLookup = new ObservableCollection <LookUpSpecific>
            {
                new LookUpSpecific {
                    CodetId = "01", Id = 1, Name = "Покупки"
                },
                new LookUpSpecific {
                    CodetId = "02", Id = 2, Name = "Продажби"
                },
                new LookUpSpecific {
                    CodetId = "03", Id = 3, Name = "Други"
                },
            };
            this.Lookups = new ObservableCollection <LookUpMetaData>(Context.GetAllLookups(" where NAMEENG='k'"));

            AllFields = new ObservableCollection <DdsDnevnicItem>();
            foreach (var items in ddsDnevnikModel.DetailItems)
            {
                AllFields.Add(new DdsDnevnicItem(items));
            }
            if (ddsmodel.LookupID > 0)
            {
                Lookup = Lookups.FirstOrDefault(e => e.Id == ddsmodel.LookupID);
                if (Lookup == null)
                {
                    Lookup = ddsmodel.KindActivity == 2 ? Lookups.FirstOrDefault(e => e.Name == "Клиенти") : Lookups.FirstOrDefault(e => e.Name == "Доставчици");
                    ddsmodel.LookupElementID = 0;
                }
            }
            else
            {
                Lookup = ddsmodel.KindActivity == 2 ? Lookups.FirstOrDefault(e => e.Name == "Клиенти") : Lookups.FirstOrDefault(e => e.Name == "Доставчици");
            }
            if (SelectedItem == null)
            {
                SelectedItem = new SaldoItem();
            }
            SelectedItem.Value = ddsDnevnikModel.ClNum;
            Bustad             = ddsDnevnikModel.Bulstat;
            DdsId  = ddsDnevnikModel.Nzdds;
            ClName = ddsDnevnikModel.NameKontr;
            if (Lookup != null)
            {
                SelectedItem.Name = Lookup.Name;
            }
            OnPropertyChanged("SelectedItem");
            ddsDnevnikModel.Total = ddsDnevnikModel.DetailItems.Sum(e => e.DdsSuma).ToString(Vf.LevFormatUI);
        }
예제 #4
0
        public IEnumerable <SaldoItem> LoadCreditAnaliticAtributes()
        {
            List <SaldoItem> saldoItems = new List <SaldoItem>();
            SaldoItem        saldoItem  = new SaldoItem();

            //saldoItem.Name = NameLookUp;
            //saldoItem.Relookup = LookUpCode;
            saldoItem.IsLookUp = true;
            saldoItems.Add(saldoItem);
            return(saldoItems);
        }
예제 #5
0
        public static IEnumerable <SaldoItem> LoadCreditAnaliticAtributes(IEnumerable <SaldoAnaliticModel> fields, int typecpnto)
        {
            List <SaldoItem> saldoItems = new List <SaldoItem>();
            int offset = 16;

            if (typecpnto == 2)
            {
                offset = 60;
            }
            int current = 0;

            foreach (SaldoAnaliticModel analiticalFields in fields)
            {
                current++;
                //Titles.Add(analiticalFields.Name);
                SaldoItemTypes saldotype = SaldoItemTypes.String;
                if (analiticalFields.DBField == "integer")
                {
                    saldotype = SaldoItemTypes.Integer;
                }
                if (analiticalFields.DBField.Contains("DECIMAL"))
                {
                    saldotype = SaldoItemTypes.Currency;
                }
                if (analiticalFields.DBField == "Date")
                {
                    saldotype = SaldoItemTypes.Date;
                }

                SaldoItem saldoItem = new SaldoItem();
                saldoItem.Type        = saldotype;
                saldoItem.Name        = analiticalFields.Name;
                saldoItem.Value       = analiticalFields.VAL;
                saldoItem.Fieldkey    = analiticalFields.ACCFIELDKEY;
                saldoItem.IsK         = typecpnto == 0;
                saldoItem.IsD         = typecpnto == 1;
                saldoItem.Id          = analiticalFields.ID;
                saldoItem.KursDif     = analiticalFields.KURSD;
                saldoItem.ValueKurs   = analiticalFields.KURS;
                saldoItem.MainKurs    = analiticalFields.KURSM;
                saldoItem.ValueVal    = analiticalFields.VALVAL;
                saldoItem.ValueCredit = analiticalFields.VALUEMONEY;
                saldoItem.Lookupval   = analiticalFields.LOOKUPVAL;
                saldoItem.TabIndex    = offset + current;
                if (analiticalFields.ACCFIELDKEY == 29 || analiticalFields.ACCFIELDKEY == 30 ||
                    analiticalFields.ACCFIELDKEY == 31)
                {
                    saldoItem.IsDK = true;
                    if (analiticalFields.ACCFIELDKEY == 30)
                    {
                        //saldoItem.InfoTitle = "Валутен курс";
                        saldoItem.IsVal = true;
                    }
                    if (analiticalFields.ACCFIELDKEY == 31)
                    {
                        //    saldoItem.InfoTitle = "Единичнa цена";
                        saldoItem.IsKol    = true;
                        saldoItem.ValueKol = analiticalFields.VALVAL;
                        saldoItem.OnePrice = analiticalFields.KURS;
                    }
                }
                if (analiticalFields.LOOKUPID != 0)
                {
                    saldoItem.LiD = analiticalFields.LOOKUPFIELDKEY;

                    saldoItem.Relookup = analiticalFields.LOOKUPID;
                    saldoItem.IsLookUp = true;
                }
                saldoItems.Add(saldoItem);
            }
            return(saldoItems);
        }
예제 #6
0
        public IEnumerable <SaldoItem> LoadCreditAnaliticAtributes(IEnumerable <SaldoAnaliticModel> fields, int typecpnto,
                                                                   TempoDataBaseContext context)
        {
            List <SaldoItem> saldoItems = new List <SaldoItem>();

            foreach (SaldoAnaliticModel analiticalFields in fields)
            {
                //Titles.Add(analiticalFields.Name);
                SaldoItemTypes saldotype = SaldoItemTypes.String;
                if (analiticalFields.DBField == "integer")
                {
                    saldotype = SaldoItemTypes.Integer;
                }
                if (analiticalFields.DBField.Contains("DECIMAL"))
                {
                    saldotype = SaldoItemTypes.Currency;
                }
                if (analiticalFields.DBField == "Date")
                {
                    saldotype = SaldoItemTypes.Date;
                }
                SaldoItem saldoItem = new SaldoItem
                {
                    Name        = analiticalFields.Name,
                    Type        = saldotype,
                    Value       = analiticalFields.VAL,
                    Fieldkey    = analiticalFields.ACCFIELDKEY,
                    IsK         = typecpnto == 0,
                    IsD         = typecpnto == 1,
                    Id          = analiticalFields.ID,
                    KursDif     = analiticalFields.KURSD,
                    ValueKurs   = analiticalFields.KURS,
                    MainKurs    = analiticalFields.KURSM,
                    ValueVal    = analiticalFields.VALVAL,
                    ValueCredit = analiticalFields.VALUEMONEY,
                    Lookupval   = analiticalFields.LOOKUPVAL
                };
                if (analiticalFields.ACCFIELDKEY == 29 || analiticalFields.ACCFIELDKEY == 30 ||
                    analiticalFields.ACCFIELDKEY == 31)
                {
                    saldoItem.IsDK = true;
                    if (analiticalFields.ACCFIELDKEY == 30)
                    {
                        saldoItem.InfoTitle = "Валутен курс";
                        saldoItem.IsVal     = true;
                    }
                    if (analiticalFields.ACCFIELDKEY == 31)
                    {
                        saldoItem.InfoTitle = "Единичнa цена";
                        saldoItem.IsKol     = true;
                    }
                }


                if (analiticalFields.LOOKUPID != 0)
                {
                    saldoItem.Key      = analiticalFields.LOOKUPFIELDKEY.ToString();
                    saldoItem.IsLookUp = true;
                    saldoItem.Relookup = analiticalFields.LOOKUPID;
                    LookupModel lm   = context.GetLookup(analiticalFields.LOOKUPID);
                    var         list = context.GetLookup(lm.LookUpMetaData.Tablename,
                                                         1);
                    int k = 0;
                    foreach (IEnumerable <string> enumerable in list)
                    {
                        int       i         = 0;
                        SaldoItem saldoitem = new SaldoItem();
                        saldoitem.Name = saldoItem.Name;
                        foreach (string s in enumerable)
                        {
                            if (i == 2)
                            {
                                saldoitem.Value = s;
                            }
                            if (i == 1)
                            {
                                saldoitem.Key = s;
                            }
                            if (k == 0 && i == 1)
                            {
                                k++;
                            }
                            if (k == 1 && i == 2)
                            {
                                k++;
                            }
                            i++;
                        }
                        saldoItem.LookUp.Add(saldoitem);
                        saldoItem.SelectedLookupItem =
                            saldoItem.LookUp.FirstOrDefault(e => e.Value == saldoItem.Value);
                    }
                }

                saldoItems.Add(saldoItem);
            }
            return(saldoItems);
        }
예제 #7
0
        //REALIZAR PROCESO-------------------------------------
        protected void NewAjust(Object Sender, EventArgs E)
        {
            if (chkCerrarO.Checked == true)
            {
                Totales();
            }
            btnAjus.Enabled = false;
            int       diasP = 0; //Dias plazo
            double    vFlet, vIVAFlet, total, vDescuento, vIVA, vExternos;
            DateTime  fechaProceso;
            string    vend, codigoAlmacen, ccos, carg, prefE, ano_cinv, tipoE;
            UInt64    numPre;
            ArrayList sqlStrings;

            #region Validaciones
            try{ numPre = Convert.ToUInt32(txtNumFacE.Text); }
            catch { Utils.MostrarAlerta(Response, "El número de entrada de almacén no es valido!"); BindDatas(); return; }

            try{ diasP = Convert.ToInt32(txtPlazo.Text); }
            catch { Utils.MostrarAlerta(Response, "Los días de plazo no son válidos!"); BindDatas(); return; }

            try
            {
                vDescuento = Convert.ToDouble(txtDesc.Text);
            }
            catch
            {
                Utils.MostrarAlerta(Response, "El valor de los descuentos no es válido!");
                return;
            }

            try
            {
                vExternos = Convert.ToDouble(txtTotalExternos.Text);
            }
            catch
            {
                Utils.MostrarAlerta(Response, "El valor de los totales externos no es valido!");
                return;
            }

            try
            {
                vFlet = Convert.ToDouble(txtFlet.Text);
            }
            catch
            {
                Utils.MostrarAlerta(Response, "El valor de los fletes no es valido!");
                return;
            }
            try
            {
                vIVAFlet = Convert.ToDouble(txtTotIF.Text);
            }
            catch
            {
                Utils.MostrarAlerta(Response, "El valor IVA de los fletes no es valido!");
                return;
            }
            try
            {
                vIVA = Convert.ToDouble(txtIVA.Text);
            }
            catch
            {
                Utils.MostrarAlerta(Response, "El valor del IVA no es valido!");
                return;
            }
            try
            {
                fechaProceso = Convert.ToDateTime(tbDate.Text);
            }
            catch
            {
                Utils.MostrarAlerta(Response, "Fecha de proceso no es valido!");
                return;
            }
            try
            {
                total = Convert.ToDouble(txtTotal.Text);
            }
            catch
            {
                Utils.MostrarAlerta(Response, "El valor del total no es valido!");
                return;
            }
            if (vExternos < vDescuento)
            {
                Utils.MostrarAlerta(Response, "Los descuentos no pueden superar los valores externos!");
                return;
            }
            //Validar total
            if (Math.Abs((vExternos - vDescuento + vIVA + vFlet + vIVAFlet) - (total)) > 0.009)
            {
                Utils.MostrarAlerta(Response, "El valor del total no coincide!");
                BindDatas();
                return;
            }
            #endregion Validaciones

            //Aqui Iniciamos el proceso como tal, habiendo superado con exito el proceso de validacion
            vend          = ddlVendedor.SelectedValue;   //Codigo del Vendedor
            codigoAlmacen = ddlAlmacen.SelectedValue;
            ccos          = DBFunctions.SingleData("SELECT pcen_centinv FROM palmacen WHERE palm_almacen='" + codigoAlmacen + "'");
            carg          = DBFunctions.SingleData("SELECT TVEND_CODIGO FROM PVENDEDOR WHERE PVEN_CODIGO='" + vend + "'"); //Cargo???????
            prefE         = "";                                                                                            //Prefijo Documento Interno (PDOCUMENTO)
            numPre        = 0;                                                                                             //Numero de Documento Interno (PDOCUMENTO)
            ano_cinv      = ConfiguracionInventario.Ano;
            tipoE         = DBFunctions.SingleData("SELECT MORD_TIPO FROM MORDENPRODUCCION WHERE PDOC_CODIGO='" + ddlPrefOrden.SelectedValue + "' AND MORD_NUMEORDE=" + ddlNumOrden.SelectedValue + ";");
            sqlStrings    = new ArrayList();

            #region Factura Proveedor
            ArrayList        arrRecepciones          = new ArrayList();
            FacturaProveedor facturaRepuestos        = new FacturaProveedor();
            string           prefijoFacturaProveedor = ddlPrefE.SelectedValue;
            UInt64           numeroFacturaProveedor  = Convert.ToUInt64(txtNumFacE.Text.Trim());
            prefE  = prefijoFacturaProveedor;
            numPre = numeroFacturaProveedor;

            if (DBFunctions.RecordExist("SELECT * FROM mfacturaproveedor WHERE pdoc_codiordepago='" + prefijoFacturaProveedor + "' AND mfac_numeordepago=" + numeroFacturaProveedor + ""))
            {
                numeroFacturaProveedor = Convert.ToUInt32(DBFunctions.SingleData("SELECT pdoc_ultidocu+1 FROM pdocumento WHERE pdoc_codigo='" + prefijoFacturaProveedor + "'"));
            }

            FacturaProveedor facturaRepuestosProv    = new FacturaProveedor("FPR", prefijoFacturaProveedor,
                                                                            ddlPrefOrden.SelectedValue, txtNIT.Text.Trim(), ddlAlmacen.SelectedValue, "F", numeroFacturaProveedor,
                                                                            Convert.ToUInt64(ddlNumOrden.SelectedValue), "P", fechaProceso,
                                                                            fechaProceso.AddDays(Convert.ToDouble(txtPlazo.Text.Trim())),
                                                                            Convert.ToDateTime(null), fechaProceso, vExternos - vDescuento,
                                                                            vIVA, vFlet, vIVAFlet, 0, txtObs.Text,
                                                                            HttpContext.Current.User.Identity.Name.ToLower());

            facturaRepuestosProv.GrabarFacturaProveedor(false);
            numPre = facturaRepuestosProv.NumeroFactura;

            for (int i = 0; i < facturaRepuestosProv.SqlStrings.Count; i++)
            {
                sqlStrings.Add(facturaRepuestosProv.SqlStrings[i].ToString());
            }
            #endregion Factura Proveedor

            #region Retenciones
            DataTable dtRet = TablaRetenciones();
            dtRet.Rows[0][0]  = "1";
            dtRet.Rows[0][1]  = DBFunctions.SingleData("SELECT MITE_CODIGO FROM MITEMS WHERE TORI_CODIGO='X' FETCH FIRST 1 ROWS ONLY;");
            dtRet.Rows[0][2]  = "";
            dtRet.Rows[0][3]  = 1;
            dtRet.Rows[0][4]  = 1;
            dtRet.Rows[0][5]  = vExternos;
            dtRet.Rows[0][6]  = vDescuento;
            dtRet.Rows[0][7]  = (vIVA * 100) / vExternos;
            dtRet.Rows[0][8]  = "";
            dtRet.Rows[0][9]  = total;
            dtRet.Rows[0][10] = "";
            dtRet.Rows[0][11] = "";
            try
            {
                Retencion RetencionItems = new Retencion(facturaRepuestosProv.NitProveedor,
                                                         facturaRepuestosProv.PrefijoFactura,
                                                         Convert.ToInt32(facturaRepuestosProv.NumeroFactura),
                                                         dtRet,
                                                         (facturaRepuestosProv.ValorFactura + facturaRepuestosProv.ValorFletes),
                                                         (facturaRepuestosProv.ValorIva + facturaRepuestosProv.ValorIvaFletes),
                                                         "R", false);

                RetencionItems.Guardar_Retenciones(false);

                for (int i = 0; i < RetencionItems.Sqls.Count; i++)
                {
                    sqlStrings.Add(RetencionItems.Sqls[i].ToString());
                }
            }
            catch (Exception ex)
            {
                Utils.MostrarAlerta(Response, "Error en Retenciones. Detalles : \\n" + ex.Message + "");
                return;
            }
            #endregion

            #region Movimiento de Kardex
            string ano_cont = ConfiguracionInventario.Ano;

            int tm = 20;            //Entradas de proveedor
            //Creamos el Objeto manejador de movimientos de kardex utilizando el constructor #2
            Movimiento Mov = new Movimiento(prefE, numPre, tm, fechaProceso, txtNIT.Text, codigoAlmacen, vend, carg, ccos, "N");

            double cant, valU, costP, costPH, costPA, costPHA, invI, invIA, pIVA, pDesc, cantDev, valP;

            ArrayList Prrs    = new ArrayList();         //Prerecepciones de la lista
            DataTable dtItems = (DataTable)ViewState["ITEMS"];
            //DITEMS
            for (int n = 0; n < dtItems.Rows.Count; n++)
            {
                string codI = dtItems.Rows[n]["CODIGO"].ToString();
                string prefijoDocumentoReferencia = "";
                UInt64 numeroDocumentoReferencia  = 0;
                prefijoDocumentoReferencia = ddlPrefOrden.SelectedValue;                  // prefijo Orden
                numeroDocumentoReferencia  = Convert.ToUInt32(ddlNumOrden.SelectedValue); // Numero Orden
                cant    = Convert.ToDouble(dtItems.Rows[n]["CANTIDAD"]);                  //cantidad ingresada
                valU    = Convert.ToDouble(dtItems.Rows[n]["VALOR"]);                     //(Costeo)
                pIVA    = 0;                                                              //iva
                pDesc   = 0;                                                              //descuento
                costP   = SaldoItem.ObtenerCostoPromedio(codI, ano_cont);
                costPH  = SaldoItem.ObtenerCostoPromedioHistorico(codI, ano_cont);
                costPA  = SaldoItem.ObtenerCostoPromedioAlmacen(codI, ano_cont, codigoAlmacen);
                costPHA = SaldoItem.ObtenerCostoPromedioHistoricoAlmacen(codI, ano_cont, codigoAlmacen);
                invI    = SaldoItem.ObtenerCantidadActual(codI, ano_cont);                       //Inventario inicial
                invIA   = SaldoItem.ObtenerCantidadActualAlmacen(codI, ano_cont, codigoAlmacen); //Inventario inicial Almacen
                cantDev = 0;                                                                     //devolucion
                valP    = costP;                                                                 //Valor publico
                Mov.InsertaFila(codI, cant, valU, costP, costPA, pIVA, pDesc, cantDev, costPH, costPHA, valP, invI, invIA, prefijoDocumentoReferencia, numeroDocumentoReferencia);
                //				0	  1		2	3		4	 5		6		7	  8		9	   10	11	  12			13							14
            }

            Mov.RealizarMov(false);
            for (int i = 0; i < Mov.SqlStrings.Count; i++)
            {
                sqlStrings.Add(Mov.SqlStrings[i].ToString());
            }
            #endregion

            #region Actualizar detalle y orden produccion
            //Actualizar cantidad entregada
            for (int n = 0; n < dtItems.Rows.Count; n++)
            {
                sqlStrings.Add(
                    "UPDATE DORDENPRODUCCION SET " +
                    "DORD_CANTENTR=DORD_CANTENTR+" + dtItems.Rows[n]["CANTIDAD"] + " " +
                    "WHERE PDOC_CODIGO='" + ddlPrefOrden.SelectedValue + "' AND " +
                    "MORD_NUMEORDE=" + ddlNumOrden.SelectedValue + " AND " +
                    "PENS_CODIGO='" + dtItems.Rows[n]["ENSAMBLE"] + "' AND " +
                    "MITE_CODIGO='" + dtItems.Rows[n]["CODIGO"] + "';");
            }

            //cerrar mordenproduccion si se recibieron todos los items
            sqlStrings.Add(
                "UPDATE MORDENPRODUCCION MO SET MO.TEST_ESTADO='F' " +
                "WHERE MO.pdoc_codigo='" + ddlPrefOrden.SelectedValue + "' AND mord_numeorde=" + ddlNumOrden.SelectedValue + " AND " +
                "NOT EXISTS(" +
                " SELECT * FROM DORDENPRODUCCION DOR " +
                " WHERE " +
                " DOR.pdoc_codigo=MO.pdoc_codigo AND DOR.mord_numeorde=MO.mord_numeorde AND " +
                " DOR.DORD_CANTXPROD>DORD_CANTENTR " +
                ");");
            #endregion

            #region Costeo
            //Costeo
            sqlStrings.Add("INSERT INTO dcostoproduccion values(" +
                           "'" + ddlPrefE.SelectedValue + "'," + numPre + "," +
                           Convert.ToDouble(ViewState["TOT_MATPRIMA"]).ToString() + "," +
                           Convert.ToDouble(ViewState["TOT_TERCEROS"]).ToString() + "," +
                           Convert.ToDouble(ViewState["TOT_MANOBRA"]).ToString() + "," +
                           Convert.ToDouble(ViewState["TOT_CIF"]).ToString() + "," +
                           Convert.ToDouble(ViewState["TOT_MAQUINARIA"]).ToString() + "," +
                           "'" + ViewState["MITE_CODIGO"].ToString() + "'" +
                           ");");
            #endregion Costeo

            //Cerrar orden de producción
            if (chkCerrarO.Checked == true)
            {
                string sql = CerrarOrdenProduccion();
                if (sql != "")
                {
                    sqlStrings.Add(sql);
                }
                else
                {
                    Utils.MostrarAlerta(Response, "Se presentó un error al intentar cerrar la orden de ooperación!");
                    return;
                }
            }

            if (chkCerrarO.Checked == false)
            {
                if (DBFunctions.Transaction(sqlStrings))
                {
                    Response.Redirect("" + indexPage + "?process=Produccion.EntradasProduccion&path=" + Request.QueryString["path"] + "&pref=" + prefijoFacturaProveedor + "&num=" + numeroFacturaProveedor);
                }
                else
                {
                    lbInfo.Text += "<br>Error : Detalles <br>" + DBFunctions.exceptions;
                }
            }
            else
            {
                if (DBFunctions.Transaction(sqlStrings) && RealizarAjusteInventario())
                {
                    Response.Redirect("" + indexPage + "?process=Produccion.EntradasProduccion&path=" + Request.QueryString["path"] + "&pref=" + prefijoFacturaProveedor + "&num=" + numeroFacturaProveedor + "&act=1&prefA=" + ddlPrefijoAjuste.SelectedValue + "&numA=" + lblNumeroAjuste.Text);
                }
                else
                {
                    lbInfo.Text += "<br>Error : Detalles <br>" + DBFunctions.exceptions;
                }
            }
        }
예제 #8
0
        public LookupsEdidViewModels(IEnumerable <FieldValuePair> fields, string tableName, bool insert)
        {
            _Fields = new ObservableCollection <FieldValuePair>(fields);
            string bulsi = "";

            if (!insert)
            {
                return;
            }
            foreach (FieldValuePair fieldValuePair in _Fields)
            {
                if (fieldValuePair.Name == "БУЛСТАТ" || fieldValuePair.Name == "ЗДДС номер")
                {
                    if (!string.IsNullOrWhiteSpace(fieldValuePair.Value))
                    {
                        bulsi = fieldValuePair.Value;
                    }
                }
                if (!string.IsNullOrWhiteSpace(fieldValuePair.RTABLENAME))
                {
                    if (fieldValuePair.RTABLENAME == "AUTO")
                    {
                        fieldValuePair.Value    = Context.SelectMax(tableName, fieldValuePair.FieldName);
                        fieldValuePair.ReadOnly = false;
                    }
                    else
                    {
                        fieldValuePair.IsLookUp = true;
                        fieldValuePair.LookUp   = new ObservableCollection <SaldoItem>();
                        var list = Context.GetSysLookup(fieldValuePair.RTABLENAME);
                        int k    = 0;
                        foreach (List <string> enumerable in list)
                        {
                            int       i         = 0;
                            SaldoItem saldoitem = new SaldoItem();
                            saldoitem.Value = enumerable[2];
                            saldoitem.Key   = enumerable[1];



                            fieldValuePair.LookUp.Add(saldoitem);
                        }
                        fieldValuePair.SelectedLookupItem =
                            fieldValuePair.LookUp.FirstOrDefault(e => e.Key == fieldValuePair.Value);
                    }
                }
                if (!string.IsNullOrWhiteSpace(fieldValuePair.Tn))
                {
                    fieldValuePair.IsLookUp = true;
                    fieldValuePair.LookUp   = new ObservableCollection <SaldoItem>();
                    var list = Context.GetSysLookup(fieldValuePair.Tn);
                    int k    = 0;
                    foreach (List <string> enumerable in list)
                    {
                        int       i         = 0;
                        SaldoItem saldoitem = new SaldoItem();
                        saldoitem.Value = enumerable[2];
                        saldoitem.Key   = enumerable[1];



                        fieldValuePair.LookUp.Add(saldoitem);
                    }
                    fieldValuePair.SelectedLookupItem =
                        fieldValuePair.LookUp.FirstOrDefault(e => e.Key == fieldValuePair.Value);
                }
            }
            foreach (FieldValuePair fieldValuePair in _Fields)
            {
                if (fieldValuePair.Name == "БУЛСТАТ" || fieldValuePair.Name == "ЗДДС номер")
                {
                    fieldValuePair.Value = bulsi;
                }
            }
        }
예제 #9
0
        private static void SetAnaliticVal(string s, TempoDataBaseContext context, ContoAll allconto, int i)
        {
            SaldoItem item = null;

            switch (i)
            {
            case 0:
                if (allconto.ItemsDebit != null && allconto.ItemsDebit.Count > 0)
                {
                    item = allconto.ItemsDebit[0];
                }
                Bulstad = s;
                if (item == null)
                {
                    var item1 = new SaldoItem {
                        SysLookup = false, Relookup = 17
                    };
                    var mainrez = item1.GetDictionary(
                        string.Format("AND \"{0}\"='{1}'", "BULSTAT", s),
                        string.Format(" order by \"{0}\"", "BULSTAT"));
                    if (mainrez.Count <= 1)
                    {
                        var lookupModel = context.GetLookup(17);
                        CodeClient = context.SelectMax(lookupModel.LookUpMetaData.Tablename, lookupModel.Fields[1].NameEng);
                        var lookupval = allconto.NameClient;
                        lookupModel.Fields.Add(new TableField {
                            DbField = "integer", GROUP = 4, Id = 4, Length = 4, IsRequared = false, NameEng = "FIRMAID", Name = "Фирма Номер"
                        });
                        context.SaveRow(new List <string> {
                            CodeClient, CodeClient, lookupval, lookupval, s, s
                        }, lookupModel, FirmaId);
                    }
                    else
                    {
                        CodeClient          = mainrez[1][0];
                        allconto.NameClient = mainrez[1][1];
                        int h = 0;
                        if (int.TryParse(mainrez[1][0], out h))
                        {
                            LiD = item1.GetLookUpId(0);
                        }
                        if (mainrez[1].Count > 4)
                        {
                            Bulstad = mainrez[1][3];
                            Vat     = mainrez[1][4];
                        }
                    }
                }
                break;

            case 1:
                if (allconto.ItemsDebit != null && allconto.ItemsDebit.Count > 1)
                {
                    item = allconto.ItemsDebit[1];
                }

                Factura = s;
                break;

            case 2:
                if (allconto.ItemsDebit != null && allconto.ItemsDebit.Count > 2)
                {
                    item = allconto.ItemsDebit[2];
                }
                DateTime date1;
                if (DateTime.TryParse(s, out date1))
                {
                    DataFactura = date1;
                }
                else
                {
                    var c = s.Split('.');
                    if (c.Length > 2)
                    {
                        DataFactura = new DateTime(int.Parse(c[2]), int.Parse(c[1]), int.Parse(c[0]));
                    }
                    else
                    {
                        DataFactura = DateTime.Now;
                    }
                }
                break;

            case 3:
                if (allconto.ItemsDebit != null && allconto.ItemsDebit.Count > 3)
                {
                    item = allconto.ItemsDebit[3];
                }
                break;

            case 4:
                if (allconto.ItemsCredit != null && allconto.ItemsCredit.Count > 0)
                {
                    item = allconto.ItemsCredit[0];
                }
                Bulstad = s;
                if (item == null)
                {
                    var item1 = new SaldoItem {
                        SysLookup = false, Relookup = 17
                    };
                    var mainrez = item1.GetDictionary(
                        string.Format("AND \"{0}\"='{1}'", "BULSTAT", s),
                        string.Format(" order by \"{0}\"", "BULSTAT"));
                    if (mainrez.Count <= 1)
                    {
                        var lookupModel = context.GetLookup(17);
                        CodeClient = context.SelectMax(lookupModel.LookUpMetaData.Tablename, lookupModel.Fields[1].NameEng);
                        var lookupval = allconto.NameClient;
                        lookupModel.Fields.Add(new TableField {
                            DbField = "integer", GROUP = 4, Id = 4, Length = 4, IsRequared = false, NameEng = "FIRMAID", Name = "Фирма Номер"
                        });
                        context.SaveRow(new List <string> {
                            CodeClient, CodeClient, lookupval, lookupval, s, s
                        }, lookupModel, FirmaId);
                    }
                    else
                    {
                        CodeClient          = mainrez[1][1];
                        allconto.NameClient = mainrez[1][2];
                        int h = 0;
                        if (int.TryParse(mainrez[1][0], out h))
                        {
                            LiD = item1.GetLookUpId(0);
                        }
                        if (mainrez[1].Count > 4)
                        {
                            Bulstad = mainrez[1][3];
                            Vat     = mainrez[1][4];
                        }
                    }
                }
                break;

            case 5:
                if (allconto.ItemsCredit != null && allconto.ItemsCredit.Count > 1)
                {
                    item = allconto.ItemsCredit[1];
                }
                Factura = s;
                break;

            case 6:
                if (allconto.ItemsCredit != null && allconto.ItemsCredit.Count > 2)
                {
                    item = allconto.ItemsCredit[2];
                }
                DateTime date2;
                if (DateTime.TryParse(s, out date2))
                {
                    DataFactura = date2;
                }
                else
                {
                    var c = s.Split('.');
                    if (c.Length > 2)
                    {
                        DataFactura = new DateTime(int.Parse(c[2]), int.Parse(c[1]), int.Parse(c[0]));
                    }
                    else
                    {
                        DataFactura = DateTime.Now;
                    }
                }
                break;

            case 7:
                if (allconto.ItemsCredit != null && allconto.ItemsCredit.Count > 3)
                {
                    item = allconto.ItemsCredit[3];
                }
                break;
            }
            if (item != null)
            {
                if (!item.IsLookUp)
                {
                    item.Value = s;
                }
                else
                {
                    if (item.Name == "Контрагент")
                    {
                        var mainrez = item.GetDictionary(
                            string.Format("AND \"{0}\"='{1}'", "BULSTAT", s),
                            string.Format(" order by \"{0}\"", "BULSTAT"));
                        if (mainrez != null && mainrez.Count > 1)
                        {
                            item.Value     = mainrez[1][0];
                            item.Lookupval = mainrez[1][1];
                            int h = 0;
                            if (int.TryParse(mainrez[1][0], out h))
                            {
                                item.LiD = item.GetLookUpId(0);
                            }
                            if (mainrez[1].Count > 4)
                            {
                                item.Bulstad = mainrez[1][3];
                                item.Vat     = mainrez[1][4];
                            }
                        }
                        else
                        {
                            var lookupModel = context.GetLookup(17);
                            item.Value     = context.SelectMax(lookupModel.LookUpMetaData.Tablename, lookupModel.Fields[1].NameEng);
                            item.Lookupval = allconto.NameClient;
                            item.Bulstad   = s;
                            item.Vat       = s;
                            lookupModel.Fields.Add(new TableField {
                                DbField = "integer", GROUP = 4, Id = 4, Length = 4, IsRequared = false, NameEng = "FIRMAID", Name = "Фирма Номер"
                            });
                            context.SaveRow(new List <string> {
                                item.Value, item.Value, item.Lookupval, item.Lookupval, s, s
                            }, lookupModel, FirmaId);
                        }
                    }
                }
            }
        }
예제 #10
0
        public EditorAddSaldosViewModel(AccountsModel acc, int groupid, long typeAnaliticalKey)
        {
            IsEdit                 = true;
            Title                  = string.Format("Редактиране на салдо по сметка {0}", acc);
            this.AccID             = acc.Id;
            this.Acc               = acc;
            this.GroupId           = groupid;
            _items                 = new ObservableCollection <SaldoItem>();
            this.typeAnaliticalKey = typeAnaliticalKey;
            List <SaldoAnaliticModel> fields = new List <SaldoAnaliticModel>(Context.GetCurrentMovements(acc.Id, groupid));
            int tabindex = 1;

            foreach (SaldoAnaliticModel analiticalFields in fields)
            {
                //Titles.Add(analiticalFields.Name);
                SaldoItemTypes saldotype = SaldoItemTypes.String;
                if (analiticalFields.DBField == "integer")
                {
                    saldotype = SaldoItemTypes.Integer;
                }
                if (analiticalFields.DBField.Contains("DECIMAL"))
                {
                    saldotype = SaldoItemTypes.Currency;
                }
                if (analiticalFields.DBField == "Date")
                {
                    saldotype = SaldoItemTypes.Date;
                }
                SaldoItem saldoItem = new SaldoItem
                {
                    Name         = analiticalFields.Name,
                    Type         = saldotype,
                    Value        = analiticalFields.VAL + analiticalFields.VALS,
                    Valued       = analiticalFields.VALUED.ToString(),
                    Fieldkey     = analiticalFields.ACCFIELDKEY,
                    IsInUnigroup = analiticalFields.Required,
                    TabIndex     = tabindex,
                    Vals         = analiticalFields.VALS
                };
                tabindex++;
                if (analiticalFields.ACCFIELDKEY == 30)
                {
                    saldoItem.ValueCredit = analiticalFields.VALVALK;
                    saldoItem.ValueDebit  = analiticalFields.VALVALD;
                    saldoItem.IsVal       = true;
                    saldoItem.IsDK        = true;
                }
                if (analiticalFields.ACCFIELDKEY == 31)
                {
                    saldoItem.ValueCredit = analiticalFields.VALKOLK;
                    saldoItem.ValueDebit  = analiticalFields.VALKOLD;
                    saldoItem.IsKol       = true;
                    saldoItem.IsDK        = true;
                }
                if (analiticalFields.ACCFIELDKEY == 29)
                {
                    saldoItem.ValueCredit = analiticalFields.VALUEMONEY;
                    saldoItem.ValueDebit  = analiticalFields.VALUED;
                    saldoItem.IsDK        = true;
                }

                //if (analiticalFields.LOOKUPID != 0)
                //{
                //    saldoItem.Key = analiticalFields.LOOKUPFIELDKEY.ToString();
                //    saldoItem.IsLookUp = true;
                //    saldoItem.Relookup = analiticalFields.LOOKUPID;
                //    LookupModel lm = context.GetLookup(analiticalFields.LOOKUPID);
                //    var list = context.GetLookup(lm.LookUpMetaData.Tablename);
                //    int k = 0;
                //    foreach (IEnumerable<string> enumerable in list)
                //    {
                //        int i = 0;
                //        SaldoItem saldoitem = new SaldoItem();

                //        foreach (string s in enumerable)
                //        {

                //            if (i == 2) saldoitem.Value = s;
                //            if (i == 1) saldoitem.Key = s;
                //            if (k == 0 && i == 1)
                //            {
                //                saldoItem.Key = s;
                //                k++;
                //            }
                //            if (k == 1 && i == 2)
                //            {
                //                saldoItem.Value = s;
                //                k++;
                //            }
                //            i++;
                //        }
                //        saldoItem.LookUp.Add(saldoitem);

                //    }
                //}
                _items.Add(saldoItem);
            }
        }
예제 #11
0
        private IEnumerable <SaldoItem> LoadAccFieldsMetaData(AccountsModel acc)
        {
            AllAnaliticTypes     = new ObservableCollection <AnaliticalAccountType>(Context.GetAllAnaliticalAccountType());
            AllAnaliticalAccount = new ObservableCollection <AnaliticalAccount>(Context.GetAllAnaliticalAccount());
            AllAnaliticalFields  = new ObservableCollection <AnaliticalFields>(Context.GetAllAnaliticalFields());
            AllConnectors        =
                new ObservableCollection <MapAnanaliticAccToAnaliticField>(Context.GetAllConnectorAnaliticField());
            AlaMapToType                 = new ObservableCollection <MapAnanaliticAccToAnaliticField>(Context.GetAllConnectorTypeField());
            SelectedAnaliticalFields     = new ObservableCollection <AnaliticalFields>();
            SelectedAnaliticalTypeFields = new ObservableCollection <AnaliticalFields>();

            SelectedAnaliticalFields.Clear();
            var CurrentAllAnaliticalAccount = AllAnaliticalAccount.FirstOrDefault(e => e.Id == acc.AnaliticalNum);

            //AnaliticalAccountType CurrentAllTypeAccount = AllAnaliticTypes.FirstOrDefault(e => e.Id == CurrentAllAnaliticalAccount.Id);
            SelectedConnectors =
                new ObservableCollection <MapAnanaliticAccToAnaliticField>(
                    AllConnectors.Where(e => CurrentAllAnaliticalAccount != null && e.AnaliticalNameID == CurrentAllAnaliticalAccount.Id));
            foreach (var curr in SelectedConnectors.OrderBy(e => e.SortOrder))
            {
                var addfield = AllAnaliticalFields.Where(e => e.Id == curr.AnaliticalFieldId).FirstOrDefault();
                if (addfield != null)
                {
                    addfield.Requared = curr.Required;
                    if (addfield != null)
                    {
                        SelectedAnaliticalFields.Add(addfield);
                    }
                }
            }
            Context.LoadMapToLookUps(SelectedAnaliticalFields, acc.Id, acc.AnaliticalNum);
            SelectedConnectors =
                new ObservableCollection <MapAnanaliticAccToAnaliticField>(
                    AlaMapToType.Where(e => e.AnaliticalFieldId == CurrentAllAnaliticalAccount.TypeID));
            SelectedAnaliticalTypeFields.Clear();
            foreach (var curr in SelectedConnectors)
            {
                var addfield = AllAnaliticalFields.FirstOrDefault(e => e.Id == curr.AnaliticalNameID);
                if (addfield != null)
                {
                    addfield.Requared = curr.Required;
                    SelectedAnaliticalTypeFields.Add(addfield);
                }
            }
            ObservableCollection <AnaliticalFields> sFieldses = new ObservableCollection <AnaliticalFields>();

            CurrentAllTypeAccount = AllAnaliticTypes.FirstOrDefault(e => e.Id == CurrentAllAnaliticalAccount.TypeID);
            if (CurrentAllTypeAccount != null)
            {
                if (CurrentAllTypeAccount.Sl)
                {
                    sFieldses.Add(AllAnaliticalFields.FirstOrDefault(f => f.Name == "Сума лв."));
                }
                if (CurrentAllTypeAccount.Sv)
                {
                    sFieldses.Add(AllAnaliticalFields.FirstOrDefault(f => f.Name == "Сума валута"));
                }
                if (CurrentAllTypeAccount.Kol)
                {
                    sFieldses.Add(AllAnaliticalFields.FirstOrDefault(f => f.Name == "Количество"));
                }
            }
            else
            {
                sFieldses.Add(AllAnaliticalFields.FirstOrDefault(f => f.Name == "Сума лв."));
            }
            Titles   = new ObservableCollection <string>();
            Contents = new ObservableCollection <ObservableCollection <string> >();
            ObservableCollection <string>    vals        = new ObservableCollection <string>();
            ObservableCollection <SaldoItem> _saldoItems = new ObservableCollection <SaldoItem>();
            int tabitem = 1;

            foreach (AnaliticalFields analiticalFields in sFieldses)
            {
                Titles.Add(analiticalFields.Name + "Кредит");
                Titles.Add(analiticalFields.Name + "Дебит");

                SaldoItemTypes saldotype = SaldoItemTypes.String;
                if (analiticalFields.FieldType == "integer")
                {
                    saldotype = SaldoItemTypes.Integer;
                }
                if (analiticalFields.FieldType.Contains("DECIMAL"))
                {
                    saldotype = SaldoItemTypes.Currency;
                }
                if (analiticalFields.FieldType == "Date")
                {
                    saldotype = SaldoItemTypes.Date;
                }
                SaldoItem saldoItem = new SaldoItem
                {
                    Name         = analiticalFields.Name,
                    Type         = saldotype,
                    Length       = 50,
                    Value        = Vf.LevFormatUI,
                    Valued       = Vf.LevFormatUI,
                    IsDK         = true,
                    Fieldkey     = analiticalFields.Id,
                    IsInUnigroup = analiticalFields.Requared,
                    TabIndex     = tabitem
                };
                tabitem++;
                if (analiticalFields.Name == "Количество")
                {
                    saldoItem.IsKol = true;
                }
                if (analiticalFields.Name == "Сума валута")
                {
                    saldoItem.IsVal = true;
                }
                if (analiticalFields.Name == "Валутен курс")
                {
                    saldoItem.IsKurs = true;
                }
                _saldoItems.Add(saldoItem);
            }
            foreach (AnaliticalFields analiticalFields in SelectedAnaliticalFields)
            {
                Titles.Add(analiticalFields.Name);
                SaldoItemTypes saldotype = SaldoItemTypes.String;
                string         defvalue  = "";
                if (analiticalFields.FieldType == "integer")
                {
                    saldotype = SaldoItemTypes.Integer;
                    defvalue  = "0";
                }
                if (analiticalFields.FieldType == "decimal")
                {
                    saldotype = SaldoItemTypes.Currency;
                    defvalue  = Vf.LevFormatUI;
                }
                if (analiticalFields.FieldType == "Date")
                {
                    saldotype = SaldoItemTypes.Date;
                    defvalue  = DateTime.Now.ToShortDateString();
                }
                SaldoItem saldoItem = new SaldoItem
                {
                    Name         = analiticalFields.Name,
                    Type         = saldotype,
                    Value        = defvalue,
                    Fieldkey     = analiticalFields.Id,
                    IsInUnigroup = analiticalFields.Requared,
                    TabIndex     = tabitem
                };
                tabitem++;
                if (analiticalFields.IdLookUp != 0)
                {
                    saldoItem.IsLookUp = true;
                    saldoItem.Relookup = analiticalFields.IdLookUp;
                }
                //    LookupModel lm = Context.GetLookup(analiticalFields.IdLookUp);
                //    var list = Context.GetLookup(lm.LookUpMetaData.Tablename, ConfigTempoSinglenton.GetInstance().CurrentFirma.Id);
                //    int k = 0;
                //    foreach (IEnumerable<string> enumerable in list)
                //    {
                //        int i = 0;
                //        SaldoItem saldoitem = new SaldoItem();

                //        foreach (string s in enumerable)
                //        {

                //            if (i == 2) saldoitem.Value = s;
                //            if (i == 1) saldoitem.Key = s;
                //            if (k == 0 && i == 1)
                //            {
                //                saldoItem.Key = s;
                //                k++;
                //            }
                //            if (k == 1 && i == 2)
                //            {
                //                saldoItem.Value = s;
                //                k++;
                //            }
                //            i++;
                //        }
                //        saldoItem.LookUp.Add(saldoitem);

                //    }
                //}
                _saldoItems.Add(saldoItem);
            }
            foreach (AnaliticalFields analiticalFields in SelectedAnaliticalTypeFields)
            {
                Titles.Add(analiticalFields.Name);
                string         defvalue  = "";
                SaldoItemTypes saldotype = SaldoItemTypes.String;
                if (analiticalFields.FieldType == "integer")
                {
                    saldotype = SaldoItemTypes.Integer;
                    defvalue  = "0";
                }
                if (analiticalFields.FieldType == "decimal")
                {
                    saldotype = SaldoItemTypes.Currency;
                    defvalue  = Vf.LevFormatUI;
                }
                if (analiticalFields.FieldType == "Date")
                {
                    saldotype = SaldoItemTypes.Date;
                    defvalue  = DateTime.Now.ToShortDateString();
                }
                SaldoItem saldoItem = new SaldoItem
                {
                    Name         = analiticalFields.Name,
                    Type         = saldotype,
                    Value        = defvalue,
                    Fieldkey     = analiticalFields.Id,
                    IsInUnigroup = analiticalFields.Requared,
                    TabIndex     = tabitem
                };
                tabitem++;
                if (analiticalFields.IdLookUp != 0)
                {
                    saldoItem.IsLookUp = true;
                    saldoItem.Relookup = analiticalFields.IdLookUp;
                }
                //    LookupModel lm = Context.GetLookup(analiticalFields.IdLookUp);
                //    var list = Context.GetLookup(lm.LookUpMetaData.Tablename, ConfigTempoSinglenton.GetInstance().CurrentFirma.Id);
                //    foreach (IEnumerable<string> enumerable in list)
                //    {
                //        int i = 0;
                //        SaldoItem saldoitem = new SaldoItem();
                //        foreach (string s in enumerable)
                //        {

                //            if (i == 2) saldoitem.Value = s;
                //            if (i == 1) saldoitem.Key = s;

                //            i++;
                //        }
                //        saldoItem.LookUp.Add(saldoitem);

                //    }
                //}
                //if (!string.IsNullOrWhiteSpace(analiticalFields.RTABLENAME))
                //{

                //    saldoItem.IsLookUp = true;
                //    saldoItem.RCODELOOKUP = analiticalFields.RCODELOOKUP;
                //    var list = Context.GetLookup(analiticalFields.RTABLENAME, ConfigTempoSinglenton.GetInstance().CurrentFirma.Id);
                //    int k = 0;
                //    foreach (IEnumerable<string> enumerable in list)
                //    {
                //        int i = 0;
                //        SaldoItem saldoitem = new SaldoItem();

                //        foreach (string s in enumerable)
                //        {

                //            if (i == 2) saldoitem.Value = s;
                //            if (i == 1) saldoitem.Key = s;
                //            if (k == 0 && i == 1)
                //            {
                //                saldoItem.Key = s;
                //                k++;
                //            }
                //            if (k == 1 && i == 2)
                //            {
                //                saldoItem.Value = s;
                //                k++;
                //            }
                //            i++;
                //        }
                //        saldoItem.LookUp.Add(saldoitem);

                //    }
                //}

                _saldoItems.Add(saldoItem);
            }
            return(_saldoItems);
        }
예제 #12
0
        public SaldosAnaliticViewModel(ObservableCollection <AnaliticalFields> observableCollection, ObservableCollection <AnaliticalFields> observableCollection_2, ObservableCollection <AnaliticalFields> staticFields, AccountsModel accountsModel)
        {
            Title = string.Format("Начални аналитични салда на сметка {0}", accountsModel);
            IsCol = accountsModel.SaldoDK > 0 || accountsModel.SaldoKK > 0;
            IsVal = accountsModel.SaldoDV > 0 || accountsModel.SaldoKV > 0;
            this.IsShowNavigation       = false;
            this.observableCollection   = observableCollection;
            this.observableCollection_2 = observableCollection_2;
            this.staticFields           = staticFields;
            this.accountsModel          = accountsModel;
            this.IsShowReport           = true;
            Titles   = new ObservableCollection <string>();
            Contents = new ObservableCollection <ObservableCollection <string> >();
            ObservableCollection <string> vals = new ObservableCollection <string>();

            _saldoItems = new ObservableCollection <SaldoItem>();
            foreach (AnaliticalFields analiticalFields in staticFields)
            {
                Titles.Add(analiticalFields.Name + "Кредит");
                Titles.Add(analiticalFields.Name + "Дебит");

                SaldoItemTypes saldotype = SaldoItemTypes.String;
                if (analiticalFields.FieldType == "integer")
                {
                    saldotype = SaldoItemTypes.Integer;
                }
                if (analiticalFields.FieldType.Contains("DECIMAL"))
                {
                    saldotype = SaldoItemTypes.Currency;
                }
                if (analiticalFields.FieldType == "Date")
                {
                    saldotype = SaldoItemTypes.Date;
                }
                SaldoItem saldoItem = new SaldoItem
                {
                    Name         = analiticalFields.Name,
                    Type         = saldotype,
                    Length       = 50,
                    Value        = Vf.LevFormatUI,
                    Valued       = Vf.LevFormatUI,
                    IsDK         = true,
                    Fieldkey     = analiticalFields.Id,
                    IsInUnigroup = analiticalFields.Requared,
                    Group        = analiticalFields.Group
                };
                _saldoItems.Add(saldoItem);
            }
            foreach (AnaliticalFields analiticalFields in observableCollection)
            {
                Titles.Add(analiticalFields.Name);
                SaldoItemTypes saldotype = SaldoItemTypes.String;
                string         defvalue  = "";
                if (analiticalFields.FieldType == "integer")
                {
                    saldotype = SaldoItemTypes.Integer;
                    defvalue  = "0";
                }
                if (analiticalFields.FieldType == "decimal")
                {
                    saldotype = SaldoItemTypes.Currency;
                    defvalue  = Vf.LevFormatUI;
                }
                if (analiticalFields.FieldType == "Date")
                {
                    saldotype = SaldoItemTypes.Date;
                    defvalue  = DateTime.Now.ToShortDateString();
                }
                SaldoItem saldoItem = new SaldoItem
                {
                    Name         = analiticalFields.Name,
                    Type         = saldotype,
                    Value        = defvalue,
                    Fieldkey     = analiticalFields.Id,
                    IsInUnigroup = analiticalFields.Requared,
                    Group        = analiticalFields.Group
                };
                if (analiticalFields.IdLookUp != 0)
                {
                    saldoItem.IsLookUp = true;
                    saldoItem.Relookup = analiticalFields.IdLookUp;
                }
                //    LookupModel lm = Context.GetLookup(analiticalFields.IdLookUp);
                //    var list = Context.GetLookup(lm.LookUpMetaData.Tablename, ConfigTempoSinglenton.GetInstance().CurrentFirma.Id);
                //    int k = 0;
                //    foreach (IEnumerable<string> enumerable in list)
                //    {
                //        int i = 0;
                //        SaldoItem saldoitem = new SaldoItem();
                //        saldoitem.Name = saldoItem.Name;
                //        List<string> s = new List<string>(enumerable);
                //        saldoitem.Key = s[1];
                //        saldoitem.Value = s[2];
                //        saldoItem.LookUp.Add(saldoitem);

                //    }
                //}
                _saldoItems.Add(saldoItem);
            }
            foreach (AnaliticalFields analiticalFields in observableCollection_2)
            {
                Titles.Add(analiticalFields.Name);
                string         defvalue  = "";
                SaldoItemTypes saldotype = SaldoItemTypes.String;
                if (analiticalFields.FieldType == "integer")
                {
                    saldotype = SaldoItemTypes.Integer;
                    defvalue  = "0";
                }
                if (analiticalFields.FieldType == "decimal")
                {
                    saldotype = SaldoItemTypes.Currency;
                    defvalue  = Vf.LevFormatUI;
                }
                if (analiticalFields.FieldType == "Date")
                {
                    saldotype = SaldoItemTypes.Date;
                    defvalue  = DateTime.Now.ToShortDateString();
                }
                SaldoItem saldoItem = new SaldoItem
                {
                    Name         = analiticalFields.Name,
                    Type         = saldotype,
                    Value        = defvalue,
                    Fieldkey     = analiticalFields.Id,
                    IsInUnigroup = analiticalFields.Requared,
                    Group        = analiticalFields.Group
                };
                if (analiticalFields.IdLookUp != 0)
                {
                    saldoItem.IsLookUp = true;
                    saldoItem.Relookup = analiticalFields.IdLookUp;
                }
                //    LookupModel lm = Context.GetLookup(analiticalFields.IdLookUp);
                //    var list = Context.GetLookup(lm.LookUpMetaData.Tablename, ConfigTempoSinglenton.GetInstance().CurrentFirma.Id);
                //    foreach (IEnumerable<string> enumerable in list)
                //    {
                //        int i = 0;
                //        SaldoItem saldoitem = new SaldoItem();
                //        saldoitem.Name = saldoItem.Name;
                //        List<string> s = new List<string>(enumerable);
                //        saldoitem.Key = s[1];
                //        saldoitem.Value = s[2];
                //        saldoItem.LookUp.Add(saldoitem);

                //    }
                //}
                //if (!string.IsNullOrWhiteSpace(analiticalFields.RTABLENAME))
                //{

                //    saldoItem.IsLookUp = true;
                //    saldoItem.RCODELOOKUP = analiticalFields.RCODELOOKUP;
                //    var list = Context.GetLookup(analiticalFields.RTABLENAME, ConfigTempoSinglenton.GetInstance().CurrentFirma.Id);
                //    int k= 0;
                //    foreach (IEnumerable<string> enumerable in list)
                //    {
                //        int i = 0;
                //        SaldoItem saldoitem = new SaldoItem();
                //        saldoitem.Name = saldoItem.Name;
                //        List<string> s = new List<string>(enumerable);
                //        saldoitem.Key = s[1];
                //        saldoitem.Value = s[2];
                //        saldoItem.LookUp.Add(saldoitem);

                //    }
                //}

                _saldoItems.Add(saldoItem);
            }

            GetValue(accountsModel);
        }
예제 #13
0
        public IEnumerable <SaldoItem> LoadCreditAnaliticAtributes(IEnumerable <SaldoAnaliticModel> fields, int typecpnto)
        {
            List <SaldoItem> saldoItems = new List <SaldoItem>();
            int offset = 16;

            if (typecpnto == 2)
            {
                offset = 60;
            }
            int current = 0;

            foreach (SaldoAnaliticModel analiticalFields in fields)
            {
                current++;
                //Titles.Add(analiticalFields.Name);
                SaldoItemTypes saldotype = SaldoItemTypes.String;
                if (analiticalFields.DBField == "integer")
                {
                    saldotype = SaldoItemTypes.Integer;
                }
                if (analiticalFields.DBField.Contains("DECIMAL"))
                {
                    saldotype = SaldoItemTypes.Currency;
                }
                if (analiticalFields.DBField == "Date")
                {
                    saldotype = SaldoItemTypes.Date;
                }

                SaldoItem saldoItem = new SaldoItem();
                saldoItem.Type        = saldotype;
                saldoItem.Name        = analiticalFields.Name;
                saldoItem.Value       = analiticalFields.VAL;
                saldoItem.Fieldkey    = analiticalFields.ACCFIELDKEY;
                saldoItem.IsK         = typecpnto == 0;
                saldoItem.IsD         = typecpnto == 1;
                saldoItem.Id          = analiticalFields.ID;
                saldoItem.KursDif     = analiticalFields.KURSD;
                saldoItem.ValueKurs   = analiticalFields.KURS;
                saldoItem.MainKurs    = analiticalFields.KURSM;
                saldoItem.ValueVal    = analiticalFields.VALVAL;
                saldoItem.ValueCredit = analiticalFields.VALUEMONEY;
                saldoItem.Lookupval   = analiticalFields.LOOKUPVAL;
                saldoItem.TabIndex    = offset + current;
                if (analiticalFields.ACCFIELDKEY == 29 || analiticalFields.ACCFIELDKEY == 30 ||
                    analiticalFields.ACCFIELDKEY == 31)
                {
                    saldoItem.IsDK = true;
                    if (analiticalFields.ACCFIELDKEY == 30)
                    {
                        //saldoItem.InfoTitle = "Валутен курс";
                        saldoItem.IsVal = true;
                        //if (typecpnto == 0)
                        //{
                        //    try
                        //    {
                        //        saldoItem.InfoValue = DAccountsModel.EndSaldoL/DAccountsModel.EndSaldoV;
                        //    }
                        //    catch (Exception)
                        //    {
                        //        saldoItem.InfoValue =0;
                        //    }

                        //}
                        //if (typecpnto == 1)
                        //{
                        //    try
                        //    {
                        //        saldoItem.InfoValue = CAccountsModel.EndSaldoL / CAccountsModel.EndSaldoV;
                        //    }
                        //    catch (Exception)
                        //    {
                        //        saldoItem.InfoValue = 0;
                        //    }

                        //}
                    }
                    if (analiticalFields.ACCFIELDKEY == 31)
                    {
                        //    saldoItem.InfoTitle = "Единичнa цена";
                        saldoItem.IsKol    = true;
                        saldoItem.ValueKol = analiticalFields.VALVAL;
                        saldoItem.OnePrice = analiticalFields.KURS;
                    }
                    //    if (typecpnto == 1)
                    //    {
                    //        try
                    //        {
                    //            saldoItem.InfoValue = (DAccountsModel.EndSaldoL / DAccountsModel.EndSaldoK);
                    //        }
                    //        catch (Exception)
                    //        {
                    //            saldoItem.InfoValue = 0;
                    //        }

                    //    }
                    //    if (typecpnto == 0)
                    //    {
                    //        try
                    //        {
                    //            saldoItem.InfoValue = CAccountsModel.EndSaldoL / CAccountsModel.EndSaldoK;
                    //        }
                    //        catch (Exception)
                    //        {
                    //            saldoItem.InfoValue = 0; ;
                    //        }

                    //    }
                    //}
                }
                if (analiticalFields.LOOKUPID != 0)
                {
                    //saldoItem.LiD = analiticalFields.LOOKUPFIELDKEY;

                    saldoItem.Relookup = analiticalFields.LOOKUPID;
                    saldoItem.IsLookUp = true;
                    //LookupModel lm = Context.GetLookup(analiticalFields.LOOKUPID);



                    //var list = Context.GetLookupDictionary(lm.LookUpMetaData.Tablename, ConfigTempoSinglenton.GetInstance().CurrentFirma.Id,""," FIRST 30 ");
                    //int k = 0;
                    //foreach (var enumerable in list)
                    //{
                    //    int i = 0;
                    //    SaldoItem saldoitem = new SaldoItem();
                    //    saldoitem.Name = saldoItem.Name;
                    //    saldoitem.Key = enumerable[lm.Fields[0].NameEng].ToString();
                    //    saldoitem.Value = enumerable[lm.Fields[1].NameEng].ToString();
                    //    saldoItem.LookUp.Add(saldoitem);
                    //    saldoItem.SelectedLookupItem =
                    //        saldoItem.LookUp.FirstOrDefault(e => e.Value == saldoItem.Value);
                    //}
                    //if (!string.IsNullOrWhiteSpace(analiticalFields.RTABLENAME))
                    //{
                    //    saldoItem.Key = analiticalFields.LOOKUPFIELDKEY.ToString();
                    //    saldoItem.IsLookUp = true;
                    //    var list1 = Context.GetLookup(analiticalFields.RTABLENAME, ConfigTempoSinglenton.GetInstance().CurrentFirma.Id);
                    //    k = 0;
                    //    foreach (IEnumerable<string> enumerable in list1)
                    //    {
                    //        int i = 0;
                    //        SaldoItem saldoitem = new SaldoItem();
                    //        saldoitem.Name = saldoItem.Name;
                    //        List<string> s = new List<string>(enumerable);
                    //        saldoitem.Key = s[1];
                    //        saldoitem.Value = s[2];

                    //        saldoItem.LookUp.Add(saldoitem);

                    //    }
                    //}
                }
                saldoItems.Add(saldoItem);
            }
            return(saldoItems);
        }
예제 #14
0
 public LookUpSelectorViewModel(SaldoItem si)
 {
     WorkSaldoItem = si;
     Fields        = WorkSaldoItem.GetDictionary("", "");
     Filters       = new ObservableCollection <Filter>(WorkSaldoItem.GetFilters());
 }
예제 #15
0
 public FastLookupEventArgs(SaldoItem item)
 {
     SaldoItem = item;
 }