Exemple #1
0
 public static object SQLiteTypeValue(EbDbTypes EbDbType, object Value)
 {
     if (EbDbType == EbDbTypes.String)
     {
         return(Value?.ToString());
     }
     else if (EbDbType == EbDbTypes.Int16 || EbDbType == EbDbTypes.Int32)
     {
         int.TryParse(Value?.ToString(), out int i);
         return(i);
     }
     else if (EbDbType == EbDbTypes.Decimal || EbDbType == EbDbTypes.Double)
     {
         double.TryParse(Value?.ToString(), out double i);
         return(i);
     }
     else if (EbDbType == EbDbTypes.Boolean || EbDbType == EbDbTypes.BooleanOriginal)
     {
         bool.TryParse(Value?.ToString(), out bool i);
         return(i ? 1 : 0);
     }
     else
     {
         return(Value);
     }
 }
Exemple #2
0
 public static string SQLiteType(EbDbTypes EbDbType)
 {
     if (EbDbType == EbDbTypes.String)
     {
         return("TEXT");
     }
     else if (EbDbType == EbDbTypes.Int16 || EbDbType == EbDbTypes.Int32)
     {
         return("INT");
     }
     else if (EbDbType == EbDbTypes.Decimal || EbDbType == EbDbTypes.Double)
     {
         return("REAL");
     }
     else if (EbDbType == EbDbTypes.Date || EbDbType == EbDbTypes.DateTime)
     {
         return("DATETIME");
     }
     else if (EbDbType == EbDbTypes.Boolean || EbDbType == EbDbTypes.BooleanOriginal)
     {
         return("INT");
     }
     else
     {
         return("TEXT");
     }
 }
Exemple #3
0
        //tbl -> master table name, ins -> is insert, _col -> cols/colvals, _extqry -> extended query, ocF -> old column field
        public virtual bool ParameterizeControl(ParameterizeCtrl_Params args, string crudContext)
        {
            if (this.BypassParameterization && args.cField.Value == null)
            {
                throw new Exception($"Unable to proceed/bypass with value '{args.cField.Value}' for {this.Name}");
            }

            string paramName = args.cField.Name + crudContext;

            if (args.cField.Value == null || (this.EbDbType == EbDbTypes.Decimal && Convert.ToString(args.cField.Value) == string.Empty))
            {
                var p = args.DataDB.GetNewParameter(paramName, (EbDbTypes)args.cField.Type);
                p.Value = DBNull.Value;
                args.param.Add(p);
            }
            else if (!this.BypassParameterization)
            {
                EbDbTypes _t = (EbDbTypes)args.cField.Type;
                if (_t == EbDbTypes.Decimal || _t == EbDbTypes.Int32)
                {
                    if (!double.TryParse(Convert.ToString(args.cField.Value), out double temp))
                    {
                        throw new Exception($"Unable to proceed with value '{args.cField.Value}' for {this.Name}");
                    }
                }
                args.param.Add(args.DataDB.GetNewParameter(paramName, (EbDbTypes)args.cField.Type, args.cField.Value));
            }

            if (args.ins)
            {
                args._cols += args.cField.Name + CharConstants.COMMA + CharConstants.SPACE;
                if (this.BypassParameterization)
                {
                    args._vals += Convert.ToString(args.cField.Value) + CharConstants.COMMA + CharConstants.SPACE;
                }
                else
                {
                    args._vals += CharConstants.AT + paramName + CharConstants.COMMA + CharConstants.SPACE;
                }
            }
            else
            {
                if (this.BypassParameterization)
                {
                    args._colvals += args.cField.Name + CharConstants.EQUALS + Convert.ToString(args.cField.Value) + CharConstants.COMMA + CharConstants.SPACE;
                }
                else
                {
                    args._colvals += args.cField.Name + CharConstants.EQUALS + CharConstants.AT + paramName + CharConstants.COMMA + CharConstants.SPACE;
                }
            }
            args.i++;
            return(true);
        }
 public void SetEbDbType(string name, EbDbTypes ebDbType)
 {
     for (int i = 0; i < this.Columns.Count; i++)
     {
         if (this.Columns[i].Name.Equals(name))
         {
             this.Columns[i].Type = (int)ebDbType;
             return;
         }
     }
     throw new KeyNotFoundException("KeyNotFoundException : Key = " + name);
 }
