private void InitializeInfo() { DataTable _paymentterms = Cache.GetCachedTable("paymentterms"); if (_paymentterms != null) { DataRow[] _rows = _paymentterms.Select("[PaymentTerm] LIKE '" + _paymentterm.ToSqlValidString(true) + "'"); if (_rows.Length > 0) { DataRow _row = _rows[0]; if (!Materia.IsNullOrNothing(_row["PaymentTerm"])) { txtPaymentTerm.Text = _row["PaymentTerm"].ToString(); } if (!Materia.IsNullOrNothing(_row["Description"])) { txtDescription.Text = _row["Description"].ToString(); } if (!Materia.IsNullOrNothing(_row["Term"])) { cboTerms.SelectedValue = _row["Term"].ToString(); } if (VisualBasic.IsNumeric(_row["Days"])) { txtDays.Value = VisualBasic.CInt(_row["Days"]); } if (VisualBasic.IsNumeric(_row["Months"])) { txtMonths.Value = VisualBasic.CInt(_row["Months"]); } } } }
private void InitializeInfo() { DataTable _bankmisc = Cache.GetCachedTable("bankmiscellaneous"); if (_bankmisc != null) { DataRow[] _rows = _bankmisc.Select("[BankMiscellaneous] LIKE '" + _bankmiscellaneous.ToSqlValidString(true) + "'"); if (_rows.Length > 0) { DataRow _row = _rows[0]; if (!Materia.IsNullOrNothing(_row["BankMiscellaneous"])) { txtDescription.Text = _row["BankMiscellaneous"].ToString(); } if (VisualBasic.IsNumeric(_row["AccountCode"])) { cboAccount.SelectedValue = _row["AccountCode"]; } if (VisualBasic.IsNumeric(_row["Type"])) { cboType.SelectedIndex = VisualBasic.CInt(_row["Type"]); } } } }
private void trvwModules_AfterNodeSelect(object sender, DevComponents.AdvTree.AdvTreeNodeEventArgs e) { if (_nodesloading) { return; } if (e.Node == null) { return; } _selectedsubmodule = SubModule.None; if (e.Node.Nodes.Count > 0) { DisableButtons(); grdRecords.Hide(); if (lstvwRecords.Redraw) { lstvwRecords.BeginUpdate(); } lstvwRecords.ImageList = _images32; lstvwRecords.Show(); lstvwRecords.ListItems.Clear(); for (int i = 0; i <= (e.Node.Nodes.Count - 1); i++) { ListViewGridItem _item = new ListViewGridItem(e.Node.Nodes[i].Name, e.Node.Nodes[i].Text.Replace(" ", "\n"), e.Node.Nodes[i].Name); _item.Tag = e.Node.Nodes[i].Tag; lstvwRecords.ListItems.Add(_item); } while (!lstvwRecords.Redraw) { lstvwRecords.EndUpdate(); } } else { if (VisualBasic.IsNumeric(e.Node.Tag)) { if (VisualBasic.CInt(e.Node.Tag) > 0) { try { _selectedsubmodule = (SubModule)e.Node.Tag; } catch { _selectedsubmodule = SubModule.None; } grdRecords.Show(); lstvwRecords.Hide(); InitializeDataSource(); } } } }
/// <summary> /// Creates a DSN connection using the specified database information. /// </summary> /// <param name="connectionstring">Database connection string</param> /// <returns></returns> public static IDbConnection CreateDSN(string connectionstring) { string _server = connectionstring.ConnectionStringValue(ConnectionStringSection.Server); string _database = connectionstring.ConnectionStringValue(ConnectionStringSection.Database); string _uid = connectionstring.ConnectionStringValue(ConnectionStringSection.UID); string _pwd = connectionstring.ConnectionStringValue(ConnectionStringSection.PWD); string _port = connectionstring.ConnectionStringValue(ConnectionStringSection.Port); if (String.IsNullOrEmpty(_port)) { _port = "3306"; } return(CreateDSN(_server, _database, _uid, _pwd, VisualBasic.CInt(_port))); }
private string GetModuleName() { string _modulename = ""; string _path = Application.StartupPath + "\\Xml\\modules.xml"; DataTable _modules = SCMS.XmlToTable(_path); if (_modules != null) { DataRow[] _rows = _modules.Select("[Id] = " + VisualBasic.CInt(_selectedmodule).ToString()); if (_rows.Length > 0) { _modulename = _rows[0]["Text"].ToString(); } _modules.Dispose(); _modules = null; Materia.RefreshAndManageCurrentProcess(); } return(_modulename); }
private void UploadFile(int index) { _currentuploadsize = 0; FireEventFromWorker(UploadTransitions.FileUploadAttempting); UploadFileInfo _file = Uploads[index]; double _size = 0; byte[] _readbytes = new byte[PacketSize]; int _currentpackagesize = 0; FileInfo _fileinfo = new FileInfo(_file.Path); FileStream _filestream = null; Stopwatch _speedtimer = new Stopwatch(); Stream _stream = null; Int32 _readings = 0; Exception _ex = null; int _packet = PacketSize; try { _size = _fileinfo.Length; } catch { } FtpWebRequest _request = null; FtpWebResponse _response = null; try { string _ftpaddress = Path.GetDirectoryName(Address).ToLower().Replace("ftp:\\", "ftp://").Replace("\\", "/") + "/" + Path.GetFileName(_file.Path); _request = (FtpWebRequest)WebRequest.Create(_ftpaddress); if (_credential != null) { _request.Credentials = _credential; } _request.KeepAlive = true; _request.UseBinary = true; _request.Method = WebRequestMethods.Ftp.UploadFile; _filestream = new FileStream(_file.Path, FileMode.Open); _request.ContentLength = VisualBasic.CLng(_size); _stream = _request.GetRequestStream(); } catch (Exception ex) { _ex = ex; } _currentuploadsize = _size; FireEventFromWorker(UploadTransitions.FileUploadStarted); if (_ex != null) { _uploaderworker.ReportProgress((int)UploadInvokations.FileUploadFailedRaiser, _ex); } else { _currentlyuploaded = 0; _currentpackagesize = 0; do { if (_uploaderworker.CancellationPending) { _filestream.Close(); _stream.Close(); _speedtimer.Stop(); if (_response != null) { _response.Close(); } return; } _trigger.WaitOne(); _speedtimer.Start(); if (_stream == null && _response != null) { _stream = _response.GetResponseStream(); } if (_readbytes.Length < PacketSize) { _packet = _readbytes.Length; } else { _packet = PacketSize; } _currentpackagesize = _filestream.Read(_readbytes, 0, _packet); _currentlyuploaded += _currentpackagesize; _totaluploaded += _currentpackagesize; FireEventFromWorker(UploadTransitions.ProgressChanged); _stream.Write(_readbytes, 0, _currentpackagesize); _readings += 1; if (_readings >= StopWatchCycle) { _uploadspeed = VisualBasic.CInt(_packet * StopWatchCycle * 1000 / (_speedtimer.ElapsedMilliseconds + 1)); _speedtimer.Reset(); _readings = 0; } } while (_currentpackagesize != 0); _stream.Close(); _filestream.Close(); _speedtimer.Stop(); FireEventFromWorker(UploadTransitions.FileUploadSucceeded); } FireEventFromWorker(UploadTransitions.FileUploadStopped); }
private void InitializeModules(ModuleGroup modules) { string _path = Application.StartupPath + "\\Xml\\modules.xml"; DataTable _table = SCMS.XmlToTable(_path); if (_table != null) { DataRow[] _rows = _table.Select("[Group] = " + VisualBasic.CInt(modules).ToString(), "[Order]"); if (_rows != null) { if (_rows.Length > 0) { brModules.Items.Clear(); for (int i = 0; i <= (_rows.Length - 1); i++) { DataRow _row = _rows[i]; Image _image = (Image)Properties.Resources.Brick.Clone(); bool _begingroup = VisualBasic.CBool(brModules.Items.Count > 0); ButtonItem _button = new ButtonItem("btnModule" + _row["Id"].ToString(), _row["Text"].ToString()); _button.ButtonStyle = eButtonStyle.ImageAndText; if (_moduleimages.Images.ContainsKey(_row["ImageKey"].ToString())) { _image = _moduleimages.Images[_row["ImageKey"].ToString()]; } _button.Image = _image; _button.ImageFixedSize = new Size(32, 32); _button.ImagePosition = eImagePosition.Top; _button.Tag = _row["Id"]; _button.FixedSize = new Size(120, 75); _button.BeginGroup = _begingroup; _button.Cursor = Cursors.Hand; _button.Click += new EventHandler(_button_Click); brModules.Items.Add(_button); } _selectedmodulegroup = modules; } } _table.Dispose(); _table = null; Materia.RefreshAndManageCurrentProcess(); } ButtonItem _modulebutton = null; Image _modulebuttonimage = (Image)Properties.Resources.Brick.Clone(); switch (modules) { case ModuleGroup.Operations: _modulebutton = new ButtonItem("btnFinance", "Finance"); if (_moduleimages.Images.ContainsKey("Finance")) { _modulebuttonimage = _moduleimages.Images["Finance"]; } _modulebutton.Image = _modulebuttonimage; _modulebutton.Tag = ModuleGroup.Finance; break; case ModuleGroup.Finance: _modulebutton = new ButtonItem("btnOperations", "Operations"); if (_moduleimages.Images.ContainsKey("Operations")) { _modulebuttonimage = _moduleimages.Images["Operations"]; } _modulebutton.Image = _modulebuttonimage; _modulebutton.Tag = ModuleGroup.Operations; break; default: break; } if (_modulebutton != null) { _modulebutton.ButtonStyle = eButtonStyle.ImageAndText; _modulebutton.ImageFixedSize = new Size(32, 32); _modulebutton.FixedSize = new Size(120, 75); _modulebutton.ImagePosition = eImagePosition.Top; bool _begingroup = VisualBasic.CBool(brModules.Items.Count > 0); _modulebutton.BeginGroup = _begingroup; _modulebutton.Click += new EventHandler(_button_Click); _modulebutton.Cursor = Cursors.Hand; brModules.Items.Add(_modulebutton); } brModules.RecalcSize(); brModules.Refresh(); brModules.Update(); Materia.RefreshAndManageCurrentProcess(); }
private void InitializeModuleNodes() { if (!_nodesloading) { _nodesloading = true; } trvwModules.BeginUpdate(); trvwModules.Nodes.Clear(); trvwModules.ImageList = _images16; trvwModules.DragDropEnabled = false; DevComponents.AdvTree.Node _scmsnode = new DevComponents.AdvTree.Node(); _scmsnode.Name = "SCMS"; _scmsnode.Text = "Supply Chain Management System"; _scmsnode.Selectable = true; _scmsnode.Enabled = true; _scmsnode.ImageKey = "SCMS"; _scmsnode.Editable = false; trvwModules.Nodes.Add(_scmsnode); string _path = Application.StartupPath + "\\Xml\\nodes.xml"; DataTable _nodes = SCMS.XmlToTable(_path); if (_nodes != null) { var _query = from _n in _nodes.AsEnumerable() where _n.Field <int>("Module") == VisualBasic.CInt(_selectedmodule) select _n; DataTable _modulenodes = null; try { _modulenodes = _query.CopyToDataTable(); } catch { } if (_modulenodes != null) { _modulenodes.TableName = "nodes"; _modulenodes.DefaultView.Sort = "[Ordering]"; DataTable _viewtable = _modulenodes.DefaultView.ToTable(); if (_viewtable.Rows.Count > 0) { for (int i = 0; i <= (_viewtable.Rows.Count - 1); i++) { DataRow _row = _viewtable.Rows[i]; DevComponents.AdvTree.Node[] _parentnodes = trvwModules.Nodes.Find(_row["ParentKey"].ToString(), true); if (_parentnodes.Length > 0) { DevComponents.AdvTree.Node _parentnode = _parentnodes[0]; DevComponents.AdvTree.Node _childnode = new DevComponents.AdvTree.Node(); _childnode.Name = _row["NodeKey"].ToString(); _childnode.Text = _row["Text"].ToString(); _childnode.ImageKey = _row["NodeKey"].ToString(); _childnode.Editable = false; _childnode.Enabled = true; _childnode.Selectable = true; _childnode.Tag = _row["SubModuleEnum"]; _parentnode.Nodes.Add(_childnode); } } } _viewtable.Dispose(); _viewtable = null; _modulenodes.Dispose(); _modulenodes = null; _nodes.Dispose(); _nodes = null; Materia.RefreshAndManageCurrentProcess(); } } trvwModules.ExpandAll(); trvwModules.EndUpdate(); if (_nodesloading) { _nodesloading = false; } if (_scmsnode.Nodes.Count > 0) { DevComponents.AdvTree.Node _selectednode = _scmsnode.Nodes[0]; trvwModules.SelectedNode = _selectednode; } }