void IReportEntity.SetPersistanceField(Dictionary <string, object> Variables) { TableDef td = MetaData.GetTableDef(GetType()); foreach (KeyValuePair <string, object> kvp in Variables) { FieldDef fld = td.GetFieldDef(kvp.Key); if (fld != null) { object TmpVal; switch (fld.DataType) { case DataType.Integer: TmpVal = Convert.ToInt32(kvp.Value); break; default: TmpVal = kvp.Value; break; } try { fld.SetLoadValue(this, TmpVal); } catch { } } } }
public Form ShowTabular() { if (!BaseWinFramework.CheckModuleAccessWithError(ModuleName, SecurityVarName.ReportView, true)) { return(null); } using (new WaitCursor()) { if (!TypeChecked) { CheckEntityType(); } if (_UIN != null) { IRuleInitUI riu = (IRuleInitUI)_UIN.Entity; _DataFilter = riu.GetBrowseFilter(); BrowseColumns = riu.GetBrowseColumns(); riu.GetBrowseSql(out BrowseSql, out BrowseCondition, out BrowseOrder); BrowseFormat.Clear(); riu.GetBrowseFormat(BrowseFormat); TableDef td = MetaData.GetTableDef(riu.GetType()); if (riu.GetFieldTransactionDate().Length == 0) { fldTransactionDate = td.fldTransactionDate; } else { fldTransactionDate = td.GetFieldDef( riu.GetFieldTransactionDate()); } } if (_BrowseForm == null || _BrowseForm.IsDisposed || _BrowseType != BrowseType.Tabular) { if (BaseWinFramework.TouchScreenVersion) { _BrowseForm = new frmGridReportTC(); } else { _BrowseForm = new frmGridReport(); } _BrowseForm.MdiParent = BaseWinFramework._MdiParent; ((IBrowseForm)_BrowseForm).ShowForm(this, ModuleName); _BrowseType = BrowseType.Tabular; } else { _BrowseForm.BringToFront(); } return(_BrowseForm); } }
private void BuildSetter() { Setter = new SetHandler[rdr.FieldCount]; EnumType = new Type[rdr.FieldCount]; Type tp = typeof(TEntity); TableDef td = MetaData.GetTableDef(tp); for (int i = 0; i < rdr.FieldCount; i++) { string Name = rdr.GetName(i); FieldDef fld = td.GetFieldDef(Name); if (fld != null) { Setter[i] = fld.GetLoadSetHandler(); if (fld.IsEnum) { EnumType[i] = fld.FieldType; } } else { MemberInfo[] mis = tp.GetMember("_" + Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (mis.Length == 0) { mis = tp.GetMember(Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (mis.Length == 0) { Setter[i] = null; } else { if (mis[0].MemberType == MemberTypes.Field) { Type ft = ((FieldInfo)mis[0]).FieldType; if (ft.IsEnum) { EnumType[i] = ft; } } else { Type ft = ((PropertyInfo)mis[0]).PropertyType; if (ft.IsEnum) { EnumType[i] = ft; } } Setter[i] = DynamicMethodCompiler.CreateSetHandler(mis[0]); } } } }
private void FindRealField(TableDef td, string FieldName, out TableDef RealTd, out FieldDef RealFd) { FieldDef fld = td.GetFieldDef(FieldName); if (fld._dtlsa == null) { RealTd = td; RealFd = fld; return; } FindRealField(MetaData.GetTableDef(fld._dtlsa._ParentType), fld._dtlsa.ParentFieldName, out RealTd, out RealFd); }
private string GetFieldName(TableDef td, string FieldName) { FieldDef fld = td.GetFieldDef(FieldName); if (fld == null) { if (td._dva != null) { return(FieldName); } else { throw new ApplicationException(string.Format(ErrorEntity.FieldNotFound, td._TableName, FieldName)); } } return(fld._dtlsa == null ? FieldName : string.Concat("(", fld._dtlsa.GetSqlQuery(), ")")); }
public EntityBindingList(DataPersistance dp, string ColumnList, string Condition, string OrderCondition, out IList <TEntity> ListEntity) { EntityType = typeof(TEntity); td = MetaData.GetTableDef(EntityType); this.dp = dp ?? BaseFramework.DefaultDataPersistance; ListEntity = this.dp.FastLoadEntities <TEntity>(null, ColumnList, Condition, OrderCondition); wrdt = new WeakReference(ListEntity); SqlQuery = BuildSqlQuery(Condition); IsLoadEntity = false; string[] Cols = ColumnList.Split(','); FieldList = new FieldDef[Cols.Length]; for (int i = 0; i < Cols.Length; i++) { FieldList[i] = td.GetFieldDef(Cols[i].Trim()); } }
public xTreeList(DataPersistance Dp, TreeList TreeList, string OrderField) { this.Dp = Dp ?? BaseFramework.DefaultDataPersistance; this.OrderField = OrderField; this.TreeList = TreeList; BindingSource bs = TreeList.DataSource as BindingSource; if (bs == null) { throw new ApplicationException( "DataSource dari TreeList belum diisi !"); } if (bs.DataSource.GetType().Name == "RuntimeType") { Td = MetaData.GetTableDef((Type)bs.DataSource); } else { Td = MetaData.GetTableDef(bs.DataSource.GetType()); } TreeList.DataSource = null; TreeList.BeforeExpand += new BeforeExpandEventHandler(TreeList_BeforeExpand); TreeList.NodeChanged += new NodeChangedEventHandler(TreeList_NodeChanged); Columns = new string[TreeList.Columns.Count + 1]; int i = 0; Columns[0] = TreeList.KeyFieldName; foreach (TreeListColumn col in TreeList.Columns) { FieldDef fld = Td.GetFieldDef(col.FieldName); col.Format.FormatType = FormatType.Custom; col.Format.FormatString = fld.FormatString; Columns[++i] = col.FieldName; } }
public MdiForm() { using (new WaitCursor()) { InitializeComponent(); BaseWinFramework.ShowProgressBar(Text); BaseSecurity.LoginWithRole = false; BaseFramework.DpEngine .RegisterEngine <SqlServerPersistance>(); BaseFramework.DpEngine .RegisterEngine <AccessPersistance>(); //BaseFramework.EnableWriteLog = true; ribbonControl1.SelectedPage = ribbonPage4; BaseWinSecurity.Init(this, null, null, true, pgAksesSistem); BaseGL.SetingPerusahaan.OnEntityAction += new EntityAction(SetingPerusahaan_OnEntityAction); TableDef td = MetaData.GetTableDef <Departemen>(); FieldDef fld = td.GetFieldDef("DepartemenProduksi"); fld.IsHidden = true; BaseWinSecurity.ListAdminButton.Add(mnPenguncianTgl); BaseWinSecurity.ListLoginButton.Add(mnNeraca); BaseWinSecurity.ListLoginButton.Add(mnLabaRugi); BaseWinSecurity.ListLoginButton.Add(mnMutasiAkun); BaseWinSecurity.ListLoginButton.Add(mnRingkasanAkun); string FolderName; #region Menu Keuangan FolderName = "Keuangan\\Transaksi"; BaseWinSecurity.RegisterDocumentModule <DocPenerimaanKasUmum>(PenerimaanKasUmum.ModuleName, FolderName, mnPenerimaanKasUmum); BaseWinSecurity.RegisterDocumentModule <DocPengeluaranKasUmum>("Pengeluaran Kas Umum", FolderName, mnPengeluaranKasUmum); BaseWinSecurity.RegisterDocumentModule <DocTransferAntarKas>("Transfer Antar Kas", FolderName, mnTransferKas); BaseWinSecurity.RegisterDocumentModule <DocPerintahBayar>("Perintah Bayar", FolderName, mnPerintahBayar); BaseWinSecurity.RegisterDocumentModule <DocPengeluaranPerintahBayar>( "Pengeluaran Uang dari Perintah Bayar", FolderName, mnPengeluaranDariPerintahBayar); FolderName = "Keuangan\\Master"; BaseWinSecurity.RegisterDocumentModule <DocJenisPenerimaanKas>("Jenis Penerimaan Kas", FolderName, mnJenisPenerimaanKas); BaseWinSecurity.RegisterDocumentModule <DocJenisPengeluaranKas>("Jenis Pengeluaran Kas", FolderName, mnJenisPengeluaranKas); #endregion #region Menu Buku Besar FolderName = "Buku Besar\\Transaksi"; BaseWinSecurity.RegisterDocumentModule <DocJurnal>("Jurnal Umum", FolderName, mnJurnalUmum); BaseWinSecurity.RegisterDocumentModule <DocKursHarian>("Kurs Harian", FolderName, mnKursHarian); FolderName = "Buku Besar\\Laporan"; BaseWinGL.RegisterPopNeraca(FolderName, mnNeraca); BaseWinGL.RegisterPopLabaRugi(FolderName, mnLabaRugi); BaseWinGL.RegisterPosisiAkun(FolderName, mnPosisiAkun); BaseWinGL.RegisterPopMutasiAkun(FolderName, mnMutasiAkun); BaseWinGL.RegisterPopRingkasanAkun(FolderName, mnRingkasanAkun); FolderName = "Buku Besar\\Master"; BaseWinSecurity.RegisterDocumentModule <DocAkun>("Akun", FolderName, mnAkun); BaseWinSecurity.RegisterDocumentModule <DocAturanJurnal>("Aturan Jurnal", FolderName, mnAturanJurnal); BaseWinSecurity.RegisterDocumentModule <DocJenisDokSumberJurnal>("Jenis Dok. Sumber", FolderName, mnJenisDokSumberJurnal); BaseWinSecurity.RegisterDocumentModule <DocDepartemen>("Departemen", FolderName, mnDepartemen); BaseWinSecurity.RegisterDocumentModule <DocProyek>("Proyek", FolderName, mnProyek); BaseWinSecurity.RegisterDocumentModule <DocMataUang>("Mata Uang", FolderName, mnMataUang); BaseWinSecurity.RegisterDocumentModule <DocSaldoAwalAkun>("Saldo Awal Akun", "Sistem\\Saldo Awal", mnSaldoAwalAkun); BaseWinSecurity.RegisterDocumentModule <DocNilaiTukarSaldoAwal>("Nilai Tukar Saldo Awal", "Sistem\\Saldo Awal", mnNilaiTukarSaldoAwal); #endregion BaseWinSecurity.RegisterSingleDocumentModule <frmSetingPerusahaan>( "Seting Perusahaan", "Sistem", mnSetingPerusahaan); } }
public xTreeList(DataPersistance Dp, TreeList TreeList, string OrderField, string SqlCondition, string PostingField) { this.PostingField = PostingField; if (TreeList.RootValue.GetType() != typeof(string)) { TreeList.RootValue = string.Empty; } this.Dp = Dp; this.OrderField = OrderField; this.TreeList = TreeList; this.SqlCondition = SqlCondition; BindingSource bs = TreeList.DataSource as BindingSource; if (bs == null) { throw new ApplicationException( "DataSource dari TreeList belum diisi !"); } if (bs.DataSource.GetType().Name == "RuntimeType") { Td = MetaData.GetTableDef((Type)bs.DataSource); } else { Td = MetaData.GetTableDef(bs.DataSource.GetType()); } TreeList.DataSource = null; TreeList.BeforeExpand += new BeforeExpandEventHandler(TreeList_BeforeExpand); TreeList.FocusedNodeChanged += new FocusedNodeChangedEventHandler(TreeList_FocusedNodeChanged); Columns = new string[TreeList.Columns.Count + 1]; int i = 0; Columns[0] = TreeList.KeyFieldName; foreach (TreeListColumn col in TreeList.Columns) { FieldDef fld = Td.GetFieldDef(col.FieldName); col.Format.FormatType = FormatType.Custom; col.Format.FormatString = fld.FormatString; Columns[++i] = col.FieldName; } }
// Real Find public bool TryFindFirstValues <TEntity>(string FieldNames, string Conditions, string OrderFields, out object[] Values, params FieldParam[] Parameters) where TEntity : BaseEntity { TableDef td = MetaData.GetTableDef(typeof(TEntity)); DataPersistance Dp = td.GetDataPersistance(this.Dp); Dp.ValidateTableDef(td); string[] FName = FieldNames.Split(','); string SqlSelect = string.Empty; bool IsLSQLExist = false; for (int i = 0; i < FName.Length; i++) { FieldDef fld = td.GetFieldDef(FName[i]); if (fld != null) { if (fld._dtlsa == null) { SqlSelect = string.Concat(SqlSelect, ",", fld._FieldName); } else { SqlSelect = string.Concat(SqlSelect, ",(", fld._dtlsa.GetSqlQuery(), ") AS ", fld._FieldName); IsLSQLExist = true; } } else { SqlSelect = string.Concat(SqlSelect, ",", FName[i].Trim()); } } SqlSelect = string.Concat("SELECT ", SqlSelect.Remove(0, 1), " FROM ", td.GetSqlHeaderView(Dp)); if (IsLSQLExist) { SqlSelect = string.Concat("SELECT * FROM (", SqlSelect, ") AS ", td._TableName); } if (Conditions.Length > 0) { SqlSelect = string.Concat(SqlSelect, " WHERE ", Conditions); } IDbCommand Cmd = Dp.CreateCommand( Dp.GetSqlSelectTopN(SqlSelect, 1, OrderFields), CommandType.Text, Parameters); bool MustClose; if (Dp.Connection.State != ConnectionState.Open) { Dp.Connection.Open(); MustClose = true; } else { MustClose = false; } IDataReader rdr = null; try { Dp.WriteLog(Cmd.CommandText); rdr = Dp._ExecuteReader(Cmd); if (rdr.Read()) { Values = new object[rdr.FieldCount]; for (int i = 0; i < rdr.FieldCount; i++) { Values[i] = NormalizeVarType(rdr[i]); } return(true); } Values = null; return(false); } finally { if (rdr != null) { rdr.Close(); } if (MustClose) { Dp.Connection.Close(); } } }
internal string GetSqlQueryValue(BaseEntity Entity, out FieldParam[] Parameters) { if (_SqlQueryValue != null) { foreach (FieldParam fldp in QueryValueParams) { fldp.Value = Entity; } } else { string retVal; TableDef tdParent = MetaData.GetTableDef(_ParentType); FieldDef fldParent = tdParent.GetFieldDef(ParentFieldName); if (fldParent._dtlsa == null) { retVal = string.Concat("SELECT ", ParentFieldName, " FROM ", tdParent._TableName, " AS x1 WHERE "); } else { retVal = string.Concat("SELECT (", fldParent._dtlsa .GetSqlQueryNested(1), ") AS ", ParentFieldName, " FROM ", tdParent._TableName, " AS x1 WHERE "); } string[] tmpStr = _RelationKeyField.Split(','); int NumRel = tmpStr.Length; TableDef td = MetaData.GetTableDef(Entity.GetType()); FieldDef fld; QueryValueParams = new FieldParam[NumRel]; string tmpStr2 = tmpStr[0].Trim(); string[] tmpData = tmpStr2.Split('='); if (tmpData.Length == 1) { retVal = string.Concat(retVal, "x1.", tmpStr2, "=@0"); fld = td.GetFieldDef(tmpStr2); } else { retVal = string.Concat(retVal, "x1.", tmpData[0], "=@0"); fld = td.GetFieldDef(tmpData[1]); } QueryValueParams[0] = new FieldParam("0", fld, fld.GetValue(Entity)); for (int i = 1; i < NumRel; i++) { tmpStr2 = tmpStr[i]; tmpData = tmpStr2.Split('='); if (tmpData.Length == 1) { retVal = string.Concat(retVal, " AND x1.", tmpStr2, "=@", i.ToString()); fld = td.GetFieldDef(tmpStr2); } else { retVal = string.Concat(retVal, " AND x1.", tmpData[0], "=@", i.ToString()); fld = td.GetFieldDef(tmpData[1]); } QueryValueParams[i] = new FieldParam(i.ToString(), fld, fld.GetValue(Entity)); } _SqlQueryValue = retVal; } Parameters = QueryValueParams; return(_SqlQueryValue); }
private string GetSqlQueryNested(int Depth) { string retVal; string DepthStr = "x" + (Depth + 1).ToString(); string _ct = string.Concat("=", Depth == 0 ? _ChildTableName : "x" + Depth.ToString(), "."); TableDef tdParent = MetaData.GetTableDef(_ParentType); FieldDef fldParent = tdParent.GetFieldDef(ParentFieldName); if (fldParent._dtlsa == null) { retVal = string.Concat("SELECT ", ParentFieldName, " FROM ", tdParent._TableName, " AS ", DepthStr, " WHERE "); } else { retVal = string.Concat("SELECT (", fldParent._dtlsa .GetSqlQueryNested(Depth + 1), ") AS ", ParentFieldName, " FROM ", tdParent._TableName, " AS ", DepthStr, " WHERE "); } string[] tmpStr = _RelationKeyField.Split(','); int NumRel = tmpStr.Length; //TableDef tdChild = MetaData.GetTableDef(_ChildTableName); // Kalo Child Virtual belum bisa... string tmpStr2 = tmpStr[0].Trim(); string[] tmpData = tmpStr2.Split('='); if (tmpData.Length == 1) { //FieldDef fldChild = tdChild.GetFieldDef(tmpStr2); //if (fldChild._dtlsa != null) retVal = string.Concat(retVal, DepthStr, ".", tmpStr2, _ct, tmpStr2); } else { retVal = string.Concat(retVal, DepthStr, ".", tmpData[0], _ct, tmpData[1]); } for (int i = 1; i < NumRel; i++) { tmpStr2 = tmpStr[i]; tmpData = tmpStr2.Split('='); if (tmpData.Length == 1) { retVal = string.Concat(retVal, " AND ", DepthStr, ".", tmpStr2, _ct, tmpStr2); } else { retVal = string.Concat(retVal, " AND ", DepthStr, ".", tmpData[0], _ct, tmpData[1]); } } return(retVal); }