Exemple #5
0
 public DbTypedValue(string Name, object Value, EbDbTypes Type)
 {
     if (Name == "eb_created_at_device")
     {
         this.Type = EbDbTypes.DateTime;
     }
     else
     {
         this.Type  = Type;
         this.Value = Value;
     }
 }
        public dynamic GetDataFieldValue(string column_name, int i, int tableIndex)
        {
            dynamic value = null;
            int     index;

            if (DataSet != null && DataSet.Tables.Count > 0 && DataSet.Tables[tableIndex].Rows?.Count > 0)
            {
                index = (DataSet.Tables[tableIndex].Rows.Count > 1) ? i : 0;
                EbDbTypes type = (DataSet.Tables[tableIndex].Columns[column_name].Type);
                value = (type == EbDbTypes.Bytea) ? DataSet.Tables[tableIndex].Rows[index][column_name] : DataSet.Tables[tableIndex].Rows[index][column_name].ToString();
            }
            return(value);
        }
Exemple #7
0
        private void AddParam(IDatabase DataDB, List <DbParameter> param, int i, EbDbTypes type, Dictionary <string, string> _d, Dictionary <string, string> _od, string key, object altVal)
        {
            if (_d.ContainsKey(key))
            {
                altVal = _d[key];
            }
            else if (_od != null && _od.ContainsKey(key))
            {
                altVal = _od[key];
            }

            param.Add(DataDB.GetNewParameter($"{key}_{i}", type, altVal));
        }
        public DbTypedValue GetDbType(string name, object value, EbDbTypes type)
        {
            DbTypedValue TV = new DbTypedValue(name, value, type);

            EbMobileControl ctrl = ControlDictionary.ContainsKey(name) ? ControlDictionary[name] : null;

            if (ctrl != null)
            {
                TV.Type  = ctrl.EbDbType;
                TV.Value = ctrl.SQLiteToActual(value);
            }
            else
            {
                if (TV.Type == EbDbTypes.Date)
                {
                    TV.Value = Convert.ToDateTime(value).ToString("yyyy-MM-dd");
                }
                else if (TV.Type == EbDbTypes.DateTime)
                {
                    TV.Value = Convert.ToDateTime(value).ToString("yyyy-MM-dd HH:mm:ss");
                }
            }
            return(TV);
        }
Exemple #9
0
        public DbTypedValue GetDbType(string name, object value, EbDbTypes type)
        {
            DbTypedValue TV = new DbTypedValue(name, value, type);

            EbMobileControl ctrl = ChildControls.Find(item => item.Name == name);

            if (ctrl != null)
            {
                TV.Type  = ctrl.EbDbType;
                TV.Value = ctrl.SQLiteToActual(value);
            }
            else
            {
                if (type == EbDbTypes.Date)
                {
                    TV.Value = Convert.ToDateTime(value).ToString("yyyy-MM-dd");
                }
                else if (type == EbDbTypes.DateTime)
                {
                    TV.Value = Convert.ToDateTime(value).ToString("yyyy-MM-dd HH:mm:ss");
                }
            }
            return(TV);
        }
        public void DoLoopInDetail(int serialnumber)
        {
            ph_Yposition = (PageNumber == 1) ? ReportHeaderHeight + this.Margin.Top : this.Margin.Top;
            dt_Yposition = ph_Yposition + PageHeaderHeight;
            foreach (EbReportDetail detail in Detail)
            {
                string column_val;
                RowHeight   = 0;
                MultiRowTop = 0;
                EbDataField[] SortedList = FieldsNotSummaryPerDetail[detail];
                EbPdfGlobals  globals    = new EbPdfGlobals();
                for (int iSortPos = 0; iSortPos < SortedList.Length; iSortPos++)
                {
                    EbDataField field = SortedList[iSortPos];
                    if (field is EbCalcField)
                    {
                        //globals.CurrentField = field;
                        column_val = (field as EbCalcField).GetCalcFieldValue(globals, DataSet, serialnumber, this);
                        EbDbTypes dbtype = (EbDbTypes)((field as EbCalcField).CalcFieldIntType);

                        if (CalcValInRow.ContainsKey(field.Title))
                        {
                            CalcValInRow[field.Title] = new PdfNTV {
                                Name = field.Title, Type = (PdfEbDbTypes)(int)dbtype, Value = column_val
                            }
                        }
                        ;
                        else
                        {
                            CalcValInRow.Add(field.Title, new PdfNTV {
                                Name = field.Title, Type = (PdfEbDbTypes)(int)dbtype, Value = column_val
                            });
                        }
                        AddParamsNCalcsInGlobal(globals);
                    }
                    else
                    {
                        column_val = GetDataFieldValue(field.ColumnName, serialnumber, field.TableIndex);
                    }

                    if (field.RenderInMultiLine)
                    {
                        field.DoRenderInMultiLine(column_val, this);
                    }
                }
                EbReportField[] SortedReportFields = this.ReportFieldsSortedPerDetail[detail];
                if (SortedReportFields.Length > 0)
                {
                    for (int iSortPos = 0; iSortPos < SortedReportFields.Length; iSortPos++)
                    {
                        EbReportField field = SortedReportFields[iSortPos];
                        if (field is EbDataField)
                        {
                            field.HeightPt += RowHeight;
                        }
                        DrawFields(field, dt_Yposition, serialnumber);
                    }
                    detailprintingtop += detail.HeightPt + RowHeight;
                    detailEnd          = detailprintingtop;
                }
                else
                {
                    detailEnd  = detailprintingtop;
                    IsLastpage = true;
                    Writer.PageEvent.OnEndPage(Writer, Doc);
                    return;
                }
            }
        }
 public EbDataColumn NewDataColumn(int index, string name, EbDbTypes type)
 {
     return(new EbDataColumn(index, name, type));
 }
