Ejemplo n.º 1
0
        public void SetObject <T>(T item)
        {
            foreach (lInputCtrl ctrl in m_inputsCtrls)
            {
                PropertyInfo property = GetProperty(typeof(T), ctrl.m_fieldName);

                if (property != null)
                {
                    ctrl.Text = property.GetValue(item).ToString();
                    return;
                }

                FieldInfo field = typeof(T).GetField(ctrl.m_fieldName);
                if (field != null)
                {
                    var obj = field.GetValue(item);
                    if (obj != null)
                    {
                        if (ctrl.m_type == lSearchCtrl.ctrlType.dateTime)
                        {
                            ctrl.Text = Convert.ToDateTime(obj).ToString(ConfigMng.GetDisplayDateFormat());
                        }
                        else
                        {
                            ctrl.Text = obj.ToString();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public T GetObject <T>() where T : new()
        {
            T item = new T();

            foreach (lInputCtrl ctrl in m_inputsCtrls)
            {
                PropertyInfo property = GetProperty(typeof(T), ctrl.m_fieldName);

                DateTime dt;
                object   val;
                if (ctrl.m_type == lSearchCtrl.ctrlType.dateTime)
                {
                    ConfigMng.parseDisplayDate(ctrl.Text, out dt);
                    val = dt;
                }
                else
                {
                    val = ctrl.Text;
                }

                if (property != null)
                {
                    property.SetValue(item, ChangeType(val, property.PropertyType), null);
                }

                FieldInfo field = typeof(T).GetField(ctrl.m_fieldName);
                if (field != null)
                {
                    field.SetValue(item, ChangeType(val, field.FieldType));
                }
            }

            return(item);
        }
Ejemplo n.º 3
0
        public lInputCtrlText(string fieldName, string alias, ctrlType type, Point pos, Size size)
            : base(fieldName, alias, type, pos, size)
        {
            m_text       = ConfigMng.CrtTextBox();
            m_text.Width = 200;

            m_panel.Controls.AddRange(new Control[] { m_label, m_text });
        }
Ejemplo n.º 4
0
 public lInputCtrl(string fieldName, string alias, ctrlType type, Point pos, Size size)
     : base(fieldName, alias, type, pos, size)
 {
     m_label             = ConfigMng.CrtLabel();
     m_label.Text        = alias + " : ";
     m_label.TextAlign   = ContentAlignment.MiddleLeft;
     m_panel.BorderStyle = BorderStyle.None;
 }
Ejemplo n.º 5
0
        public ContentSync()
        {
            //load config
            string   path = ConfigMng.FindTmpl("fb.cfg");
            string   txt  = File.ReadAllText(path);
            ConfigCS cfg  = JsonConvert.DeserializeObject <ConfigCS>(txt);

            ApiKey           = cfg.ApiKey;
            FirebaseEmail    = cfg.FirebaseEmail;
            FirebasePassword = cfg.FirebasePassword;
        }
Ejemplo n.º 6
0
        public lInputCtrlDate(string fieldName, string alias, ctrlType type, Point pos, Size size)
            : base(fieldName, alias, type, pos, size)
        {
#if fit_txt_size
            int w = ConfigMng.getWidth(ConfigMng.getDateFormat()) + 20;
#else
            int w = 100;
#endif
            m_date.Width        = w;
            m_date.Format       = DateTimePickerFormat.Custom;
            m_date.CustomFormat = ConfigMng.GetDisplayDateFormat();
            m_date.Font         = ConfigMng.GetFont();

            m_panel.Controls.AddRange(new Control[] { m_label, m_date });
        }
Ejemplo n.º 7
0
        void getCnnStr()
        {
#if DEBUG
            m_db = ConfigMng.CfgRead("zDb") as string;
#else
            m_db = ConfigMng.FindTmpl("PTXX_NB.accdb");
#endif
            if (m_db != null)
            {
                var cnnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=<zDb>;";
                m_cnnStr = cnnStr.Replace("<zDb>", m_db);
            }
            else
            {
                OpenDbDlg();
                #if DEBUG
                ConfigMng.CfgWrite("zDb", m_db);
                #endif
            }
        }
Ejemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            Dictionary <string, MyUser> userD;
            var content = new lOleDbContentProvider();

            ConfigMng.CfgRead("zDb");
            var zDb    = ConfigMng.CfgRead("zDb") as string;
            var cnnStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=<zDb>;";

            content.initCnn(cnnStr.Replace("<zDb>", zDb));
            var userLst = content.GetAllUsers();

            userD = new Dictionary <string, MyUser>();
            foreach (MyUser tuser in userLst)
            {
                userD.Add(tuser.zFb, tuser);
            }

            var arr = optTxt.Lines;
            int s   = 0;

            for (int i = 0; i < arr.Length; i++)
            {
                string line = arr[i];
                switch (s)
                {
                case 0:
                    if (userD.ContainsKey(line))
                    {
                        s = 1;
                    }
                    else
                    {
                        s = -1;
                    }
                    break;
                }
            }
        }
Ejemplo n.º 9
0
        private void openFormToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string vbs;

#if DEBUG
            vbs = @"C:\Users\Onsiter\Google Drive\CBV\DTPTXX\tools\dkthoikhoa.vbs";
#else
            vbs = ConfigMng.FindTmpl("dkthoikhoa.vbs");
#endif
            Process scriptProc = new Process();
            scriptProc.StartInfo.WorkingDirectory = vbs.Substring(0, vbs.LastIndexOf("\\"));
            scriptProc.StartInfo.FileName         = @"C:\Windows\SysWOW64\cscript.exe";
            scriptProc.StartInfo.UseShellExecute  = false;
            scriptProc.StartInfo.Arguments        = "dkthoikhoa.vbs";
            scriptProc.StartInfo.CreateNoWindow   = false;
            scriptProc.StartInfo.Verb             = "runas";
            scriptProc.StartInfo.WindowStyle      = ProcessWindowStyle.Normal; //prevent console window from popping up
            scriptProc.Start();
            //scriptProc.StartInfo.WorkingDirectory = vbs.Substring(vbs.LastIndexOf("\\")); //<---very important
            //scriptProc.WaitForExit(); // <-- Optional if you want program running until your script exit
            //scriptProc.Close();
        }
Ejemplo n.º 10
0
        private void InitCtrl()
        {
            SplitContainer sc = new SplitContainer();

            sc.Dock = DockStyle.Fill;
            TableLayoutPanel tlp = new TableLayoutPanel();

            tlp.Dock = DockStyle.Fill;
            tlp.ColumnStyles.Add(new ColumnStyle()
            {
                SizeType = SizeType.AutoSize
            });
            tlp.ColumnStyles.Add(new ColumnStyle()
            {
                SizeType = SizeType.Percent, Width = 100
            });
            var iCol = 0;
            var iRow = 0;
            var lbl  = new Label();

            m_inputPanel = new UserInputPanel();
            int lastRow = 0;

            foreach (var ctrl in m_inputPanel.m_inputsCtrls)
            {
                tlp.Controls.Add(ctrl.m_panel, ctrl.m_pos.X, ctrl.m_pos.Y);
                tlp.SetColumnSpan(ctrl.m_panel, ctrl.m_size.Width);
                tlp.SetRowSpan(ctrl.m_panel, ctrl.m_size.Height);
                lastRow = Math.Max(lastRow, ctrl.m_pos.Y);
                iRow++;
            }

            lbl  = ConfigMng.CrtLabel(); lbl.Text = "Tags";
            tags = ConfigMng.CrtCheckedListBox();
            tlp.Controls.Add(lbl, iCol, ++iRow);
            tlp.Controls.Add(tags, iCol + 1, iRow);

            var btn = ConfigMng.CrtButton(); btn.Text = "Add/Update";

            btn.AutoSize = true;
            btn.Click   += AddUpdateUser;
            tlp.Controls.Add(btn, iCol, ++iRow);

            sc.Panel2.Controls.Add(tlp);
            this.Controls.Add(sc);

            //left panel
            tv = new TreeView();
            tv.NodeMouseDoubleClick += (s, e) => {
                m_user = (MyUser)e.Node.Tag;
                ShowSelectedUser();
            };
            tv.Dock = DockStyle.Fill;
            sc.Panel1.Controls.Add(tv);

            m_useCmb = new MyCmb();
            var cmb = m_useCmb.userCmb;

            cmb.Dock = DockStyle.Top;
            sc.Panel1.Controls.Add(cmb);

            m_useCmb.OnSelectUser += (s, e) =>
            {
                m_user = m_useCmb.GetUser();
                ShowSelectedUser();
            };

            //menu context
            var mc = new ContextMenuStrip();

            this.ContextMenuStrip = mc;
            var newUser = mc.Items.Add("clear");

            newUser.Click += NewUser_Click;
        }
Ejemplo n.º 11
0
 public MyCmb()
 {
     userCmb        = ConfigMng.CrtComboBox();
     userCmb.KeyUp += Cmb_KeyUp;
     userCmb.SelectedIndexChanged += UserCmb_SelectedIndexChanged;
 }