public override DD GetDD() { DL x = E.GetDL(); double p10 = Util.PowerTen(DTI.Scale(E.Type)); return((ee) => (double)x(ee) / p10); }
public Exp Convert( DataType t ) { if ( t < DataType.Decimal ) t = DTI.Base( t ); if ( Type == t ) return this; else if ( Type == DataType.Bigint ) return t == DataType.String ? (Exp) new IntToStringExp( this ) : t == DataType.Double ? (Exp) new IntToDoubleExp( this ) : t >= DataType.Decimal ? (Exp) new IntToDecimalExp( this, t ) : null; else if ( Type == DataType.Double ) return t == DataType.String ? (Exp) new DoubleToStringExp( this ) : t == DataType.Bigint ? (Exp) new DoubleToIntExp( this ) : t >= DataType.Decimal ? (Exp) new DoubleToDecimalExp( this, t ) : null; else if ( Type >= DataType.Decimal ) { if ( t == DataType.String ) return new DecimalToStringExp( this ); else if ( t == DataType.Double ) return new DecimalToDoubleExp( this ); else if ( t >= DataType.Decimal ) { int amount = DTI.Scale( t ) - DTI.Scale( Type ); return amount == 0 ? (Exp) this : amount > 0 ? (Exp) new ExpScale( this, t, amount ) : (Exp) new ExpScaleReduce( this, t, -amount ); } } else if ( Type == DataType.Binary && t == DataType.String ) return new BinaryToStringExp( this ); else if ( Type == DataType.Bool && t == DataType.String ) return new BoolToStringExp( this ); else if ( Type == DataType.ScaledInt && t >= DataType.Decimal ) return this; return null; }
public override DL GetDL() { DL x = E.GetDL(); long p10 = (long)Util.PowerTen(DTI.Scale(Type)); return((ee) => x(ee) * p10); }
public override DL GetDL() { DD x = E.GetDD(); ulong p10 = Util.PowerTen(DTI.Scale(Type)); return((ee) => (long)(x(ee) * p10)); }
public override Value Eval( EvalEnv e ) { if ( Type <= DataType.String && e.Locals[I]._O == null ) { e.Locals[I] = DTI.Default( Type ); } return e.Locals[I]; }
public static string D2S(long v, DataType t) { decimal d = v; int scale = DTI.Scale(t); d = d / Util.PowerTen(scale); return(d.ToString("F" + scale, System.Globalization.CultureInfo.InvariantCulture)); }
public override DataType TypeCheck( SqlExec e ) { DataType tL = Left.TypeCheck( e ); DataType tR = Right.TypeCheck( e ); if ( tL == DataType.Bigint && tR == DataType.Double ) { Left = new IntToDoubleExp(Left); tL = DataType.Double; } else if ( tR == DataType.Bigint && tL == DataType.Double ) { Right = new IntToDoubleExp(Right); tR = DataType.Double; } else if ( Operator != Token.VBar && ( tL >= DataType.Decimal || tR >= DataType.Decimal ) ) { if ( tR == DataType.Bigint ) tR = DTI.Decimal(18,0); else if ( tL == DataType.Bigint ) tL = DTI.Decimal(18,0); else if ( tR == DataType.Float ) { Right = Right.Convert( tL ); tR = tL; } else if ( tL == DataType.Float ) { Left = Left.Convert( tR ); tL = tR; } int sL = DTI.Scale(tL); int sR = DTI.Scale(tR); if ( sL < 0 || sR < 0 ) e.Error( "Type error involving decimal" ); switch( Operator ) { case Token.Divide: tL = DTI.Decimal( 18, sL - sR ); break; case Token.Times: tL = DTI.Decimal( 18, sL + sR ); break; case Token.Percent: break; default: if ( sL > sR ) { Right = new ExpScale( Right, tL, sL - sR ); tR = tL; } else if ( sL < sR ) { Left = new ExpScale( Left, tR, sR - sL ); tL = tR; } break; } tR = tL; } if ( tL == tR ) { if ( Operator <= Token.NotEqual ) Type = DataType.Bool; else { Type = tL; if ( !TokenInfo.OperatorValid( Operator, tL ) ) e.Error ( "Type error " + TokenInfo.Name(Operator) + " not valid for type " + DTI.Name(tL) ); } } else if ( tL == DataType.String && Operator == Token.VBar ) { Type = DataType.String; Right = Right.Convert( DataType.String ); } else e.Error( "Binary operator datatype error"); return Type; }
public override Value Eval( EvalEnv e ) { Value v = E.Eval( e ); decimal d = v.L; int scale = DTI.Scale( E.Type ); d = d / Util.PowerTen( scale ); v.O = d.ToString( "F" + scale, System.Globalization.CultureInfo.InvariantCulture ); return v; }
public override void Convert( DataType [] types, Exec e ) { for ( int i = 0; i < types.Length; i += 1 ) { if ( !Convert( i, types[ i ] ) ) { e.Error( "Data type conversion error to " + DTI.Name( types[ i ] ) ); } } }
/// <summary> /// returns the registered service or default service type /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="DTI">default service</typeparam> /// <returns></returns> public static T Resolve <T, DTI>() where DTI : T, new() { var service = Resolve <T>(); if (service == null) { service = new DTI(); } return(service); }
// At least one of GetDV or the relevant GetD? must be implemented ( or an infinite recursion will happen ). public virtual DV GetDV() { switch( DTI.Base( Type ) ) { case DataType.Bool : DB db = GetDB(); return ( ee ) => Value.New( db( ee ) ); case DataType.Double : DD dd = GetDD(); return ( ee ) => Value.New( dd( ee ) ); case DataType.String : DS ds = GetDS(); return ( ee ) => Value.New( ds( ee ) ); case DataType.Binary : DX dx = GetDX(); return ( ee ) => Value.New( dx( ee ) ); default: DL dl = GetDL(); return ( ee ) => Value.New( dl( ee ) ); } }
long DoParse(string s, DataType t) { try { return((long)(decimal.Parse(s) * Util.PowerTen(DTI.Scale(t)))); } catch (System.Exception) { throw new System.Exception("Cannot convert '" + s + "' to decimal"); } }
// Statement execution. Value [] InitLocals() { int n = LocalTypes.Length; var result = new Value[n]; for (int i = 0; i < n; i += 1) { result[i] = DTI.Default(LocalTypes[i]); } return(result); }
public override void Bind(SqlExec e) { for (int i = 0; i < Types.Length; i += 1) { Arg[i].Bind(e); DataType t = Arg[i].Type; if (t != Types[i]) { e.Error(this + " parameter type error, arg " + i + " expected " + DTI.Name(Types[i]) + " actual " + DTI.Name(t)); } } }
public override DataType TypeCheck( SqlExec e ) { if ( B.Params.Count != Plist.Length ) e.Error( "Param count error calling function " + FuncName ); for ( int i = 0; i < Plist.Length; i += 1 ) if ( Plist[i].Type != B.Params.Types[i] ) { Exp conv = Plist[i].Convert( B.Params.Types[i] ); if ( conv != null ) Plist[i] = conv; else e.Error( "Parameter Type Error calling function " + FuncName + " required type=" + DTI.Name( B.Params.Types[i] ) + " supplied type=" + DTI.Name( Plist[i].Type ) + " exp=" + Plist[i] ); } return Type; }
public override void Bind( SqlExec e ) { var ci = e.CI; if ( ci == null ) e.Error( "Undeclared variable " + ColName ); for ( int i=0; i < ci.Count; i += 1 ) if ( ci.Name[ i ] == ColName ) { e.Used[ i ] = true; ColIx = i; Type = DTI.Base( ci.Type[ i ] ); return; } e.Error( "Column " + ColName + " not found" ); }
public override Value Eval(EvalEnv e) { string s = (string)Arg[0].Eval(e)._O; DataType t = (DataType)Arg[1].Eval(e).L; try { Value result = new Value(); result.L = (long)(decimal.Parse(s) * Util.PowerTen(DTI.Scale(t))); return(result); } catch (System.Exception) { throw new System.Exception("Error converting [" + s + "] to decimal"); } }
public override void Bind( SqlExec e ) { B = e.Db.GetRoutine( Schema, FuncName, true, e ); Type = B.ReturnType; e.Bind( Plist ); if ( B.Params.Count != Plist.Length ) e.Error( "Param count error calling function " + FuncName ); for ( int i = 0; i < Plist.Length; i += 1 ) if ( Plist[ i ].Type != B.Params.Type[ i ] ) { Exp conv = Plist[ i ].Convert( B.Params.Type[ i ] ); if ( conv != null ) Plist[ i ] = conv; else e.Error( "Parameter Type Error calling function " + FuncName + " required type=" + DTI.Name( B.Params.Type[ i ] ) + " supplied type=" + DTI.Name( Plist[ i ].Type ) + " exp=" + Plist[ i ] ); } }
public override DataType Bind( SqlExec e ) { var ci = e.CI; if ( ci == null ) e.Error( "Undeclared variable " + ColName ); for ( int i=0; i < ci.Count; i += 1 ) if ( ci.Names[i] == ColName ) { e.Used[ i ] = true; ColIx = i; Type = DTI.Base( ci.Types[i] ); return Type; } // for ( int i=0; i < ci.Length; i += 1 ) System.Console.WriteLine( ci[i].Name ); e.Error( "Column " + ColName + " not found" ); return Type; }
private async void DepartmentEmployeeRegistration() { try { TokenNo(); Drawable icon_error = Resources.GetDrawable(Resource.Drawable.alert); icon_error.SetBounds(0, 0, 40, 30); if (txt_EmployeeTokenNo.Text != "") { if (txt_EmployeeName.Text != "") { if (txt_EmployeeAddress.Text != "") { if (txt_EmployeeContactNo.Text != "") { if (txt_EmployeeEmailID.Text != "") { if (txt_EmployeeDepartmentID.Text != "") { if (txt_EmployeeDesignationID.Text != "") { if (txt_EmployeePassword.Text != "") { foreach (var item in ResultAllDesignationMaster) { if (item.DesignationName.ToString().Trim() == (txt_EmployeeDesignationID.Text.Trim())) { _ObjDepartmentEmployeeRegistration.EmployeeDepartmentID = item.DepartmentID; _ObjDepartmentEmployeeRegistration.EmployeeDesignationID = item.DesignationID; } } _ObjDepartmentEmployeeRegistration.DeviceTokenId = DTI.ToString(); _ObjDepartmentEmployeeRegistration.EmployeeTokenNo = txt_EmployeeTokenNo.Text; _ObjDepartmentEmployeeRegistration.EmployeeName = txt_EmployeeName.Text; _ObjDepartmentEmployeeRegistration.EmployeeAddress = txt_EmployeeAddress.Text; _ObjDepartmentEmployeeRegistration.EmployeeContactNo = txt_EmployeeContactNo.Text; _ObjDepartmentEmployeeRegistration.EmployeeEmailID = txt_EmployeeEmailID.Text; //_ObjDepartmentEmployeeRegistration.EmployeeDepartmentID = Convert.ToInt32(txt_EmployeeDepartmentID.Text); //_ObjDepartmentEmployeeRegistration.EmployeeDesignationID = Convert.ToInt32(txt_EmployeeDesignationID.Text); _ObjDepartmentEmployeeRegistration.EmployeePassword = txt_EmployeePassword.Text; _ObjDepartmentEmployeeRegistration.Date = Convert.ToDateTime(DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")); // ADD Insert Code Here WebHelpper _objHelper = new WebHelpper(); string Url = StatusModel.Url + "AddDepartmentEmployeeRegistration"; progressDialog = ProgressDialog.Show(this, Android.Text.Html.FromHtml("<font color='#EC407A'> Please wait...</font>"), Android.Text.Html.FromHtml("<font color='#EC407A'> Data Inserting...</font>"), true); var PostString = JsonConvert.SerializeObject(_ObjDepartmentEmployeeRegistration); var requestTemp = await _objHelper.MakePostRequest(Url, PostString, true); ResultModel ResultgetRequest = JsonConvert.DeserializeObject <ResultModel>(requestTemp); if (ResultgetRequest.success == 1) { progressDialog.Hide(); Toast.MakeText(this, ResultgetRequest.msg, ToastLength.Short).Show(); } else { progressDialog.Hide(); Toast.MakeText(this, ResultgetRequest.msg, ToastLength.Short).Show(); return; } clear(); } else { txt_EmployeePassword.RequestFocus(); txt_EmployeePassword.SetError("Please Enter Password First", icon_error); } } else { txt_EmployeeDesignationID.RequestFocus(); txt_EmployeeDesignationID.SetError("Please Select Designation First", icon_error); } } else { txt_EmployeeDepartmentID.RequestFocus(); txt_EmployeeDepartmentID.SetError("Please Select Department First", icon_error); } } else { txt_EmployeeEmailID.RequestFocus(); txt_EmployeeEmailID.SetError("Please Enter Email ID First", icon_error); } } else { txt_EmployeeContactNo.RequestFocus(); txt_EmployeeContactNo.SetError("Please Enter Contact Number First", icon_error); } } else { txt_EmployeeAddress.RequestFocus(); txt_EmployeeAddress.SetError("Please Enter Address First", icon_error); } } else { txt_EmployeeName.RequestFocus(); txt_EmployeeName.SetError("Please Enter Full Name First", icon_error); } } else { txt_EmployeeTokenNo.RequestFocus(); txt_EmployeeTokenNo.SetError("Please Enter Token Number First", icon_error); } } catch (Exception e) { progressDialog.Hide(); string ErrorMsg = e.ToString(); Toast.MakeText(this, ErrorMsg, ToastLength.Long).Show(); } }
public override Value Eval( EvalEnv e ) { Value v = E.Eval( e ); v.L = (long) ( v.L * (long)Util.PowerTen( DTI.Scale( Type ) ) ); return v; }
public override Value Eval( EvalEnv e ) { Value v = E.Eval( e ); v.D = ((double)v.L) / Util.PowerTen( DTI.Scale( E.Type ) ); return v; }