Exemple #12
0
 public VendorDbType(EbDbTypes type, dynamic vDbType, string vDbText)
 {
     this.EbDbType = type;
     this.VDbType  = vDbType;
     this.VDbText  = vDbText;
 }
 public abstract DbParameter GetNewOutParameter(string parametername, EbDbTypes type);
 // DbCommand GetNewCommand(DbConnection con, string sql, DbTransaction trans);
 public abstract DbParameter GetNewParameter(string parametername, EbDbTypes type, object value);
Exemple #15
0
 public EbDataColumn(string columnname, EbDbTypes type)
 {
     this.ColumnName = columnname;
     this.Type       = type;
 }
Exemple #16
0
 public MobileTableColumn(string name, EbDbTypes type, object value)
 {
     Name  = name;
     Type  = type;
     Value = value;
 }
Exemple #17
0
 public EbDataColumn(int index, string columnname, EbDbTypes type)
 {
     this.ColumnIndex = index;
     this.ColumnName  = columnname;
     this.Type        = type;
 }
Exemple #18
0
        public override void DrawMe(float printingTop, EbReport Rep, List <Param> Params, int slno)
        {
            ColumnText   ct         = new ColumnText(Rep.Canvas);
            string       column_val = string.Empty;
            EbDbTypes    dbtype     = EbDbTypes.String;
            EbPdfGlobals globals    = new EbPdfGlobals();

            try
            {
                column_val = Rep.ExecuteExpression(Rep.ValueScriptCollection[Name], slno, globals, DataFieldsUsedInCalc, true).ToString();
                dbtype     = (EbDbTypes)CalcFieldIntType;

                if (Rep.CalcValInRow.ContainsKey(Title))
                {
                    Rep.CalcValInRow[Title] = new PdfNTV {
                        Name = Title, Type = (PdfEbDbTypes)(int)dbtype, Value = column_val
                    }
                }
                ;
                else
                {
                    Rep.CalcValInRow.Add(Title, new PdfNTV {
                        Name = Title, Type = (PdfEbDbTypes)(int)dbtype, Value = column_val
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + e.StackTrace);
            }
            if (SuppressIfZero && !(Convert.ToDecimal(column_val) > 0))
            {
                column_val = String.Empty;
            }
            else
            {
                if (dbtype == EbDbTypes.Decimal)
                {
                    column_val = FormatDecimals(column_val, AmountInWords, DecimalPlaces, Rep.CultureInfo?.NumberFormat, FormatUsingCulture);
                }
                if (Prefix != "" || Suffix != "")
                {
                    column_val = Prefix + " " + column_val + " " + Suffix;
                }
            }
            Phrase phrase = GetPhrase(column_val, (DbType)DbType, Rep.Font);

            if (!string.IsNullOrEmpty(LinkRefId))
            {
                Anchor    a = CreateLink(phrase, LinkRefId, Rep.Doc, Params);
                Paragraph p = new Paragraph {
                    a
                };
                p.Font = GetItextFont(this.Font, Rep.Font);
                ct.AddText(p);
            }
            else
            {
                ct.AddText(phrase);
            }

            float ury = Rep.HeightPt - (printingTop + TopPt + Rep.detailprintingtop);
            float lly = Rep.HeightPt - (printingTop + TopPt + HeightPt + Rep.detailprintingtop);

            ct.SetSimpleColumn(Llx, lly, Urx, ury, Leading, (int)TextAlign);
            ct.Go();
        }