Beispiel #1
0
        public void themsct(string ngaychungtu, TextEdit txtsct, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, string userid)
        {
            int       dai   = 5;
            DataTable da    = new DataTable();
            string    thang = DateTime.Parse(ngaychungtu).Month.ToString();

            if (thang.Length < 2)
            {
                thang = "0" + thang;
            }
            string year    = DateTime.Parse(ngaychungtu).Year.ToString();
            string nam     = "-" + thang + "-" + year.Substring(2, 2);
            string sophieu = "08-08-PHKT";

            try
            {
                string id = gen.GetString("select Top 1 RefNo from GLVoucher where Month(RefDate)='" + DateTime.Parse(ngaychungtu).Month.ToString() + "' and Year(RefDate)='" + DateTime.Parse(ngaychungtu).Year.ToString() + "'  order by RefNo DESC");
                int    ct = Int32.Parse(id.Substring(10, dai)) + 1;
                for (int i = 0; i < dai - ct.ToString().Length; i++)
                {
                    sophieu = sophieu + "0";
                }
                sophieu = sophieu + ct.ToString() + nam;
            }
            catch { sophieu = sophieu + "00001" + nam; }

            txtsct.Text = sophieu;
            checktruocsau(tsbttruoc, tsbtsau, sophieu, ngaychungtu, userid);
        }
Beispiel #2
0
        protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
        {
            base.OnRenderSplitButtonBackground(e);
            bool drawBorder           = false;
            bool drawSeparator        = true;
            ToolStripSplitButton item = (ToolStripSplitButton)e.Item;

            checked
            {
                Rectangle btnRect    = new Rectangle(0, 0, item.ButtonBounds.Width - 1, item.ButtonBounds.Height - 1);
                Rectangle borderRect = new Rectangle(0, 0, item.Bounds.Width - 1, item.Bounds.Height - 1);
                bool      flag       = item.DropDownButtonPressed;
                if (flag)
                {
                    drawBorder    = true;
                    drawSeparator = false;
                    SolidBrush b = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground);
                    try
                    {
                        e.Graphics.FillRectangle(b, borderRect);
                    }
                    finally
                    {
                        flag = (b != null);
                        if (flag)
                        {
                            ((IDisposable)b).Dispose();
                        }
                    }
                }
                else
                {
                    flag = item.DropDownButtonSelected;
                    if (flag)
                    {
                        drawBorder = true;
                        RectDrawing.DrawSelection(e.Graphics, this.ColorTable.CommonColorTable, borderRect);
                    }
                }
                flag = item.ButtonPressed;
                if (flag)
                {
                    SolidBrush b2 = new SolidBrush(this.ColorTable.CommonColorTable.PressedBackground);
                    try
                    {
                        e.Graphics.FillRectangle(b2, btnRect);
                    }
                    finally
                    {
                        flag = (b2 != null);
                        if (flag)
                        {
                            ((IDisposable)b2).Dispose();
                        }
                    }
                }
                flag = drawBorder;
                if (flag)
                {
                    Pen p = new Pen(this.ColorTable.CommonColorTable.SelectionBorder);
                    try
                    {
                        e.Graphics.DrawRectangle(p, borderRect);
                        flag = drawSeparator;
                        if (flag)
                        {
                            e.Graphics.DrawRectangle(p, btnRect);
                        }
                    }
                    finally
                    {
                        flag = (p != null);
                        if (flag)
                        {
                            ((IDisposable)p).Dispose();
                        }
                    }
                    this.DrawCustomArrow(e.Graphics, item);
                }
            }
        }
Beispiel #3
0
        public static void InitLanguage(Form frm)
        {
            frm.BackColor = frmOptions.BACKCOLOR;
            if (Util.language == "0")
            {
                return;
            }

            _sb.Clear();
            frm.Text = TranslateString(frm.Text);
            string[] titles = Properties.Resources.Language.Replace("\n", "").Replace("\r", "").Split(';');
            if (titles != null)
            {
                for (int i = 0; i < titles.Length; i++)
                {
                    string[] title = titles[i].Split('-');
                    if (title.Length == 2)
                    {
                        string oldtitle, newtitle;
                        oldtitle = title[0].Replace("\r\n", "").ToLower();
                        newtitle = title[1].Replace("\r\n", "");
                        foreach (Control tb in frm.Controls)
                        {
                            switch (tb.GetType().ToString())
                            {
                            case "System.Windows.Forms.TextBox":
                                ((TextBox)tb).ShortcutsEnabled = true;
                                break;

                            case "System.Windows.Forms.ComboBox":
                                break;

                            case "System.Windows.Forms.MenuStrip":
                                MenuStrip ms = (MenuStrip)tb;
                                for (int k = 0; k < ms.Items.Count; k++)
                                {
                                    ToolStripMenuItem menuitem = (ToolStripMenuItem)ms.Items[k];
                                    if (menuitem.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                                    {
                                        menuitem.Text = newtitle;
                                        break;
                                    }
                                    else
                                    {
                                        SetSubMenu((ToolStripMenuItem)ms.Items[k], oldtitle, newtitle);
                                    }
                                }
                                break;

                            case "LXMS.ToolStripEx":
                            case "System.Windows.Forms.ToolStrip":
                                ToolStrip ts          = (ToolStrip)tb;
                                string    controltype = string.Empty;
                                for (int k = 0; k < ts.Items.Count; k++)
                                {
                                    ToolStripItem toolitem = (ToolStripItem)ts.Items[k];
                                    if (toolitem.GetType().ToString() != "System.Windows.Forms.ToolStripSeparator")
                                    {
                                        if (toolitem.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                                        {
                                            toolitem.Text = newtitle;
                                            break;
                                        }
                                        else if (toolitem.GetType().ToString() == "System.Windows.Forms.ToolStripDropDownButton")
                                        {
                                            ToolStripDropDownButton tsb = (ToolStripDropDownButton)toolitem;
                                            for (int m = 0; m < tsb.DropDownItems.Count; m++)
                                            {
                                                ToolStripDropDownItem tsbitem = (ToolStripDropDownItem)tsb.DropDownItems[m];
                                                if (tsbitem.GetType().ToString() != "System.Windows.Forms.ToolStripSeparator")
                                                {
                                                    if (tsbitem.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                                                    {
                                                        tsbitem.Text = newtitle;
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                        else if (toolitem.GetType().ToString() == "System.Windows.Forms.ToolStripSplitButton")
                                        {
                                            ToolStripSplitButton tsb = (ToolStripSplitButton)toolitem;
                                            for (int m = 0; m < tsb.DropDownItems.Count; m++)
                                            {
                                                if (tsb.DropDownItems[m].GetType().ToString() != "System.Windows.Forms.ToolStripSeparator")
                                                {
                                                    ToolStripMenuItem tsbitem = (ToolStripMenuItem)tsb.DropDownItems[m];
                                                    SetSubMenu((ToolStripMenuItem)tsbitem, oldtitle, newtitle);
                                                    if (tsbitem.GetType().ToString() != "System.Windows.Forms.ToolStripSeparator")
                                                    {
                                                        if (tsbitem.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                                                        {
                                                            tsbitem.Text = newtitle;
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                break;

                            case "LXMS.TabControlEx":
                            case "System.Windows.Forms.TabControl":
                                TabControl tc = (TabControl)tb;
                                foreach (TabPage tp in tc.Controls)
                                {
                                    _sb.Append(tp.Text.ToString() + "-" + oldtitle + "\r\n");
                                    if (tp.Text.ToLower() == oldtitle)
                                    {
                                        tp.Text = newtitle;
                                        break;
                                    }
                                    foreach (Control ct in tp.Controls)
                                    {
                                        SetSubControl(ct, oldtitle, newtitle);
                                    }
                                }
                                break;

                            case "System.Windows.Forms.SplitContainer":
                                SplitContainer sc = (SplitContainer)tb;
                                SetSubControl(sc.Panel1, oldtitle, newtitle);
                                SetSubControl(sc.Panel2, oldtitle, newtitle);
                                break;

                            default:
                                SetSubControl(tb, oldtitle, newtitle);
                                break;
                            }
                        }
                        System.Reflection.FieldInfo[] fieldInfo = frm.GetType().GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                        for (int m = 0; m < fieldInfo.Length; m++)
                        {
                            switch (fieldInfo[m].FieldType.Name)
                            {
                            case "ContextMenuStrip":
                                ContextMenuStrip cms = (ContextMenuStrip)fieldInfo[m].GetValue(frm);
                                for (int k = 0; k < cms.Items.Count; k++)
                                {
                                    if (cms.Items[k].GetType().ToString() == "System.Windows.Forms.ToolStripMenuItem")
                                    {
                                        ToolStripMenuItem menuitem = (ToolStripMenuItem)cms.Items[k];
                                        if (menuitem.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                                        {
                                            menuitem.Text = newtitle;
                                            break;
                                        }
                                        else
                                        {
                                            SetSubMenu((ToolStripMenuItem)cms.Items[k], oldtitle, newtitle);
                                        }
                                    }
                                }
                                break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            string retstr = _sb.ToString();
        }
Beispiel #4
0
        public void loadpkt(CheckEdit cechd, string active, string role, DevExpress.XtraGrid.GridControl gridControl1, GridView gridView1, TextEdit txtsct, ComboBoxEdit cbldt, LookUpEdit ledv, DateEdit denct, DateEdit denht,
                            DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit repositoryItemLookUpEdit1, DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit tkco, DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit rpkh,
                            DevExpress.XtraEditors.Repository.RepositoryItemDateEdit nphhd, DevExpress.XtraEditors.Repository.RepositoryItemTextEdit sotien, Frm_phieuthu F, LookUpEdit ledt, TextEdit txtnn, TextEdit txtldn, TextEdit txtctg,
                            ToolStripButton tsbtsua, ToolStripButton tsbtxoa, ToolStripButton tsbtcat, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtnap, ToolStripButton tsbtin, string ngaychungtu, string tsbt, ComboBoxEdit cbthue, TextEdit txthtt, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, DataTable khach, string userid, ToolStripButton tsbtkc, DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit rpmanganh, DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit rpmachiphi, SearchLookUpEdit danhmuc)
        {
            DataTable  dt  = new DataTable();
            phieuchitm ctm = new phieuchitm();

            ctm.loadstart(cechd, gridControl1, gridView1, cbldt, ledv, denct, denht, repositoryItemLookUpEdit1, tkco, rpkh, nphhd, sotien, ledt, tsbtsua, tsbtxoa, tsbtcat, tsbtboghi, tsbtghiso, tsbtnap, tsbtin, ngaychungtu, dt, tsbt, cbthue, khach, userid, rpmanganh, rpmachiphi, danhmuc);
            if (active == "1")
            {
                DataTable da = new DataTable();
                da = gen.GetTable("select  a.Description,DebitAccount,CreditAccount,Amount,AccountingObjectCode,InvDate,InvSeries,InvNo,CustomField5,CustomField4 from GLVoucherDetail a,AccountingObject b where a.AccountingObjectID=b.AccountingObjectID and RefID='" + role + "' order by SortOrder");
                for (int i = 0; i < da.Rows.Count; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr[0] = da.Rows[i][1].ToString();
                    dr[1] = da.Rows[i][2].ToString();
                    if (da.Rows[i][5].ToString() != "")
                    {
                        dr[2]         = DateTime.Parse(da.Rows[i][5].ToString());
                        cechd.Checked = true;
                    }
                    dr[3] = da.Rows[i][7].ToString();
                    dr[4] = da.Rows[i][6].ToString();
                    dr[5] = da.Rows[i][8].ToString();
                    dr[6] = da.Rows[i][3].ToString();
                    dr[7] = da.Rows[i][4].ToString();
                    dr[8] = da.Rows[i][0].ToString();
                    dr[9] = da.Rows[i][9].ToString();
                    dt.Rows.Add(dr);
                }
                gridControl1.DataSource = dt;
                tsbtcat.Enabled         = false;
                tsbtkc.Enabled          = false;
                F.Text = "Xem phiếu kế toán";

                da = gen.GetTable("select AccountingObjectCode,a.Contactname,JournalMemo,DocumentIncluded,RefDate,PostedDate,RefNo,StockCode,Posted,AccountingObjectType,Cancel,Tax,ExDate,a.PostVersion  from GLVoucher a, AccountingObject b,Stock c where a.AccountingObjectID=b.AccountingObjectID and a.StockID=c.StockID and RefID='" + role + "'");
                try
                {
                    cbldt.SelectedIndex = Int32.Parse(da.Rows[0][9].ToString());
                }
                catch { }
                ledv.EditValue    = da.Rows[0][7].ToString();
                ledt.EditValue    = da.Rows[0][0].ToString();
                txtnn.Text        = da.Rows[0][1].ToString();
                txtldn.Text       = da.Rows[0][2].ToString();
                txtctg.Text       = da.Rows[0][3].ToString();
                denct.EditValue   = DateTime.Parse(da.Rows[0][4].ToString());
                denht.EditValue   = DateTime.Parse(da.Rows[0][5].ToString());
                txtsct.Text       = da.Rows[0][6].ToString();
                cbthue.Text       = da.Rows[0][11].ToString();
                danhmuc.EditValue = da.Rows[0][13].ToString();
                if (da.Rows[0][8].ToString() == "True")
                {
                    tsbtghiso.Visible = false;
                    tsbtboghi.Visible = true;
                    tsbtsua.Enabled   = false;
                }
                else
                {
                    tsbtboghi.Visible = false;
                    tsbtghiso.Visible = true;
                }
                if (da.Rows[0][10].ToString() == "True")
                {
                    tsbtboghi.Enabled = false;
                    tsbtghiso.Enabled = false;
                }
                try
                {
                    txthtt.Text = da.Rows[0][12].ToString();
                }
                catch { }
                checktruocsau(tsbttruoc, tsbtsau, txtsct.Text, ngaychungtu, userid);
            }
            else
            {
                try
                {
                    F.Text = "Thêm phiếu kế toán";
                    themsct(ngaychungtu, txtsct, tsbttruoc, tsbtsau, userid);
                    denct.EditValue  = DateTime.Parse(ngaychungtu);
                    denht.EditValue  = DateTime.Parse(ngaychungtu);
                    cechd.Checked    = true;
                    cechd.Checked    = false;
                    txthtt.EditValue = 0;
                }
                catch
                {
                    XtraMessageBox.Show("Vui lòng kiểm tra lại < Ngày chứng từ >.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    F.Close();
                }
            }
        }
Beispiel #5
0
        public void themsct(string ngaychungtu, TextEdit txtsct, string mk, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau)
        {
            DataTable da    = new DataTable();
            int       dai   = 5;
            string    idkho = gen.GetString("select * from Stock where StockCode='" + mk + "'");
            string    thang = DateTime.Parse(ngaychungtu).Month.ToString();

            if (thang.Length < 2)
            {
                thang = "0" + thang;
            }
            string year    = DateTime.Parse(ngaychungtu).Year.ToString();
            string nam     = "-" + thang + "-" + year.Substring(2, 2);
            string sophieu = "08-" + mk + "-PCVT";

            try
            {
                string id = gen.GetString("select Top 1 RefNo from SUCAPayment where Month(RefDate)='" + DateTime.Parse(ngaychungtu).Month.ToString() + "' and Year(RefDate)='" + DateTime.Parse(ngaychungtu).Year.ToString() + "' and StockID='" + idkho + "'  order by RefNo DESC");
                int    ct = Int32.Parse(id.Substring(10, dai)) + 1;
                for (int i = 0; i < dai - ct.ToString().Length; i++)
                {
                    sophieu = sophieu + "0";
                }
                sophieu = sophieu + ct.ToString() + nam;
            }
            catch { sophieu = sophieu + "00001" + nam; }
            txtsct.Text = sophieu;
            checktruocsau(tsbttruoc, tsbtsau, mk, sophieu, ngaychungtu);
        }
Beispiel #6
0
        public Form1()
        {
            InitializeComponent();

            toolStrip1.Items.Add("ToolStrip");
            toolStrip1.ShowItemToolTips = true;
            toolStrip1.LayoutStyle      = ToolStripLayoutStyle.HorizontalStackWithOverflow;
            toolStrip1.CanOverflow      = true;

            ToolStripComboBox       cb        = new ToolStripComboBox("Gang");
            ToolStripButton         button    = new ToolStripButton("Button");
            ToolStripDropDownButton db        = new ToolStripDropDownButton("Drop");
            ToolStripSplitButton    sb        = new ToolStripSplitButton("Split");
            ToolStripSeparator      separator = new ToolStripSeparator();

            toolStrip1.Items.Add(cb);
            toolStrip1.Items.Add(button);
            toolStrip1.Items.Add(separator);
            toolStrip1.Items.Add(db);
            toolStrip1.Items.Add(sb);


            //************************************************************************************//


            ToolStripMenuItem menuItem  = new ToolStripMenuItem("File");
            ToolStripMenuItem menuItem1 = new ToolStripMenuItem("Open");
            ToolStripMenuItem menuItem2 = new ToolStripMenuItem("Save");

            menuItem1.ShortcutKeys = Keys.Control | Keys.O;
            menuItem2.CheckOnClick = true;
            menuItem.DropDownItems.Add(menuItem1);
            menuItem.DropDownItems.Add(menuItem2);

            menuStrip1.Items.Add(menuItem);
            menuStrip1.Items.Add(separator);
            menuStrip1.Items.Add(db);


            //************************************************************************************//

            l1 = new ToolStripLabel();
            l2 = new ToolStripLabel();
            l3 = new ToolStripLabel();

            l1.Text = "Текущие дата и время: ";

            statusStrip1.Items.Add(l1);
            statusStrip1.Items.Add(l2);
            statusStrip1.Items.Add(l3);

            timer1.Interval = 1000;
            timer1.Tick    += timer_Tick;
            timer1.Start();


            //************************************************************************************//


            ToolStripMenuItem copy  = new ToolStripMenuItem("Копировать");
            ToolStripMenuItem paste = new ToolStripMenuItem("Вставить");

            contextMenuStrip1.Items.Add(copy);
            contextMenuStrip1.Items.Add(paste);

            textBox1.ContextMenuStrip = contextMenuStrip1;

            copy.Click  += copy_Click;
            paste.Click += paste_Click;
        }
        private ToolStrip BuildViewTabPageToolStripItems(ToolStrip toolStrip, string name)
        {
            Screenshot selectedScreenshot = new Screenshot();

            ToolStripButton toolStripButtonConfigure = new ToolStripButton
            {
                Alignment   = ToolStripItemAlignment.Left,
                AutoToolTip = false,
                ToolTipText = "Configure this component to change image attributes, folder path, and filename pattern",
                Image       = Resources.configure
            };

            if (toolStrip.Tag is Screen screen)
            {
                if (_slideShow.SelectedSlide != null)
                {
                    selectedScreenshot = _screenshotCollection.GetScreenshot(_slideShow.SelectedSlide.Name, screen.ViewId);
                }

                toolStripButtonConfigure.Text = "Configure";

                toolStripButtonConfigure.Tag = toolStrip.Tag;

                toolStripButtonConfigure.Click += configureScreen_Click;
            }

            if (toolStrip.Tag is Region region)
            {
                if (_slideShow.SelectedSlide != null)
                {
                    selectedScreenshot = _screenshotCollection.GetScreenshot(_slideShow.SelectedSlide.Name, region.ViewId);
                }

                toolStripButtonConfigure.Text = "Configure";

                toolStripButtonConfigure.Tag = toolStrip.Tag;

                toolStripButtonConfigure.Click += configureRegion_Click;
            }

            ToolStripSplitButton toolStripSplitButtonEdit = new ToolStripSplitButton
            {
                Name        = name + "toolStripSplitButtonEdit",
                Text        = "Edit",
                Alignment   = ToolStripItemAlignment.Left,
                AutoToolTip = false,
                ToolTipText = "Edit the screenshot with an application or script",
                Image       = Resources.edit
            };

            toolStripSplitButtonEdit.ButtonClick += runEditor_Click;

            ToolStripButton toolStripButtonEncryptDecrypt = new ToolStripButton
            {
                Name        = name + "toolStripButtonEncryptDecrypt",
                Alignment   = ToolStripItemAlignment.Left,
                AutoToolTip = false
            };

            toolStripButtonEncryptDecrypt.Click += new EventHandler(encryptDecryptScreenshot_Click);

            if (toolStrip.Tag is Region regionEncryptDecrypt)
            {
                if (regionEncryptDecrypt.Encrypt)
                {
                    toolStripButtonEncryptDecrypt.Text  = "Decrypt";
                    toolStripButtonEncryptDecrypt.Image = Resources.unlock;
                }
                else
                {
                    toolStripButtonEncryptDecrypt.Text  = "Encrypt";
                    toolStripButtonEncryptDecrypt.Image = Resources._lock;
                }
            }

            if (toolStrip.Tag is Screen screenEncryptDecrypt)
            {
                if (screenEncryptDecrypt.Encrypt)
                {
                    toolStripButtonEncryptDecrypt.Text  = "Decrypt";
                    toolStripButtonEncryptDecrypt.Image = Resources.unlock;
                }
                else
                {
                    toolStripButtonEncryptDecrypt.Text  = "Encrypt";
                    toolStripButtonEncryptDecrypt.Image = Resources._lock;
                }
            }

            foreach (Editor editor in _formEditor.EditorCollection)
            {
                if (editor != null && _fileSystem.FileExists(editor.Application))
                {
                    toolStripSplitButtonEdit.DropDown.Items.Add(editor.Name, Icon.ExtractAssociatedIcon(editor.Application).ToBitmap(), runEditor_Click);
                }
            }

            ToolStripButton toolStripButtonEmail = new ToolStripButton
            {
                Text        = "Email",
                Alignment   = ToolStripItemAlignment.Left,
                AutoToolTip = false,
                Image       = Resources.email
            };

            toolStripButtonEmail.Click += new EventHandler(emailScreenshot_Click);

            string emailServerHost = _config.Settings.SMTP.GetByKey("EmailServerHost", _config.Settings.DefaultSettings.EmailServerHost).Value.ToString();

            int.TryParse(_config.Settings.SMTP.GetByKey("EmailServerPort", _config.Settings.DefaultSettings.EmailServerPort).Value.ToString(), out int emailServerPort);
            string emailClientUsername = _config.Settings.SMTP.GetByKey("EmailClientUsername", _config.Settings.DefaultSettings.EmailClientUsername).Value.ToString();
            string emailClientPassword = _config.Settings.SMTP.GetByKey("EmailClientPassword", _config.Settings.DefaultSettings.EmailClientPassword).Value.ToString();
            string emailMessageFrom    = _config.Settings.SMTP.GetByKey("EmailMessageFrom", _config.Settings.DefaultSettings.EmailMessageFrom).Value.ToString();
            string emailMessageTo      = _config.Settings.SMTP.GetByKey("EmailMessageTo", _config.Settings.DefaultSettings.EmailMessageTo).Value.ToString();

            if (string.IsNullOrEmpty(emailServerHost) ||
                emailServerPort <= 0 ||
                string.IsNullOrEmpty(emailClientUsername) ||
                string.IsNullOrEmpty(emailClientPassword) ||
                string.IsNullOrEmpty(emailMessageFrom) ||
                string.IsNullOrEmpty(emailMessageTo))
            {
                toolStripButtonEmail.ToolTipText = "Email settings have not been configured for " + _config.Settings.ApplicationName + " to email screenshots";
                toolStripButtonEmail.Enabled     = false;
            }
            else
            {
                toolStripButtonEmail.ToolTipText = "Email this screenshot using the configured Email settings";
                toolStripButtonEmail.Enabled     = true;
            }

            ToolStripButton toolStripButtonFileTransfer = new ToolStripButton
            {
                Text        = "File Transfer",
                Alignment   = ToolStripItemAlignment.Left,
                AutoToolTip = false,
                Image       = Resources.file_transfer
            };

            toolStripButtonFileTransfer.Click += new EventHandler(fileTransferScreenshot_Click);

            string fileTransferServerHost = _config.Settings.SFTP.GetByKey("FileTransferServerHost", _config.Settings.DefaultSettings.FileTransferServerHost).Value.ToString();

            int.TryParse(_config.Settings.SFTP.GetByKey("FileTransferServerPort", _config.Settings.DefaultSettings.FileTransferServerPort).Value.ToString(), out int fileTransferServerPort);
            string fileTransferClientUsername = _config.Settings.SFTP.GetByKey("FileTransferClientUsername", _config.Settings.DefaultSettings.FileTransferClientUsername).Value.ToString();
            string fileTransferClientPassword = _config.Settings.SFTP.GetByKey("FileTransferClientPassword", _config.Settings.DefaultSettings.FileTransferClientPassword).Value.ToString();

            if (string.IsNullOrEmpty(fileTransferServerHost) ||
                fileTransferServerPort <= 0 ||
                string.IsNullOrEmpty(fileTransferClientUsername) ||
                string.IsNullOrEmpty(fileTransferClientPassword))
            {
                toolStripButtonFileTransfer.ToolTipText = "File Transfer settings have not been configured for " + _config.Settings.ApplicationName + " to send screenshots to a file server";
                toolStripButtonFileTransfer.Enabled     = false;
            }
            else
            {
                toolStripButtonFileTransfer.ToolTipText = "Upload this screenshot to the specified file server using the configured File Transfer settings";
                toolStripButtonFileTransfer.Enabled     = true;
            }

            ToolStripButton toolStripButtonScreenshotMetadata = new ToolStripButton
            {
                Text        = "Metadata",
                Alignment   = ToolStripItemAlignment.Left,
                AutoToolTip = false,
                ToolTipText = "Show screenshot metadata (such as image format, width, height, date, time, and filepath)",
                Image       = Resources.properties
            };

            toolStripButtonScreenshotMetadata.Click += new EventHandler(screenshotMetadata_Click);

            ToolStripItem toolStripLabelFilename = new ToolStripLabel
            {
                Name      = name + "toolStripLabelFilename",
                Text      = "File:",
                Alignment = ToolStripItemAlignment.Right,
                Anchor    = AnchorStyles.Top | AnchorStyles.Left
            };

            ToolStripItem toolStripTextBoxFilename = new ToolStripTextBox
            {
                Name      = name + "toolStripTextBoxFilename",
                Alignment = ToolStripItemAlignment.Right,
                AutoSize  = false,
                ReadOnly  = true,
                Width     = 200,
                BackColor = Color.LightYellow,
                Text      = string.Empty
            };

            ToolStripItem toolstripButtonOpenFolder = new ToolStripButton
            {
                Name         = name + "toolstripButtonOpenFolder",
                Image        = Resources.openfolder,
                Alignment    = ToolStripItemAlignment.Right,
                AutoToolTip  = false,
                ToolTipText  = "Show screenshot location",
                DisplayStyle = ToolStripItemDisplayStyle.Image
            };

            toolstripButtonOpenFolder.Click += new EventHandler(showScreenshotLocation_Click);

            toolStrip.Items.Add(toolStripButtonConfigure);
            toolStrip.Items.Add(new ToolStripSeparator {
                Alignment = ToolStripItemAlignment.Left
            });
            toolStrip.Items.Add(toolStripSplitButtonEdit);
            toolStrip.Items.Add(toolStripButtonEncryptDecrypt);
            toolStrip.Items.Add(toolStripButtonEmail);
            toolStrip.Items.Add(toolStripButtonFileTransfer);
            toolStrip.Items.Add(toolStripButtonScreenshotMetadata);
            toolStrip.Items.Add(toolstripButtonOpenFolder);
            toolStrip.Items.Add(toolStripTextBoxFilename);
            toolStrip.Items.Add(toolStripLabelFilename);
            toolStrip.Items.Add(new ToolStripSeparator {
                Alignment = ToolStripItemAlignment.Right
            });

            return(toolStrip);
        }
Beispiel #8
0
        public void loadctmvt(string active, string role, DevExpress.XtraGrid.GridControl gridControl1, GridView gridView1, TextEdit txtsct, ComboBoxEdit cbldt, LookUpEdit ledv, DateEdit denct, DateEdit denht,
                              DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit tkno, DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit tkco, DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit mahang,
                              DevExpress.XtraEditors.Repository.RepositoryItemTextEdit soluong, DevExpress.XtraEditors.Repository.RepositoryItemTextEdit dongia, DevExpress.XtraEditors.Repository.RepositoryItemTextEdit thanhtien, Frm_phieuthuvt F, LookUpEdit ledt, TextEdit txtnn, TextEdit txtldn, TextEdit txtctg,
                              ToolStripButton tsbtsua, ToolStripButton tsbtxoa, ToolStripButton tsbtcat, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtnap, ToolStripButton tsbtin, string ngaychungtu, string tsbt, ComboBoxEdit cbthue, TextEdit txtshd, TextEdit txtkhhd, TextEdit txtnhd, TextEdit txtcth, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, DataTable khach, DataTable hang)
        {
            DataTable    dt     = new DataTable();
            phieuthutmvt pttmvt = new phieuthutmvt();

            pttmvt.loadstart(gridControl1, gridView1, cbldt, ledv, denct, denht, tkno, tkco, mahang, soluong, dongia, thanhtien, ledt, tsbtsua, tsbtxoa, tsbtcat, tsbtboghi, tsbtghiso, tsbtnap, tsbtin, ngaychungtu, dt, tsbt, cbthue, khach, hang);
            if (active == "1")
            {
                DataTable da = new DataTable();
                da = gen.GetTable("select  DebitAccount,CreditAccount,Amount,InventoryItemCode,a.SalePrice,Quantity from SUCAPaymentDetail a,InventoryItem b where a.InventoryItemID=b.InventoryItemID and RefID='" + role + "' order by SortOrder");
                for (int i = 0; i < da.Rows.Count; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr[0] = da.Rows[i][0].ToString();
                    dr[1] = da.Rows[i][1].ToString();
                    dr[2] = da.Rows[i][3].ToString();
                    dr[3] = da.Rows[i][5].ToString();
                    dr[4] = da.Rows[i][4].ToString();
                    dr[5] = da.Rows[i][2].ToString();
                    dt.Rows.Add(dr);
                }
                gridControl1.DataSource = dt;
                tsbtcat.Enabled         = false;

                F.Text = "Xem phiếu chi tiềm mặt mua vật tư";
                da     = gen.GetTable("select AccountingObjectCode,a.Contactname,JournalMemo,DocumentIncluded,RefDate,PostedDate,RefNo,StockCode,Posted,AccountingObjectType,Cancel,Tax,InvDate,InvSeries,InvNo  from SUCAPayment a, AccountingObject b,Stock c where a.AccountingObjectID=b.AccountingObjectID and a.StockID=c.StockID and RefID='" + role + "'");
                try
                {
                    cbldt.SelectedIndex = Int32.Parse(da.Rows[0][9].ToString());
                }
                catch { }
                ledv.EditValue  = da.Rows[0][7].ToString();
                ledt.EditValue  = da.Rows[0][0].ToString();
                txtnn.Text      = da.Rows[0][1].ToString();
                txtldn.Text     = da.Rows[0][2].ToString();
                txtctg.Text     = da.Rows[0][3].ToString();
                denct.EditValue = DateTime.Parse(da.Rows[0][4].ToString());
                denht.EditValue = DateTime.Parse(da.Rows[0][5].ToString());
                txtsct.Text     = da.Rows[0][6].ToString();
                txtshd.Text     = da.Rows[0][14].ToString();
                try
                {
                    txtnhd.EditValue = DateTime.Parse(da.Rows[0][12].ToString());
                }
                catch { txtnhd.Text = ""; }
                txtkhhd.Text = da.Rows[0][13].ToString();
                try
                {
                    cbthue.Text = da.Rows[0][11].ToString();
                }
                catch { }
                if (da.Rows[0][8].ToString() == "True")
                {
                    tsbtghiso.Visible = false;
                    tsbtboghi.Visible = true;
                    tsbtsua.Enabled   = false;
                }
                else
                {
                    tsbtboghi.Visible = false;
                    tsbtghiso.Visible = true;
                }
                if (da.Rows[0][10].ToString() == "True")
                {
                    tsbtboghi.Enabled = false;
                    tsbtghiso.Enabled = false;
                }
                txtcth.Text = gridView1.Columns["Thành tiền"].SummaryText;
                checktruocsau(tsbttruoc, tsbtsau, ledv.EditValue.ToString(), txtsct.Text, ngaychungtu);
            }
            else
            {
                try
                {
                    F.Text = "Thêm phiếu chi tiền mặt mua vật tư";
                    if (role == null)
                    {
                        ledv.ItemIndex = 0;
                    }
                    else
                    {
                        ledv.EditValue = role;
                    }
                    denct.EditValue = DateTime.Parse(ngaychungtu);
                    denht.EditValue = DateTime.Parse(ngaychungtu);
                    txtcth.Text     = gridView1.Columns["Thành tiền"].SummaryText;
                }
                catch
                {
                    XtraMessageBox.Show("Vui lòng kiểm tra lại < Ngày chứng từ >.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    F.Close();
                }
            }
        }
 public ToolStripSplitButtonAccessibleObject(ToolStripSplitButton item) : base(item)
 {
     _owningToolStripSplitButton = item;
 }
Beispiel #10
0
        public static void CheckControls(object parentControl, string strShortcutKeys)
        {
            try
            {
                if (parentControl is MenuStrip)
                {
                    MenuStrip menu = (MenuStrip)parentControl;
                    foreach (ToolStripItem item in menu.Items)
                    {
                        if (item.Tag != null && item is ToolStripButton)
                        {
                            ToolStripButton button = (ToolStripButton)item;
                            if (button.Tag.ToString().Equals(strShortcutKeys))
                            {
                                button.PerformClick();
                                return;
                            }
                        }
                        CheckControls(item, strShortcutKeys);
                    }
                    return;
                }
                if (parentControl is ToolStripMenuItem)
                {
                    ToolStripItemCollection menuitems = ((ToolStripMenuItem)parentControl).DropDownItems;
                    foreach (ToolStripItem item in menuitems)
                    {
                        if (item.Tag != null)
                        {
                            ToolStripItem button = (ToolStripItem)item;
                            if (button.Tag.ToString().Equals(strShortcutKeys))
                            {
                                button.PerformClick();
                                return;
                            }
                        }
                        CheckControls(item, strShortcutKeys);
                    }
                    return;
                }
                if (parentControl is ToolStripSplitButton)
                {
                    ToolStripSplitButton menu = (ToolStripSplitButton)parentControl;

                    foreach (ToolStripItem item in menu.DropDown.Items)
                    {
                        if (item.Tag != null)
                        {
                            ToolStripItem button = (ToolStripItem)item;
                            if (button.Tag.ToString().Equals(strShortcutKeys))
                            {
                                button.PerformClick();
                                return;
                            }
                        }
                        CheckControls(item, strShortcutKeys);
                    }
                    return;
                }

                if (parentControl is ToolStrip)
                {
                    ToolStrip menu = (ToolStrip)parentControl;
                    foreach (ToolStripItem item in menu.Items)
                    {
                        if (item.Tag != null)
                        {
                            ToolStripItem button = (ToolStripItem)item;
                            if (button.Tag.ToString().Equals(strShortcutKeys))
                            {
                                button.PerformClick();
                                return;
                            }
                        }
                        CheckControls(item, strShortcutKeys);
                    }
                    return;
                }
                if (parentControl is Panel)
                {
                    foreach (Control item in (parentControl as Control).Controls)
                    {
                        if (item is Button)
                        {
                            Button button = (Button)item;
                            if (button.Tag.ToString().Equals(strShortcutKeys))
                            {
                                button.PerformClick();
                                return;
                            }
                        }
                    }
                    return;
                }


                //if (parentControl is DevExpress.XtraNavBar.NavBarControl)
                //{
                //    DevExpress.XtraNavBar.NavBarControl _navBarControl = (DevExpress.XtraNavBar.NavBarControl)parentControl;
                //    foreach (DevExpress.XtraNavBar.NavBarGroup _navBarGroup in _navBarControl.Groups)
                //    {
                //        foreach (DevExpress.XtraNavBar.NavBarItemLink item in _navBarGroup.ItemLinks)
                //        {
                //            if (item.Item.Tag != null && !item.Item.Tag.ToString().Equals(""))
                //            {
                //                bool isExitsPermission = CheckExistsValue(item.Item.Tag.ToString(),strShortcutKeys);
                //                DevExpress.XtraNavBar.NavBarItemLink button = (DevExpress.XtraNavBar.NavBarItemLink)item.Item;
                //                button.
                //                if (!isExitsPermission)
                //                    item.Item.Appearance.ForeColor = Color.DarkGray;
                //            }
                //        }
                //    }
                //    return;
                //}
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
 // Constructors
 public ToolStripSplitButtonAccessibleObject(ToolStripSplitButton item)
 {
 }
        private static void WriteToolStripItemEntrys(ref StringBuilder stringBuilder, ToolStripItem control, string name, int depth, bool withIndent, bool asXml)
        {
            ToolStripComboBox tscb = control as ToolStripComboBox;

            if (tscb != null && !string.IsNullOrEmpty(name))
            {
                bool hasChilds = (tscb.Items.Count > 0);
                WriteToolStripItemEntry(ref stringBuilder, tscb, depth + 1, withIndent, asXml, hasChilds);

                int i = 0;
                foreach (var item in tscb.Items)
                {
                    WriteEntry(ref stringBuilder, name + CB_ITEM + ++i, item.ToString(), depth + 2, withIndent, (!asXml) ? NodeType.SimpleSettings : NodeType.ChildControl);
                }

                if (asXml && hasChilds)
                {
                    stringBuilder.AppendLine(new string(INDENT, depth + 1) + CLOSE_CONTROL_XML_NODE);
                }

                return;
            }

            ToolStripDropDownButton tsddb = control as ToolStripDropDownButton;

            if (tsddb != null)
            {
                bool hasChilds = tsddb.HasDropDownItems;
                WriteToolStripItemEntry(ref stringBuilder, tsddb, depth + 1, withIndent, asXml, hasChilds);

                if (hasChilds)
                {
                    foreach (ToolStripItem item in tsddb.DropDownItems)
                    {
                        WriteToolStripItemEntrys(ref stringBuilder, item, item.Name, depth + 2, withIndent, asXml);
                    }
                }

                if (asXml && hasChilds)
                {
                    stringBuilder.AppendLine(new string(INDENT, depth + 1) + CLOSE_CONTROL_XML_NODE);
                }

                return;
            }

            ToolStripSplitButton tssb = control as ToolStripSplitButton;

            if (tssb != null)
            {
                bool hasChilds = tssb.HasDropDownItems;
                WriteToolStripItemEntry(ref stringBuilder, tssb, depth + 1, withIndent, asXml, hasChilds);

                if (hasChilds)
                {
                    foreach (ToolStripItem item in tssb.DropDownItems)
                    {
                        WriteToolStripItemEntrys(ref stringBuilder, item, item.Name, depth + 2, withIndent, asXml);
                    }
                }

                if (asXml && hasChilds)
                {
                    stringBuilder.AppendLine(new string(INDENT, depth + 1) + CLOSE_CONTROL_XML_NODE);
                }

                return;
            }

            ToolStripLabel tsl = control as ToolStripLabel;

            if (tsl != null)
            {
                WriteToolStripItemEntry(ref stringBuilder, tsl, depth + 1, withIndent, asXml, false);
                return;
            }

            ToolStripTextBox tstb = control as ToolStripTextBox;

            if (tstb != null)
            {
                WriteToolStripItemEntry(ref stringBuilder, tstb, depth + 1, withIndent, asXml, false);
                return;
            }

            ToolStripMenuItem tsmi = control as ToolStripMenuItem;

            if (tsmi != null)
            {
                bool hasChilds = (tsmi.HasDropDownItems); // || tsmi.HasDropDown);
                WriteToolStripItemEntry(ref stringBuilder, tsmi, depth + 1, withIndent, asXml, hasChilds);

                if (tsmi.HasDropDownItems)
                {
                    foreach (ToolStripItem item in tsmi.DropDownItems)
                    {
                        WriteToolStripItemEntrys(ref stringBuilder, item, item.Name, depth + 2, withIndent, asXml);
                    }
                }

                ////else if (tsmi.HasDropDown)
                ////    foreach (ToolStripItem item in tsmi.DropDown.Items)
                ////        WriteToolStripItemEntrys(ref stringBuilder, item, item.Name, depth + 2, withIndent, asXml);

                if (asXml && hasChilds)
                {
                    stringBuilder.AppendLine(new string(INDENT, depth + 1) + CLOSE_CONTROL_XML_NODE);
                }

                return;
            }

            ToolStripButton tsb = control as ToolStripButton;

            if (tsb != null)
            {
                WriteToolStripItemEntry(ref stringBuilder, tsb, depth + 1, withIndent, asXml, false);
                return;
            }
        }
Beispiel #13
0
 public static void Add(this ToolStripSplitButton target, params ToolStripItem[] items) =>
 target.DropDownItems.AddRange(items);
Beispiel #14
0
 public static void PopulateBackDropDown(ToolStripSplitButton button)
 {
     PopulateMenuWith(button, backwardHistory, Back);
 }
Beispiel #15
0
        public void ePrint(string printPage = "OR", Form parent = null)
        {
            PrintDialog        printDioalog  = new PrintDialog();
            PrintDocument      printDocument = new PrintDocument();
            PrintPreviewDialog previewDialog = new PrintPreviewDialog();

            previewDialog.Height = 600;
            previewDialog.Width  = 800;


            previewDialog.PrintPreviewControl.Rows = 10;


            // set properties
            if (isLandscape)
            {
                printDocument.DefaultPageSettings.Landscape = true;
            }



            printDioalog.Document = printDocument;

            switch (printPage)
            {
            case "OR":
            {
                printDocument.PrintPage += new PrintPageEventHandler(ePrint_officialReceipt);
                break;
            }

            case "OP":
            {
                printDocument.PrintPage += new PrintPageEventHandler(ePrint_orderOfPayment);
                break;
            }

            case "DRLayoutOne":
            {
                printDocument.PrintPage += new PrintPageEventHandler(ePrint_dailyReportLayoutOne);
                break;
            }
            }

            if (forReport)
            {
                // do some Stuff
                // Show Print Preview Dialog
                previewDialog.Document = printDocument;

                // FROM http://stackoverflow.com/questions/18421107/setting-initial-state-of-printpreviewdialog-controls
                ToolStripSplitButton zoomButton = ((ToolStrip)previewDialog.Controls[1]).Items[1] as ToolStripSplitButton;
                zoomButton.DropDownItems[5].PerformClick();//Check the 75% item in the zoom list

                if (parent == null)
                {
                    previewDialog.ShowDialog();
                }
                else
                {
                    previewDialog.MdiParent = parent;
                    previewDialog.Show();
                }


                printDocument.DefaultPageSettings.PaperSize = new PaperSize("Legal", 850, 1400);
            }


            DialogResult result = printDioalog.ShowDialog();

            if (result == DialogResult.OK)
            {
                printDocument.Print();
            }
        }
Beispiel #16
0
    //void TestMenu2()
    //{
    //	var m = new AMenu();
    //	m["One"] = o => AOutput.Write(o);
    //	m["Two"] = o => AOutput.Write(o);
    //	m.LazySubmenu("Submenu 1").Fill = _ => {
    //		AOutput.Write("adding items of " + m.CurrentAddMenu.OwnerItem);
    //		m["Three"] = o => AOutput.Write(o);
    //		m["Four"] = o => AOutput.Write(o);
    //		m.LazySubmenu("Submenu 2", _ => {
    //			AOutput.Write("adding items of " + m.CurrentAddMenu.OwnerItem);
    //			m["Five"] = o => AOutput.Write(o);
    //			m["Six"] = o => AOutput.Write(o);
    //		});
    //		m["Seven"] = o => AOutput.Write(o);
    //	};
    //	m["Eight"] = o => AOutput.Write(o);
    //	m.Show();

    //}

    //void TestMenu2()
    //{
    //	var m = new AMenu();
    //	m["One"] = o => AOutput.Write(o);
    //	m["Two"] = o => AOutput.Write(o);
    //	m.LazySubmenu("Submenu 1");
    //	m.LazyFill = _ => {
    //		AOutput.Write("adding items of " + m.CurrentAddMenu.OwnerItem);
    //		m["Three"] = o => AOutput.Write(o);
    //		m["Four"] = o => AOutput.Write(o);
    //		m.LazySubmenu("Submenu 2", _ => {
    //			AOutput.Write("adding items of " + m.CurrentAddMenu.OwnerItem);
    //			m["Five"] = o => AOutput.Write(o);
    //			m["Six"] = o => AOutput.Write(o);
    //		});
    //		m["Seven"] = o => AOutput.Write(o);
    //	};
    //	m["Eight"] = o => AOutput.Write(o);
    //	m.Show();

    //}

#if false
    void TestToolbar()
    {
        for (int i = 0; i < 1; i++)
        {
            var t = new AToolbar("123");
            //t.NoText = true;
            //t.Border= TBBorder.Sizable3;t.Control.Text = "Toolbar";
            //t.Border = TBBorder.SizableWithCaptionX;

            //t["Find", @"Q:\app\find.ico"] = o => AOutput.Write(o);
            //t["Copy", @"Q:\app\copy.ico"] = o => AOutput.Write(o);
            //t.Separator("Tpi group");
            //t["Delete", @"Q:\app\delete.ico"] = o => AOutput.Write(o);
            //t["No image"] = o => AOutput.Write(o);
            //t["TT", tooltip: "WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW WWWWWWWWWWWW "] = o => AOutput.Write(o);
            ////t.LastButton.DisplayStyle = ToolStripItemDisplayStyle.Image;
            ////t.LastButton.AutoToolTip = false;
            ////t.LastButton.ToolTipText = "ggg";
            //t.Separator();
            //t["Run", @"Q:\app\run.ico"] = o => AOutput.Write(o);
            //t.Separator("");
            //t["Paste text", @"Q:\app\paste.ico"] = o => AOutput.Write(o);
            //t.LastButton.ToolTipText = "Toooooltip";

            //t.ExtractIconPathFromCode = true;
            //t["Auto icon"] = o => AOutput.Write("notepad.exe");
            //t["Failed icon", @"Q:\app\-.ico"] = o => AOutput.Write(o);
            ////t.LastButton.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
            ////t.Separator("");
            ////t.Add(new ToolStripTextBox { ToolTipText= "ToolStripTextBox", AutoSize=false, Width=50 });
            ////t.Add(new ToolStripComboBox { ToolTipText= "ToolStripComboBox", AutoSize=false, Width=50 });
            ////t.Add(new ToolStripTextBox());
            ////t.Add(new ToolStripTextBox());
            ////t.Add(new ToolStripTextBox());
            ////t.Add(new ToolStripButton("aaa"));
            ////t.Add(new ToolStripButton("bbb"));
            ////t["Multi\r\nline"] = o => AOutput.Write(o);

            //t["None"] = o => _B(TBBorder.None);
            //t["SWC"] = o => _B(TBBorder.SizableWithCaption);
            //t["Sizable1"] = o => _B(TBBorder.Sizable1);
            //t["Sizable2"] = o => _B(TBBorder.Sizable2);
            //t["Sizable3"] = o => _B(TBBorder.Sizable3);
            //t["Sizable3D"] = o => _B(TBBorder.Sizable3D);
            //t["Sizable"] = o => _B(TBBorder.Sizable);
            //t["FixedWithCaption"] = o => _B(TBBorder.FixedWithCaption);
            //t["SizableWithCaption"] = o => _B(TBBorder.SizableWithCaption);
            //t["Close"] = o => t.Close();

#if false
            var dd = new ToolStripDropDownButton("DD");
            t.Add(dd, @"Q:\app\find.ico");
            dd.DropDownOpening += (unu, sed) => {
                var m = new AMenu(dd);
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => AOutput.Write(o);
                }
            };
            var sb = new ToolStripSplitButton("SB");
            t.Add(sb, @"Q:\app\copy.ico", o => AOutput.Write(o));
#elif true
            //t.Control.Font = new Font("Courier New", 16);
            //t.Control.RightToLeft = RightToLeft.Yes;
            t.MenuButton("DD", m => {
                AOutput.Write("dd");
                //m.MultiShow = false;
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => AOutput.Write(o);
                }
            }, @"Q:\app\find.ico", "MenuButton");
            t.SplitButton("SB", m => {
                m["one"] = o => AOutput.Write(o);
                //var sb = m.Control.OwnerItem as ToolStripSplitButton;
                //AOutput.Write(sb);
                //sb.DefaultItem = m.LastItem;
                using (m.Submenu("Sub")) {
                    m["si"] = o => AOutput.Write(o);
                }
            }, @"Q:\app\copy.ico", "SplitButton", o => AOutput.Write(o));
            t.Separator("");
            t[true, "DD2", @"Q:\app\delete.ico"] = m => {
                AOutput.Write("create menu");
                //m.MultiShow = false;
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => AOutput.Write(o);
                }
            };
            //t.SplitButton("SB", o => {
            //	AOutput.Write(o);
            //}, m => {
            //	m["one"] = o => AOutput.Write(o);
            //	using(m.Submenu("Sub")) {
            //		m["si"] = o => AOutput.Write(o);
            //	}
            //}, @"Q:\app\copy.ico", "SplitButton");
            //Action<AMenu> menu1 = m => {
            //	m["one"] = o => AOutput.Write(o);
            //	using(m.Submenu("Sub")) {
            //		m["si"] = o => AOutput.Write(o);
            //	}
            //};
            //t.MenuButton("DD", menu1, @"Q:\app\find.ico", "MenuButton");
#elif false
            t.MenuButton("DD", @"Q:\app\find.ico");
            t.Menu = m => {
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["si"] = o => AOutput.Write(o);
                }
            };
#else
            t.MenuButton("DD", @"Q:\app\find.ico").Menu = m => {
                AOutput.Write("dd");
                //m.MultiShow = false;
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["two"] = o => AOutput.Write(o);
                }
            };
            t.SplitButton("SB", o => AOutput.Write(o), @"Q:\app\copy.ico").Menu = m => {
                AOutput.Write("dd");
                m["one"] = o => AOutput.Write(o);
                using (m.Submenu("Sub")) {
                    m["two"] = o => AOutput.Write(o);
                }
            };
#endif
            //t.Separator("");
            ////t["GC"] = o => GC.Collect();

            //var dd = new ToolStripSplitButton("SB2", null, (unu,sed)=>AOutput.Write("click"));
            //t.Add(dd, @"Q:\app\delete.ico");
            //dd.DropDownOpening += (unu, sed) => {
            //	var m = new AMenu();
            //	dd.DropDown = m.Control;
            //	m["one"] = o => AOutput.Write(o);
            //};
            //dd.ButtonClick += (unu, sed) => AOutput.Write("button click");
            //dd.DoubleClickEnabled = true;
            //dd.ButtonDoubleClick += (unu, sed) => AOutput.Write("button double click");

            //ATimer.After(3000, _ => {
            //	var c = t.Control.Items[0];
            //	c.Select();
            //});

            //void _B(TBBorder b){
            //	t.Border = b;
            //	//AOutput.Write(AWnd.More.BorderWidth((AWnd)t.Control));
            //}

            //t.Bounds = new Rectangle(i * 300 + 700, 200, 200, 200);
            t.Show();
            //t.Window.ActivateLL();
            ATime.SleepDoEvents(200);

            //for(int j = 1; j <= (int)TBBorder.SizableWithCaptionX; j++) {
            //	ATime.SleepDoEvents(1000);
            //	t.Border = (TBBorder)j;
            //}

            //ATime.SleepDoEvents(1000);
            //t.Border = TBBorder.FixedWithCaption;
            //ATime.SleepDoEvents(3000);
            //t.Border = TBBorder.SizableWithCaption;

            //var m = new AMenu();
            //using(m.Submenu("Sub")) {

            //}
            //m.Show()
        }

        //var c = new System.Windows.Forms.VisualStyles.VisualStyleRenderer(VisualStyleElement.Window.FrameLeft.Inactive).GetColor(ColorProperty.BorderColor);
        //AOutput.Write((uint)c.ToArgb());

        //ATimer.After(500, _ => {
        //	var w = (AWnd)t.Control;
        //	//w.SetStyle(WS.DLGFRAME, SetAddRemove.Add);
        //});

        ADialog.Options.TopmostIfNoOwnerWindow = true;
        ADialog.Show();

        //ATimer.After(10000, _ => Application.Exit());
        //Application.Run();
    }
        protected void CreateVPNSupport()
        {
            VpnConnUtils.InitSettings();

            //
            // vpnButton
            //
            this.vpnButton = new System.Windows.Forms.ToolStripSplitButton();
            this.vpnButton.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.vpnButton.Enabled               = true;
            this.vpnButton.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.vpnButton.Name        = "vpnButton";
            this.vpnButton.Size        = new System.Drawing.Size(19, 23);
            this.vpnButton.Text        = "VPN";
            this.vpnButton.ToolTipText = "VPN";
            vpnButton.Image            = VpnSelectorLibRes.network_off;
            //vpnButton.DoubleClick += VpnButton_DoubleClick; - do not working

            //
            // ipAddressLabel
            //
            this.ipAddressLabel             = new System.Windows.Forms.ToolStripStatusLabel();
            this.ipAddressLabel.AutoToolTip = true;
            this.ipAddressLabel.Enabled     = false;
            this.ipAddressLabel.Name        = "ipAddressLabel";
            this.ipAddressLabel.Size        = new System.Drawing.Size(66, 20);
            this.ipAddressLabel.Text        = "127.0.0.1";
            this.ipAddressLabel.ToolTipText = "127.0.0.1";

            this.statusBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.eventWarrningButton, this.vpnButton, this.ipAddressLabel
            });

            if (useMainTrayIconForVPN && BaseApplicationContext.NotifyIcon != null)
            {
                vpnNotifyIcon = BaseApplicationContext.NotifyIcon;
            }
            else
            {
                vpnNotifyIcon = new NotifyIcon(components)
                {
                    ContextMenuStrip = new ContextMenuStrip(),
                    Icon             = vpnOffIcon,
                    Text             = "VPN",
                    Visible          = true
                };
            }

            vpnButton.MouseDown += VpnButton_MouseDown;
            vpnNotifyIcon.ContextMenuStrip.Opening += VpnNotifyIconContextMenuStrip_Opening;
            vpnNotifyIcon.DoubleClick += VpnNotifyIcon_DoubleClick;

            VpnConnUtils.OnCheckExternalIPAddressComplatedEvent += JustNetworkUtils_OnCheckExternalIPAddressComplatedEvent;
            VpnConnUtils.VpnDisconnectedEvent += VpnSelector_OnVpnDisconnectedEvent;
            VpnConnUtils.VpnConnectedEvent    += VpnSelector_OnVpnConnectedEvent;
            VpnConnUtils.VpnDialerErrorEvent  += VpnSelector_OnVpnDialerErrorEvent;

            VpnConnUtils.CreateDialerAndBeginWatch();
            if (VpnConnUtils.CurrentVPNServer != null)//checked in InitApplication()
            {
                //vpn connection presents before app started
                if (VpnConnUtils.CurVPNServerChangedEvent != null)
                {
                    VpnConnUtils.CurVPNServerChangedEvent(null, new CurVPNServerChangedEventArgs());
                }
                ProcessVpnConnectedEvent();
            }
            if ((bool)FrwConfig.Instance.GetPropertyValue(VpnConnUtils.SETTING_CHECK_IP_ON_STARTUP, true) == true)
            {
                VpnConnUtils.ConfirmIpAddressAsync();
            }
        }
Beispiel #18
0
        //save//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void checkpctmvt(string active, string role, Frm_phieuthuvt F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, ComboBoxEdit cbldt, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                                TextEdit txtnn, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                                ToolStripButton tsbtcat, ToolStripButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, ComboBoxEdit cbthue, TextEdit txtshd, TextEdit txtkhhd, TextEdit txtnhd, string userid, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[20, 8];
                string check = "0";
                for (int i = 0; i < gridView1.RowCount - 1; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Tài khoản có").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 0] = gridView1.GetRowCellValue(i, "Tài khoản có").ToString();
                    if (gridView1.GetRowCellValue(i, "Tài khoản nợ").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 1] = gridView1.GetRowCellValue(i, "Tài khoản nợ").ToString();
                    if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail[i, 2] = mh;
                    }

                    if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 3] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
                    if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                }
                if (check == "1")
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Tài khoản có> <Tài khoản nợ> <Mã hàng> <Số lượng> <Đơn giá> <Thành tiền> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string dv   = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                    string tong = gridView1.Columns["Thành tiền"].SummaryText;
                    tong = tong.Replace(".", "");
                    string ldt;
                    if (cbldt.EditValue.ToString() == "Khách hàng")
                    {
                        ldt = "0";
                    }
                    else if (cbldt.EditValue.ToString() == "Nhà cung cấp")
                    {
                        ldt = "1";
                    }
                    else
                    {
                        ldt = "2";
                    }
                    string nhd = txtnhd.Text;
                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from SUCAPayment where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), tsbttruoc, tsbtsau);
                            XtraMessageBox.Show("Số phiếu trùng, hệ thống tự động chỉnh số phiếu của bạn thành " + txtsct.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch { }
                        if (nhd == "")
                        {
                            gen.ExcuteNonquery("insert into SUCAPayment(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,TotalAmount,Tax,InvSeries,InvNo,EmployeeID) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "','" + txtdc.Text + "',N'" + txtnn.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + tong + "','" + cbthue.Text + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + userid + "')");
                        }
                        else
                        {
                            gen.ExcuteNonquery("insert into SUCAPayment(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,TotalAmount,Tax,InvDate,InvSeries,InvNo,EmployeeID) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "','" + txtdc.Text + "',N'" + txtnn.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + tong + "','" + cbthue.Text + "','" + txtnhd.EditValue.ToString() + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + userid + "')");
                        }
                        string refid = gen.GetString("select * from SUCAPayment where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into SUCAPaymentDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,SalePrice) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 3] + "'," + i + ",'" + detail[i, 2] + "','" + detail[i, 4] + "')");
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,Goods) values(newid(),'" + refid + "','" + txtsct.Text + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + dv + "')");
                        }
                    }
                    else
                    {
                        if (nhd == "")
                        {
                            gen.ExcuteNonquery("update SUCAPayment set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress='" + txtdc.Text + "',Contactname=N'" + txtnn.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',TotalAmount='" + tong + "',Posted='False',Tax='" + cbthue.Text + "',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',EmployeeID='" + userid + "'  where RefID='" + role + "'");
                        }
                        else
                        {
                            gen.ExcuteNonquery("update SUCAPayment set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress='" + txtdc.Text + "',Contactname=N'" + txtnn.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',TotalAmount='" + tong + "',Posted='False',Tax='" + cbthue.Text + "',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',InvDate='" + txtnhd.EditValue.ToString() + "',EmployeeID='" + userid + "'  where RefID='" + role + "'");
                        }
                        gen.ExcuteNonquery("delete  from  SUCAPaymentDetail where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into SUCAPaymentDetail(RefDetailID,RefID,DebitAccount,CreditAccount,Amount,Quantity,SortOrder,InventoryItemID,SalePrice) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 3] + "'," + i + ",'" + detail[i, 2] + "','" + detail[i, 4] + "')");
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,Goods) values(newid(),'" + role + "','" + txtsct.Text + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + dv + "')");
                        }
                    }
                    F.myac();
                    F.getactive("1");
                    F.Text = "Xem phiếu thu tiền mặt bán vật tư";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #19
0
 private void PreventToolStripSplitButtonClosing(ToolStripSplitButton control)
 {
 }
        protected override void OnRenderSplitButtonBackground(
            ToolStripItemRenderEventArgs e)
        {
            ToolStrip            toolStrip = e.ToolStrip;
            ToolStripSplitButton item      = e.Item as ToolStripSplitButton;

            if (item != null)
            {
                Graphics           g    = e.Graphics;
                LinearGradientMode mode =
                    toolStrip.Orientation == Orientation.Horizontal ?
                    LinearGradientMode.Vertical : LinearGradientMode.Horizontal;
                Rectangle             bounds = new Rectangle(Point.Empty, item.Size);
                SmoothingModeGraphics sg     = new SmoothingModeGraphics(g);

                Color arrowColor = toolStrip.Enabled ?
                                   ColorTable.Fore : SystemColors.ControlDark;

                if (item.BackgroundImage != null)
                {
                    Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                    ControlPaintEx.DrawBackgroundImage(
                        g,
                        item.BackgroundImage,
                        ColorTable.BackNormal,
                        item.BackgroundImageLayout,
                        bounds,
                        clipRect);
                }

                if (item.ButtonPressed)
                {
                    Rectangle buttonBounds = item.ButtonBounds;
                    Padding   padding      = (item.RightToLeft == RightToLeft.Yes) ?
                                             new Padding(0, 1, 1, 1) : new Padding(1, 1, 0, 1);
                    buttonBounds = LayoutUtils.DeflateRect(buttonBounds, padding);
                    RenderHelper.RenderBackgroundInternal(
                        g,
                        bounds,
                        ColorTable.BackHover,
                        ColorTable.Border,
                        ColorTable.BackNormal,
                        RoundStyle.All,
                        true,
                        true,
                        mode);

                    buttonBounds.Inflate(-1, -1);
                    g.SetClip(buttonBounds);
                    RenderHelper.RenderBackgroundInternal(
                        g,
                        buttonBounds,
                        ColorTable.BackPressed,
                        ColorTable.Border,
                        ColorTable.BackNormal,
                        RoundStyle.Left,
                        false,
                        true,
                        mode);
                    g.ResetClip();

                    using (Pen pen = new Pen(ColorTable.Border))
                    {
                        g.DrawLine(
                            pen,
                            item.SplitterBounds.Left,
                            item.SplitterBounds.Top,
                            item.SplitterBounds.Left,
                            item.SplitterBounds.Bottom);
                    }
                    base.DrawArrow(
                        new ToolStripArrowRenderEventArgs(
                            g,
                            item,
                            item.DropDownButtonBounds,
                            arrowColor,
                            ArrowDirection.Down));
                    return;
                }

                if (item.Pressed || item.DropDownButtonPressed)
                {
                    RenderHelper.RenderBackgroundInternal(
                        g,
                        bounds,
                        ColorTable.BackPressed,
                        ColorTable.Border,
                        ColorTable.BackNormal,
                        RoundStyle.All,
                        true,
                        true,
                        mode);
                    base.DrawArrow(
                        new ToolStripArrowRenderEventArgs(
                            g,
                            item,
                            item.DropDownButtonBounds,
                            arrowColor,
                            ArrowDirection.Down));
                    return;
                }

                if (item.Selected)
                {
                    RenderHelper.RenderBackgroundInternal(
                        g,
                        bounds,
                        ColorTable.BackHover,
                        ColorTable.Border,
                        ColorTable.BackNormal,
                        RoundStyle.All,
                        true,
                        true,
                        mode);
                    using (Pen pen = new Pen(ColorTable.Border))
                    {
                        g.DrawLine(
                            pen,
                            item.SplitterBounds.Left,
                            item.SplitterBounds.Top,
                            item.SplitterBounds.Left,
                            item.SplitterBounds.Bottom);
                    }
                    base.DrawArrow(
                        new ToolStripArrowRenderEventArgs(
                            g,
                            item,
                            item.DropDownButtonBounds,
                            arrowColor,
                            ArrowDirection.Down));
                    return;
                }

                base.DrawArrow(
                    new ToolStripArrowRenderEventArgs(
                        g,
                        item,
                        item.DropDownButtonBounds,
                        arrowColor,
                        ArrowDirection.Down));
                return;
            }

            base.OnRenderSplitButtonBackground(e);
        }
Beispiel #21
0
        /// <summary>
        /// Creates a menu or toolbar item.
        /// </summary>
        /// <param name="x">XML element containing item properties.</param>
        /// <param name="isMenu">false if toolbar item, true if menu item (also if menu bar item).</param>
        ToolStripItem _CreateChildItem(XElement x, bool isMenu)
        {
            string s, tag = x.Name.LocalName;

            if (tag == "sep")
            {
                return new ToolStripSeparator()
                       {
                           Tag = x
                       }
            }
            ;

            ToolStripItem item; ToolStripMenuItem mi;
            bool          isControl = false, needHandler = false;

            if (isMenu)
            {
                mi = new ToolStripMenuItem();

                item = mi;
                if (x.HasElements || x.HasAttr("dd"))
                {
                    _Submenu(x, mi, tag);
                }
                else
                {
                    needHandler = true;
                }
            }
            else if (x.HasAttr("type"))
            {
                isControl = true;
                string cue = x.Attr("cue");
                s = x.Attr("type");
                switch (s)
                {
                case "edit":
                    var ed = new ToolStripSpringTextBox();
                    if (cue != null)
                    {
                        ed.ZSetCueBanner(cue);
                    }
                    item = ed;
                    break;

                case "combo":
                    var combo = new ToolStripSpringComboBox();
                    if (cue != null)
                    {
                        combo.ZSetCueBanner(cue);
                    }
                    item = combo;
                    break;

                default:
                    Debug.Assert(false);
                    return(null);
                }
                if (cue != null)
                {
                    item.AccessibleName = cue;
                }
            }
            else if (x.HasElements || x.HasAttr("dd"))
            {
                ToolStripDropDownItem ddi;
                var handler = _callbacks.GetClickHandler(tag);
                if (handler != null)
                {
                    var sb = new ToolStripSplitButton();
                    sb.ButtonClick += handler;
                    ddi             = sb;
                }
                else
                {
                    ddi = new ToolStripDropDownButton();
                }
                item = ddi;
                _Submenu(x, ddi, tag);
            }
            else
            {
                needHandler = true;
                var b = new ToolStripButton();
                item = b;
            }

            item.Name = tag;
            item.Tag  = x;

            _SetItemProperties(x, item, isMenu, isControl);

            if (needHandler)
            {
                var handler = _callbacks.GetClickHandler(tag);
                if (handler != null)
                {
                    item.Click += handler;
                }
                else
                {
                    ADebug.Print("no handler of " + tag);
                    //return null;
                    //item.Enabled = false;
                    item.Visible = false;
                }
            }

            return(item);
        }

        void _Submenu(XElement x, ToolStripDropDownItem ddItem, string tag)
        {
            var s = x.Attr("dd");

            if (!s.NE())
            {
                ddItem.DropDown = Submenus[s];
            }
            else
            {
                var dd = ddItem.DropDown as ToolStripDropDownMenu;                 //note: not ddItem.DropDown=new ToolStripDropDownMenu(). Then eg hotkeys don't work.
                dd.Name = tag;
                dd.Tag  = x;
                Submenus.Add(tag, dd);

                if (s != null)                              //attribute dd="". Will be filled later, eg on Opening event.
                {
                    dd.Items.Add(new ToolStripSeparator()); //else no drop arrow and no Opening event
                    return;
                }
#if !LAZY_MENUS
                dd.SuspendLayout();                 //with this don't need lazy menus
                _AddChildItems(x, dd, true);
                dd.ResumeLayout(false);
#else
                //Fill menu items later. This saves ~50 ms of startup time if not using dd.SuspendLayout. With dd.SuspendLayout - just 5 ms.
                //Can do it with Opening event or with timer. With timer easier. With event users cannot use MSAA etc to automate clicking menu items (with timer cannot use it only the first 1-2 seconds).
#if true
                ATimer.After(500, t =>
                {
                    dd.SuspendLayout();
                    _AddChildItems(x, dd, true);
                    dd.ResumeLayout(false);
                });
#else
                dd.Items.Add(new ToolStripSeparator());
                CancelEventHandler eh = null;
                eh = (sender, e) =>
                {
                    dd.Opening -= eh;
                    dd.Items.Clear();
                    _AddChildItems(x, dd, true);
                };
                dd.Opening += eh;
#endif
#endif
            }
        }

        void _SetItemProperties(XElement x, ToolStripItem item, bool isMenu, bool isControl)
        {
            string s, defaultText = null;

            var tt = x.Attr("tt");             //tooltip

            item.ToolTipText = tt ?? (isMenu ? null : (defaultText = _GetDefaultItemText(x)));

            if (!isMenu)
            {
                if (x.HasAttr("hide"))
                {
                    item.Overflow = ToolStripItemOverflow.Always;
                }
                else if (!_inBuildAll)
                {
                    item.Overflow = ToolStripItemOverflow.AsNeeded;
                }
            }
            if (isControl)
            {
                return;
            }

            Image im = null;

            if (x.Attr(out s, "i2"))              //custom image as icon file
            {
                im = AIcon.GetFileIconImage(s);
                if (im == null)
                {
                    AOutput.Write($"Failed to get {(isMenu ? "menu item" : "toolbar button")} {x.Name} icon from file {s}\n\tTo fix this, right-click it and select Properties...");
                }
                //SHOULDDO: async or cache
            }
            if (im == null && x.Attr(out s, "i"))
            {
                im = _callbacks.GetImage(s);                                              //image from resources
            }
            item.Image = im;

            if (x.Attr(out s, "color") && ColorInt.FromString(s, out var color))
            {
                item.ForeColor = (Color)color;
            }
            else if (!_inBuildAll)
            {
                item.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
            }

            bool hasCustomText = x.Attr(out s, "t2");             //custom text

            item.Text = s ?? defaultText ?? _GetDefaultItemText(x);

            if (isMenu)
            {
                var mi = item as ToolStripMenuItem;
                if (!_inBuildAll)
                {
                    mi.ShortcutKeys             = 0;
                    mi.ShortcutKeyDisplayString = null;
                }
                if (x.Attr(out s, "hk"))
                {
                    bool ok = AKeys.More.ParseHotkeyString(s, out var hk);
                    if (ok)
                    {
                        try { mi.ShortcutKeys = hk; } catch { ok = false; }
                    }
                    if (!ok)
                    {
                        ADebug.Print("Invalid hotkey: " + s);
                    }
                }
                if (x.Attr(out string ss, "hkText"))
                {
                    mi.ShortcutKeyDisplayString = (s == null) ? ss : s + ", " + ss;
                }
            }
            else
            {
                var style = item.Image == null ? ToolStripItemDisplayStyle.ImageAndText : (ToolStripItemDisplayStyle)x.Attr("style", 0);
                if (style == 0)
                {
                    style = hasCustomText ? ToolStripItemDisplayStyle.ImageAndText : ToolStripItemDisplayStyle.Image;                            //0 is ToolStripItemDisplayStyle.None
                }
                item.DisplayStyle = style;
            }
        }

        /// <summary>
        /// If x has attribute t, gets its value.
        /// Else gets its name and converts to text, eg "File_OneTwo" to "One Two".
        /// </summary>
        string _GetDefaultItemText(XElement x)
        {
            if (!x.Attr(out string s, "t"))
            {
                string tag = x.Name.LocalName;
                s = tag.Remove(0, tag.LastIndexOf('_') + 1);                 //eg "Edit_Copy" -> "Copy"
                s = s.RegexReplace("(?<=[^A-Z])(?=[A-Z])", " ");             //"OneTwoThree" -> "One Two Three". //speed: don't need to optimize.
            }
            return(s);
        }

        /// <summary>
        /// Merges custom attributes into default menubar or toolbar XML.
        /// Reorders toolbar buttons if need.
        /// </summary>
        /// <param name="xCustom">Root element of customizations file.</param>
        /// <param name="xtsDef">Default menustrip or toolstrip. For custom toolbars the function can replace it.</param>
        /// <param name="name">xtsDef name, just to avoid getting it again.</param>
        /// <param name="isMenu"></param>
        void _MergeCustom(XElement xCustom, ref XElement xtsDef, string name, bool isMenu)
        {
            var xtsCust = xCustom.Element(xtsDef.Name); if (xtsCust == null)

            {
                return;
            }

            if (isMenu)
            {
            }
            else if (name.Starts("Custom"))
            {
                var xc = xCustom.Element(name); if (xc == null)
                {
                    return;
                }
                xc.Remove();
                xtsDef.ReplaceWith(xc);
                xtsDef = xc;
                return;
                //MSDN: "if the new content has no parent, then the objects are simply attached to the XML tree. If the new content already is parented and is part of another XML tree, then the new content is cloned". Tested, it's true.
            }
            else
            {
                //reorder toolbar buttons
                if (xtsCust.Attr(out string s, "order"))
                {
                    xtsDef.Elements("sep").Remove();                     //remove all default <sep/>, because all separators now are in the 'order' attribute
                    var a = s.SegSplit(" ");
                    for (int i = a.Length - 1; i >= 0; i--)
                    {
                        if (a[i] == "sep")
                        {
                            xtsDef.AddFirst(new XElement("sep"));
                        }
                        else
                        {
                            var xb = xtsDef.Element(a[i]); if (xb == null)
                            {
                                continue;
                            }
                            xb.Remove(); xtsDef.AddFirst(xb);
                        }
                    }
                }
            }

            foreach (var xCust in xtsCust.Elements())
            {
                foreach (var xDef in xtsDef.Descendants(xCust.Name))
                {
                    foreach (var att in xCust.Attributes())
                    {
                        xDef.SetAttributeValue(att.Name, att.Value);
                    }
                }
            }
        }

        /// <summary>
        /// Extracts differences between _xmlFileDefault and _xStrips and saves to _xmlFileCustom.
        /// </summary>
        void _DiffCustom()
        {
            var    xStripsDefault = AExtXml.LoadElem(_xmlFileDefault);
            var    xStripsCustom  = new XElement("strips");
            string s;

            //menus
            _DiffDescendants(MenuBar.Tag as XElement, true);

            //standard toolbars
            foreach (var ts in Toolbars.Values)
            {
                if (ts == _tsCustom1 || ts == _tsCustom2)
                {
                    continue;
                }
                _DiffDescendants(ts.Tag as XElement, false);
            }

            void _DiffDescendants(XElement xts, bool isMenu)
            {
                XElement xtsDef = xStripsDefault.Element(xts.Name), xtsCust = null;

                foreach (var x in xts.Descendants())
                {
                    var name = x.Name; if (name == "sep")
                    {
                        continue;
                    }
                    XElement xDef = xtsDef.Desc(name), xCust = null;
                    foreach (var att in x.Attributes())
                    {
                        var aname = att.Name;
                        if (att.Value == xDef.Attr(aname))
                        {
                            continue;
                        }
                        if (xtsCust == null)
                        {
                            xStripsCustom.Add(xtsCust = new XElement(xts.Name));
                        }
                        if (xCust == null)
                        {
                            xtsCust.Add(xCust = new XElement(name));
                        }
                        xCust.SetAttributeValue(aname, att.Value);
                    }
                }
                if (isMenu)
                {
                    return;
                }
                //order
                var s1 = new StringBuilder();
                var s2 = new StringBuilder();

                foreach (var x in xts.Elements())
                {
                    if (s1.Length > 0)
                    {
                        s1.Append(' ');
                    }
                    s1.Append(x.Name);
                }
                foreach (var x in xtsDef.Elements())
                {
                    if (s2.Length > 0)
                    {
                        s2.Append(' ');
                    }
                    s2.Append(x.Name);
                }
                s = s1.ToString();
                if (s != s2.ToString())
                {
                    if (xtsCust == null)
                    {
                        xStripsCustom.Add(xtsCust = new XElement(xts.Name));
                    }
                    xtsCust.SetAttributeValue("order", s);
                }
            }

            //custom toolbars. Temporarily move them from _xStrips to xCustom.
            var xCust1 = _tsCustom1.Tag as XElement;
            var xCust2 = _tsCustom2.Tag as XElement;

            if (xCust1.HasElements)
            {
                xCust1.Remove(); xStripsCustom.Add(xCust1);
            }
            if (xCust2.HasElements)
            {
                xCust2.Remove(); xStripsCustom.Add(xCust2);
            }

            //AOutput.Clear();
            //AOutput.Write(xStripsCustom);
#if true
            //save
            try {
                AFile.CreateDirectoryFor(_xmlFileCustom);
                xStripsCustom.SaveElem(_xmlFileCustom);
            }
            catch (Exception e) {
                AOutput.Write("Failed to save XML file", _xmlFileCustom, e.Message);
            }
#endif

            if (xCust1.HasElements)
            {
                xCust1.Remove(); _xStrips.Add(xCust1);
            }
            if (xCust2.HasElements)
            {
                xCust2.Remove(); _xStrips.Add(xCust2);
            }
        }
Beispiel #22
0
        private void ToolStripSplitButton_ButtonClick(object sender, EventArgs e)
        {
            ToolStripSplitButton control = (ToolStripSplitButton)sender;

            control.ShowDropDown();
        }
Beispiel #23
0
        public void loadpck(string active, string role, DevExpress.XtraGrid.GridControl gridControl1, GridView gridView1, TextEdit txtsct, LookUpEdit ledvn, LookUpEdit ledv, DateEdit denct, DateEdit denht,
                            DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit mahang, DevExpress.XtraEditors.Repository.RepositoryItemTextEdit soluong, DevExpress.XtraEditors.Repository.RepositoryItemTextEdit soluongqd, Frm_chuyenkhonb F, LookUpEdit ledt, TextEdit txtldn,
                            ToolStripButton tsbtsua, ToolStripButton tsbtxoa, ToolStripButton tsbtcat, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtnap, ToolStripButton tsbtin, string ngaychungtu, string userid, string branchid, TextEdit txtngh, TextEdit txtptvc, DevExpress.XtraEditors.Repository.RepositoryItemTextEdit dongia, DevExpress.XtraEditors.Repository.RepositoryItemTextEdit thanhtien, TextEdit txtpnv, TextEdit txtcth, DevExpress.XtraEditors.Repository.RepositoryItemTextEdit chiphi, TextEdit txtnhd, TextEdit txtms, TextEdit txtkhhd, TextEdit txtshd, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, string tsbt, DataTable khach, DataTable hang, CheckEdit nhan)
        {
            DataTable dt = new DataTable();

            loadstart(gridControl1, gridView1, ledvn, ledv, ledt, denct, denht, mahang, soluong, soluongqd, tsbtsua, tsbtxoa, tsbtcat, tsbtboghi, tsbtghiso, tsbtnap, tsbtin, ngaychungtu, userid, branchid, active, dt, dongia, thanhtien, chiphi, txtnhd, khach, hang);
            if (active == "1")
            {
                DataTable da = new DataTable();
                da = gen.GetTable("select  InventoryItemCode,Quantity,Description,InventoryItemName,a.UnitPrice,a.Amount from INTransferBranchSUDetail a,InventoryItem b where a.InventoryItemID=b.InventoryItemID and RefID='" + role + "' order by SortOrder");
                for (int i = 0; i < da.Rows.Count; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr[0] = da.Rows[i][0].ToString();
                    dr[1] = da.Rows[i][3].ToString();
                    dr[2] = da.Rows[i][1].ToString();
                    dr[3] = da.Rows[i][4].ToString();
                    dr[4] = da.Rows[i][5].ToString();
                    dr[5] = da.Rows[i][2].ToString();
                    dt.Rows.Add(dr);
                }
                gridControl1.DataSource = dt;

                tsbtcat.Enabled = false;

                F.Text = "Xem phiếu xuất hàng gửi bán vỏ LPG";

                da = gen.GetTable("select AccountingObjectCode,a.Contactname,JournalMemo,InvSeries,RefDate,PostedDate,RefNo,OutwardStockID,Posted,InvNo,Cancel,ShippingNo,RefNoIn,InwardStockID,No,InvDate,PostVersion  from INTransferBranchSU a, AccountingObject b where a.AccountingObjectID=b.AccountingObjectID  and RefID='" + role + "'");

                string kho  = gen.GetString("select StockCode from Stock where StockID='" + da.Rows[0][7].ToString() + "'");
                string khon = gen.GetString("select StockCode from Stock where StockID='" + da.Rows[0][13].ToString() + "'");
                ledvn.EditValue = khon;
                ledv.EditValue  = kho;
                ledt.EditValue  = da.Rows[0][0].ToString();
                txtldn.Text     = da.Rows[0][2].ToString();

                txtshd.Text      = da.Rows[0][9].ToString();
                txtkhhd.Text     = da.Rows[0][3].ToString();
                txtms.Text       = da.Rows[0][14].ToString();
                txtnhd.EditValue = DateTime.Parse(da.Rows[0][15].ToString());

                denct.EditValue = DateTime.Parse(da.Rows[0][4].ToString());
                denht.EditValue = DateTime.Parse(da.Rows[0][5].ToString());
                txtsct.Text     = da.Rows[0][6].ToString();
                txtpnv.Text     = da.Rows[0][12].ToString();
                txtngh.Text     = da.Rows[0][1].ToString();
                txtptvc.Text    = da.Rows[0][11].ToString();
                if (da.Rows[0][8].ToString() == "True")
                {
                    tsbtghiso.Visible = false;
                    tsbtboghi.Visible = true;
                    tsbtsua.Enabled   = false;
                    nhan.Enabled      = false;
                }
                else
                {
                    tsbtboghi.Visible = false;
                    tsbtghiso.Visible = true;
                }
                if (da.Rows[0][10].ToString() == "True")
                {
                    tsbtboghi.Enabled = false;
                    tsbtghiso.Enabled = false;
                }

                if (da.Rows[0][16].ToString() == "1")
                {
                    nhan.Checked = true;
                }
                else
                {
                    nhan.Checked = false;
                }

                Double tongthanhtien = Double.Parse(gridView1.Columns["Thành tiền"].SummaryText);
                txtcth.Text = String.Format("{0:n0}", tongthanhtien);
                if (tsbt == "tsbtpnhgbvlpg")
                {
                    checktruocsaunhap(tsbttruoc, tsbtsau, ledvn.EditValue.ToString(), txtpnv.Text, ngaychungtu);
                }
                else
                {
                    checktruocsau(tsbttruoc, tsbtsau, ledv.EditValue.ToString(), txtsct.Text, ngaychungtu);
                }
            }
            else
            {
                F.Text = "Thêm phiếu xuất hàng gửi bán vỏ LPG";
                if (role == null)
                {
                    ledv.ItemIndex = 0;
                }
                else
                {
                    ledv.EditValue = role;
                }
                denht.EditValue  = DateTime.Parse(ngaychungtu);
                txtnhd.EditValue = DateTime.Parse(ngaychungtu);
                denct.EditValue  = DateTime.Parse(ngaychungtu);
                nhan.Checked     = false;
            }
        }
Beispiel #24
0
        public static void SetSubControl(Control tb, string oldtitle, string newtitle)
        {
            switch (tb.GetType().ToString())
            {
            case "System.Windows.Forms.TextBox":
                ((TextBox)tb).ShortcutsEnabled = true;
                break;

            case "System.Windows.Forms.ComboBox":
                break;

            case "System.Windows.Forms.MenuStrip":
                MenuStrip ms = (MenuStrip)tb;
                for (int k = 0; k < ms.Items.Count; k++)
                {
                    ToolStripMenuItem menuitem = (ToolStripMenuItem)ms.Items[k];
                    if (menuitem.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                    {
                        menuitem.Text = newtitle;
                        break;
                    }
                    else
                    {
                        SetSubMenu((ToolStripMenuItem)ms.Items[k], oldtitle, newtitle);
                    }
                }
                break;

            case "LXMS.ToolStripEx":
            case "System.Windows.Forms.ToolStrip":
                ToolStrip ts = (ToolStrip)tb;
                for (int k = 0; k < ts.Items.Count; k++)
                {
                    ToolStripItem toolitem = (ToolStripItem)ts.Items[k];
                    if (toolitem.GetType().ToString() != "System.Windows.Forms.ToolStripSeparator")
                    {
                        if (toolitem.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                        {
                            toolitem.Text = newtitle;
                            break;
                        }
                        else if (toolitem.GetType().ToString() == "System.Windows.Forms.ToolStripDropDownButton")
                        {
                            ToolStripDropDownButton tsb = (ToolStripDropDownButton)toolitem;
                            for (int m = 0; m < tsb.DropDownItems.Count; m++)
                            {
                                if (tsb.DropDownItems[m].GetType().ToString() == "System.Windows.Forms.ToolStripControlHost")
                                {
                                    continue;
                                }
                                ToolStripDropDownItem tsbitem = (ToolStripDropDownItem)tsb.DropDownItems[m];
                                if (tsbitem.GetType().ToString() != "System.Windows.Forms.ToolStripSeparator")
                                {
                                    if (tsbitem.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                                    {
                                        tsbitem.Text = newtitle;
                                        break;
                                    }
                                }
                            }
                        }
                        else if (toolitem.GetType().ToString() == "System.Windows.Forms.ToolStripSplitButton")
                        {
                            ToolStripSplitButton tsb = (ToolStripSplitButton)toolitem;
                            for (int m = 0; m < tsb.DropDownItems.Count; m++)
                            {
                                ToolStripMenuItem tsbitem = (ToolStripMenuItem)tsb.DropDownItems[m];
                                if (tsbitem.GetType().ToString() != "System.Windows.Forms.ToolStripSeparator")
                                {
                                    if (tsbitem.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                                    {
                                        tsbitem.Text = newtitle;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                break;

            case "LXMS.TabControlEx":
            case "System.Windows.Forms.TabControl":
                TabControl tc = (TabControl)tb;
                foreach (TabPage tp in tc.Controls)
                {
                    if (tp.Text.ToLower() == oldtitle)
                    {
                        tp.Text = newtitle;
                        //break;
                    }
                    foreach (Control ct in tp.Controls)
                    {
                        SetSubControl(ct, oldtitle, newtitle);
                    }
                }
                break;

            case "System.Windows.Forms.SplitContainer":
                SplitContainer sc = (SplitContainer)tb;
                SetSubControl(sc.Panel1, oldtitle, newtitle);
                SetSubControl(sc.Panel2, oldtitle, newtitle);
                break;

            default:
                if (!string.IsNullOrEmpty(tb.Text) && tb.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                {
                    tb.Text = newtitle;
                }
                if (tb.Controls.Count > 0)
                {
                    foreach (Control ch in tb.Controls)
                    {
                        SetSubControl(ch, oldtitle, newtitle);
                    }
                }
                break;
            }

            System.Reflection.FieldInfo[] fieldInfo = tb.GetType().GetFields(System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            for (int m = 0; m < fieldInfo.Length; m++)
            {
                switch (fieldInfo[m].FieldType.Name)
                {
                case "ContextMenuStrip":
                    ContextMenuStrip cms = (ContextMenuStrip)fieldInfo[m].GetValue(tb);
                    for (int k = 0; k < cms.Items.Count; k++)
                    {
                        if (cms.Items[k].GetType().ToString() == "System.Windows.Forms.ToolStripMenuItem")
                        {
                            ToolStripMenuItem menuitem = (ToolStripMenuItem)cms.Items[k];
                            if (menuitem.Text.Trim().ToLower().CompareTo(oldtitle) == 0)
                            {
                                menuitem.Text = newtitle;
                                break;
                            }
                            else
                            {
                                SetSubMenu((ToolStripMenuItem)cms.Items[k], oldtitle, newtitle);
                            }
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
Beispiel #25
0
        public void checkpck(string active, string role, Frm_chuyenkhonb F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, LookUpEdit ledvn, TextEdit txtsct, TextEdit txtname, TextEdit txtngh, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                             ToolStripButton tsbtcat, ToolStripButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, TextEdit txtptvc, string userid, string branchid, TextEdit txtpnv, TextEdit txtms, TextEdit txtkhhd, TextEdit txtshd, TextEdit txtnhd, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, string bat)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[20, 8];
                string check = "0";
                for (int i = 0; i < gridView1.RowCount - 1; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'");
                        detail[i, 0] = mh;
                    }
                    if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "")
                    {
                        detail[i, 1] = "0";
                    }
                    else
                    {
                        detail[i, 1] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    }
                    detail[i, 2] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "");
                    if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "")
                    {
                        detail[i, 4] = "0";
                    }
                    else
                    {
                        detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", ".");
                    }
                    if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "")
                    {
                        detail[i, 5] = "0";
                    }
                    else
                    {
                        detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", "");
                    }
                    detail[i, 3] = gridView1.GetRowCellValue(i, "Diễn giải").ToString();
                }

                if (check == "1")
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Mã hàng> <Số lượng quy đổi> <Đơn giá> <Thành tiền> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string dv       = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                    string dvn      = gen.GetString("select * from Stock where StockCode='" + ledvn.EditValue.ToString() + "'");
                    string tongtien = gridView1.Columns["Thành tiền"].SummaryText.Replace(".", "");
                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from INTransferBranchSU where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), tsbttruoc, tsbtsau);
                            XtraMessageBox.Show("Số phiếu trùng, hệ thống tự động chỉnh số phiếu của bạn thành " + txtsct.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch { }

                        try
                        {
                            string ton = gen.GetString("select * from INTransferBranchSU where RefNoIn='" + txtpnv.Text + "'");
                            themsctn(ngaychungtu, txtpnv, ledvn.EditValue.ToString());
                            XtraMessageBox.Show("Số phiếu trùng, hệ thống tự động chỉnh số phiếu của bạn thành " + txtsct.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch { }

                        gen.ExcuteNonquery("insert into INTransferBranchSU(RefID,RefType,RefDate,PostedDate,RefNo,RefNoIn,AccountingObjectID,AccountingObjectName,Contactname,JournalMemo,Posted,OutwardStockID,InwardStockID,ShippingNo,TotalAmount,No,InvSeries,InvNo,InvDate) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + txtpnv.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtngh.Text + "',N'" + txtldn.Text + "','False','" + dv + "','" + dvn + "','" + txtptvc.Text + "','" + tongtien + "','" + txtms.Text + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + txtnhd.EditValue.ToString() + "')");
                        string refid = gen.GetString("select * from INTransferBranchSU where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        if (DateTime.Parse(ngaychungtu) < DateTime.Parse("09/01/2017"))
                        {
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtsct.Text + "','336','1563','" + tongtien + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtpnv.Text + "','1563','336','" + tongtien + "','" + dt + "','" + dvn + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                        }
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into INTransferBranchSUDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,UnitPrice,Amount) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "','" + detail[i, 4] + "','" + detail[i, 5] + "')");
                        }
                    }
                    else
                    {
                        if (bat == "1")
                        {
                            try
                            {
                                string ton = gen.GetString("select * from INTransferBranchSU where RefNoIn='" + txtpnv.Text + "'");
                                themsctn(ngaychungtu, txtpnv, ledvn.EditValue.ToString());
                                XtraMessageBox.Show("Số phiếu trùng, hệ thống tự động chỉnh số phiếu của bạn thành " + txtsct.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            catch { }
                        }
                        gen.ExcuteNonquery("update INTransferBranchSU set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',Contactname=N'" + txtngh.Text + "',JournalMemo=N'" + txtldn.Text + "',RefNoIn='" + txtpnv.Text + "',InwardStockID='" + dvn + "',Posted='False',ShippingNo='" + txtptvc.Text + "',TotalAmount='" + tongtien + "',No='" + txtms.Text + "',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',InvDate='" + txtnhd.EditValue.ToString() + "'  where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete  from  INTransferBranchSUDetail where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'");
                        if (DateTime.Parse(ngaychungtu) < DateTime.Parse("09/01/2017"))
                        {
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtsct.Text + "','336','1563','" + tongtien + "','" + dt + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtpnv.Text + "','1563','336','" + tongtien + "','" + dt + "','" + dvn + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')");
                        }
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            gen.ExcuteNonquery("insert into INTransferBranchSUDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,Description,UnitPrice,Amount) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "',N'" + detail[i, 3] + "','" + detail[i, 4] + "','" + detail[i, 5] + "')");
                        }
                    }
                    F.myac();
                    F.getactive("1");
                    F.Text = "Xem phiếu xuất hàng gửi bán vỏ LPG";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #26
0
//save//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void checkpkt(string active, string role, Frm_phieuthu F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, ComboBoxEdit cbldt, TextEdit txtsct, TextEdit txtname, TextEdit txtdc,
                             TextEdit txtnn, TextEdit txtctg, TextEdit txtldn, DateEdit denct, DateEdit denht, ToolStripButton tsbtboghi, ToolStripButton tsbtghiso, ToolStripButton tsbtxoa,
                             ToolStripButton tsbtcat, ToolStripButton tsbtin, ToolStripButton tsbtsua, ToolStripButton tsbtnap, string ngaychungtu, ComboBoxEdit cbthue, TextEdit txthtt, string userid, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, ToolStripButton tsbtkc, SearchLookUpEdit danhmuc)
        {
            try
            {
                string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'");
                string[,] detail = new string[100, 11];
                string check = "0";
                for (int i = 0; i < gridView1.RowCount - 1; i++)
                {
                    if (gridView1.GetRowCellValue(i, "Tài khoản có").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 0] = gridView1.GetRowCellValue(i, "Tài khoản có").ToString();
                    if (gridView1.GetRowCellValue(i, "Tài khoản nợ").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 1] = gridView1.GetRowCellValue(i, "Tài khoản nợ").ToString();

                    detail[i, 2] = "NULL";
                    if (gridView1.GetRowCellValue(i, "Ngày phát hành HĐ").ToString() != "")
                    {
                        detail[i, 2] = "'" + gridView1.GetRowCellValue(i, "Ngày phát hành HĐ").ToString() + "'";
                    }

                    detail[i, 3] = gridView1.GetRowCellValue(i, "Loại hóa đơn").ToString();
                    detail[i, 4] = gridView1.GetRowCellValue(i, "Số hóa đơn").ToString();
                    if (gridView1.GetRowCellValue(i, "Số tiền").ToString() == "")
                    {
                        check = "1";
                    }
                    detail[i, 5] = gridView1.GetRowCellValue(i, "Số tiền").ToString().Replace(".", "");

                    if (gridView1.GetRowCellValue(i, "Mã khách").ToString() == "")
                    {
                        check = "1";
                    }
                    else
                    {
                        string mk = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + gridView1.GetRowCellValue(i, "Mã khách").ToString() + "'");
                        detail[i, 6] = mk;
                    }
                    detail[i, 7] = gridView1.GetRowCellValue(i, "Diễn giải").ToString();
                    detail[i, 8] = gridView1.GetRowCellValue(i, "Ký hiệu hóa đơn").ToString();
                    detail[i, 9] = gridView1.GetRowCellValue(i, "Nhóm chi phí").ToString();
                }
                if (check == "1")
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Tài khoản có> <Tài khoản nợ> <Số tiền> <Mã Khách> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string dv   = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'");
                    string tong = gridView1.Columns["Số tiền"].SummaryText;
                    tong = tong.Replace("Tổng tiền =", "").Trim();
                    tong = tong.Replace(".", "");

                    string ldt;
                    if (cbldt.EditValue.ToString() == "Khách hàng")
                    {
                        ldt = "0";
                    }
                    else if (cbldt.EditValue.ToString() == "Nhà cung cấp")
                    {
                        ldt = "1";
                    }
                    else
                    {
                        ldt = "2";
                    }
                    if (active == "0")
                    {
                        try
                        {
                            string ton = gen.GetString("select * from GLVoucher where RefNo='" + txtsct.Text + "'");
                            themsct(ngaychungtu, txtsct, tsbttruoc, tsbtsau, userid);
                            XtraMessageBox.Show("Số phiếu trùng, hệ thống tự động chỉnh số phiếu của bạn thành " + txtsct.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch {}
                        if (txthtt.Text == "")
                        {
                            gen.ExcuteNonquery("insert into GLVoucher(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,TotalAmount,Tax,UserID,PostVersion) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "','" + txtdc.Text + "',N'" + txtnn.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + tong + "','" + cbthue.Text + "','" + userid + "','" + danhmuc.EditValue.ToString() + "')");
                        }
                        else
                        {
                            gen.ExcuteNonquery("insert into GLVoucher(RefID,RefType,RefDate,PostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,Contactname,JournalMemo,DocumentIncluded,Posted,StockID,AccountingObjectType,TotalAmount,Tax,ExDate,UserID,PostVersion) values(newid(),101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "','" + txtdc.Text + "',N'" + txtnn.Text + "',N'" + txtldn.Text + "',N'" + txtctg.Text + "','False','" + dv + "','" + ldt + "','" + tong + "','" + cbthue.Text + "'," + txthtt.Text + ",'" + userid + "','" + danhmuc.EditValue.ToString() + "')");
                        }
                        string refid = gen.GetString("select * from GLVoucher where RefNo='" + txtsct.Text + "'");
                        F.getrole(refid);
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            /*if (detail[i, 2] == "")
                             * {
                             *
                             *  gen.ExcuteNonquery("insert into GLVoucherDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,SortOrder,CustomField5) values(newid(),'" + refid + "',N'" + detail[i, 7] + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "'," + i + ",'" + detail[i, 8] + "')");
                             * }
                             * else
                             * {*/
                            gen.ExcuteNonquery("insert into GLVoucherDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,InvDate,InvSeries,InvNo,SortOrder,CustomField5,CustomField4) values(newid(),'" + refid + "',N'" + detail[i, 7] + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "'," + detail[i, 2] + ",'" + detail[i, 3] + "','" + detail[i, 4] + "'," + i + ",'" + detail[i, 8] + "',N'" + detail[i, 9] + "')");
                            //}
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,CABA,ExDate,Occupation,GroupCost) values(newid(),'" + refid + "','" + txtsct.Text + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + denct.EditValue.ToString() + "'," + txthtt.Text + ",'" + detail[i, 7] + "',N'" + detail[i, 9] + "')");
                        }
                    }
                    else
                    {
                        if (txthtt.Text == "")
                        {
                            gen.ExcuteNonquery("update GLVoucher set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress='" + txtdc.Text + "',Contactname=N'" + txtnn.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',TotalAmount='" + tong + "',Posted='False',Tax='" + cbthue.Text + "',ExDate = Null,UserID='" + userid + "',PostVersion='" + danhmuc.EditValue.ToString() + "'  where RefID='" + role + "'");
                        }
                        else
                        {
                            gen.ExcuteNonquery("update GLVoucher set RefDate='" + denct.EditValue.ToString() + "',PostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "',AccountingObjectAddress='" + txtdc.Text + "',Contactname=N'" + txtnn.Text + "',JournalMemo=N'" + txtldn.Text + "',DocumentIncluded=N'" + txtctg.Text + "',StockID='" + dv + "',AccountingObjectType='" + ldt + "',TotalAmount='" + tong + "',Posted='False',Tax='" + cbthue.Text + "',ExDate = " + txthtt.Text + ",UserID='" + userid + "',PostVersion='" + danhmuc.EditValue.ToString() + "'  where RefID='" + role + "'");
                        }
                        gen.ExcuteNonquery("delete  from  GLVoucherDetail where RefID='" + role + "'");
                        gen.ExcuteNonquery("insert into HACHTOANBK select *,GetDate() from HACHTOAN where RefID='" + role + "'");
                        gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'");
                        for (int i = 0; i < gridView1.RowCount - 1; i++)
                        {
                            /*if (detail[i, 2] == "")
                             * {
                             *  gen.ExcuteNonquery("insert into GLVoucherDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,SortOrder,CustomField5) values(newid(),'" + role + "',N'" + detail[i, 7] + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "'," + i + ",'" + detail[i, 8] + "')");
                             * }
                             * else
                             * {*/
                            gen.ExcuteNonquery("insert into GLVoucherDetail(RefDetailID,RefID,Description,DebitAccount,CreditAccount,Amount,AccountingObjectID,InvDate,InvSeries,InvNo,SortOrder,CustomField5,CustomField4) values(newid(),'" + role + "',N'" + detail[i, 7] + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "'," + detail[i, 2] + ",'" + detail[i, 3] + "','" + detail[i, 4] + "'," + i + ",'" + detail[i, 8] + "',N'" + detail[i, 9] + "')");
                            //}
                            gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain,CABA,ExDate,Occupation,GroupCost) values(newid(),'" + role + "','" + txtsct.Text + "','" + detail[i, 1] + "','" + detail[i, 0] + "','" + detail[i, 5] + "','" + detail[i, 6] + "','" + dv + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "','" + denct.EditValue.ToString() + "'," + txthtt.Text + ",'" + detail[i, 7] + "',N'" + detail[i, 9] + "')");
                        }
                    }
                    F.myac();
                    F.getactive("1");
                    F.Text = "Xem phiếu kế toán";
                }
            }
            catch
            {
                XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #27
0
        /*public void themsct(string ngaychungtu, TextEdit txtsct, string ledv, string ledvn, TextEdit txtpnv, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau)
         * {
         *  DataTable da = new DataTable();
         *  int dai = 5;
         *  string idkho = gen.GetString("select * from Stock where StockCode='" + ledv + "'");
         *  string idkhon = gen.GetString("select * from Stock where StockCode='" + ledvn + "'");
         *  string dv = gen.GetString("select BranchCode from Branch a, Stock b where a.BranchID=b.BranchID and b.StockCode='" + ledv + "'");
         *  string dvn = gen.GetString("select BranchCode from Branch a, Stock b where a.BranchID=b.BranchID and b.StockCode='" + ledvn + "'");
         *  string thang = DateTime.Parse(ngaychungtu).Month.ToString();
         *  if (thang.Length < 2) thang = "0" + thang;
         *  string year = DateTime.Parse(ngaychungtu).Year.ToString();
         *  string nam = "-" + thang + "-" + year.Substring(2, 2);
         *  string sophieu = dv + "-" + ledv + "-XHVT";
         *  string sophieuvo = dvn + "-" + ledvn + "-NHVT";
         *      try
         *      {
         *          string id = gen.GetString("select Top 1 RefNo from INTransferBranchSU where Month(RefDate)='" + DateTime.Parse(ngaychungtu).Month.ToString() + "' and Year(RefDate)='" + DateTime.Parse(ngaychungtu).Year.ToString() + "' and OutwardStockID='" + idkho + "'  order by RefNo DESC");
         *          int ct = Int32.Parse(id.Substring(10, dai)) + 1;
         *          for (int i = 0; i < dai - ct.ToString().Length; i++)
         *          {
         *              sophieu = sophieu + "0";
         *          }
         *          sophieu = sophieu + ct.ToString() + nam;
         *      }
         *      catch { sophieu = sophieu + "00001" + nam; }
         *
         *      try
         *      {
         *          string id = gen.GetString("select Top 1 RefNoIn from INTransferBranchSU where Month(RefDate)='" + DateTime.Parse(ngaychungtu).Month.ToString() + "' and Year(RefDate)='" + DateTime.Parse(ngaychungtu).Year.ToString() + "' and InwardStockID='" + idkhon + "'  order by RefNoIn DESC");
         *          int ct = Int32.Parse(id.Substring(10, dai)) + 1;
         *          for (int i = 0; i < dai - ct.ToString().Length; i++)
         *          {
         *              sophieuvo = sophieuvo + "0";
         *          }
         *          sophieuvo = sophieuvo + ct.ToString() + nam;
         *      }
         *      catch { sophieuvo = sophieuvo + "00001" + nam; }
         *
         *  txtsct.Text = sophieu;
         *  txtpnv.Text = sophieuvo;
         *  checktruocsau(tsbttruoc, tsbtsau, ledv, sophieu, ngaychungtu);
         * }*/

        public void themsct(string ngaychungtu, TextEdit txtsct, string ledv, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau)
        {
            DataTable da    = new DataTable();
            int       dai   = 5;
            string    idkho = gen.GetString("select * from Stock where StockCode='" + ledv + "'");
            string    dv    = gen.GetString("select BranchCode from Branch a, Stock b where a.BranchID=b.BranchID and b.StockCode='" + ledv + "'");
            string    thang = DateTime.Parse(ngaychungtu).Month.ToString();

            if (thang.Length < 2)
            {
                thang = "0" + thang;
            }
            string year    = DateTime.Parse(ngaychungtu).Year.ToString();
            string nam     = "-" + thang + "-" + year.Substring(2, 2);
            string sophieu = dv + "-" + ledv + "-XHVT";

            try
            {
                string id = gen.GetString("select Top 1 RefNo from INTransferBranchSU where Month(RefDate)='" + DateTime.Parse(ngaychungtu).Month.ToString() + "' and Year(RefDate)='" + DateTime.Parse(ngaychungtu).Year.ToString() + "' and OutwardStockID='" + idkho + "'  order by RefNo DESC");
                int    ct = Int32.Parse(id.Substring(10, dai)) + 1;
                for (int i = 0; i < dai - ct.ToString().Length; i++)
                {
                    sophieu = sophieu + "0";
                }
                sophieu = sophieu + ct.ToString() + nam;
            }
            catch { sophieu = sophieu + "00001" + nam; }

            txtsct.Text = sophieu;
            checktruocsau(tsbttruoc, tsbtsau, ledv, sophieu, ngaychungtu);
        }
Beispiel #28
0
        private ToolStrip BuildViewTabPageToolStripItems(ToolStrip toolStrip, string name)
        {
            ToolStripSplitButton toolStripSplitButtonEdit = new ToolStripSplitButton
            {
                Text        = "Edit",
                Alignment   = ToolStripItemAlignment.Left,
                AutoToolTip = false,
                Image       = Resources.edit
            };

            ToolStripButton toolStripButtonEmail = new ToolStripButton
            {
                Text        = "Email",
                Alignment   = ToolStripItemAlignment.Left,
                AutoToolTip = false,
                Image       = Resources.email
            };

            toolStripButtonEmail.Click += new EventHandler(emailScreenshot_Click);

            // Check to see if Email (SMTP) is configured.
            string host = Settings.Application.GetByKey("EmailServerHost", DefaultSettings.EmailServerHost).Value.ToString();

            string username = Settings.Application.GetByKey("EmailClientUsername", DefaultSettings.EmailClientUsername).Value.ToString();
            string password = Settings.Application.GetByKey("EmailClientPassword", DefaultSettings.EmailClientPassword).Value.ToString();

            string from = Settings.Application.GetByKey("EmailMessageFrom", DefaultSettings.EmailMessageFrom).Value.ToString();
            string to   = Settings.Application.GetByKey("EmailMessageTo", DefaultSettings.EmailMessageTo).Value.ToString();

            if (string.IsNullOrEmpty(host) ||
                string.IsNullOrEmpty(username) ||
                string.IsNullOrEmpty(password) ||
                string.IsNullOrEmpty(@from) ||
                string.IsNullOrEmpty(to))
            {
                toolStripButtonEmail.ToolTipText = "SMTP settings have not been configured for " + Settings.ApplicationName + " to email screenshots";
                toolStripButtonEmail.Enabled     = false;
            }
            else
            {
                toolStripButtonEmail.ToolTipText = "Email this screenshot using the configured SMTP settings";
                toolStripButtonEmail.Enabled     = true;
            }

            toolStripSplitButtonEdit.DropDown.Items.Add("Add New Editor ...", null, addEditor_Click);

            foreach (Editor editor in _formEditor.EditorCollection)
            {
                if (editor != null && FileSystem.FileExists(editor.Application))
                {
                    toolStripSplitButtonEdit.DropDown.Items.Add(editor.Name, Icon.ExtractAssociatedIcon(editor.Application).ToBitmap(), runEditor_Click);
                }
            }

            ToolStripSplitButton toolStripSplitButtonConfigure = new ToolStripSplitButton
            {
                Text        = "Configure",
                Alignment   = ToolStripItemAlignment.Right,
                AutoToolTip = false,
                Image       = Resources.configure
            };

            toolStripSplitButtonConfigure.DropDown.Items.Add("Add New Screen", null, addScreen_Click);
            toolStripSplitButtonConfigure.DropDown.Items.Add("Add New Region", null, addRegion_Click);

            toolStripSplitButtonConfigure.DropDown.Items.Add(new ToolStripSeparator());

            if (toolStrip.Tag is Screen)
            {
                ToolStripMenuItem toolStripMenuItemChangeScreen = new ToolStripMenuItem
                {
                    Text = "Change Screen",
                    Tag  = toolStrip.Tag
                };

                toolStripMenuItemChangeScreen.Click += new EventHandler(changeScreen_Click);

                toolStripSplitButtonConfigure.DropDown.Items.Add(toolStripMenuItemChangeScreen);

                ToolStripMenuItem toolStripMenuItemRemoveScreen = new ToolStripMenuItem
                {
                    Text = "Remove Screen",
                    Tag  = toolStrip.Tag
                };

                toolStripMenuItemRemoveScreen.Click += new EventHandler(removeScreen_Click);

                toolStripSplitButtonConfigure.DropDown.Items.Add(toolStripMenuItemRemoveScreen);
            }

            if (toolStrip.Tag is Region)
            {
                ToolStripMenuItem toolStripMenuItemRegion = new ToolStripMenuItem
                {
                    Text = "Change Region",
                    Tag  = toolStrip.Tag
                };

                toolStripMenuItemRegion.Click += new EventHandler(changeRegion_Click);

                toolStripSplitButtonConfigure.DropDown.Items.Add(toolStripMenuItemRegion);

                ToolStripMenuItem toolStripMenuItemRemoveRegion = new ToolStripMenuItem
                {
                    Text = "Remove Region",
                    Tag  = toolStrip.Tag
                };

                toolStripMenuItemRemoveRegion.Click += new EventHandler(removeRegion_Click);

                toolStripSplitButtonConfigure.DropDown.Items.Add(toolStripMenuItemRemoveRegion);
            }

            ToolStripItem toolStripLabelFilename = new ToolStripLabel
            {
                Text      = "Filename:",
                Alignment = ToolStripItemAlignment.Right,
                Anchor    = AnchorStyles.Top | AnchorStyles.Left
            };

            ToolStripItem toolstripTextBoxFilename = new ToolStripTextBox
            {
                Name      = name + "toolStripTextBoxFilename",
                Alignment = ToolStripItemAlignment.Right,
                AutoSize  = false,
                ReadOnly  = true,
                Width     = 200,
                BackColor = Color.LightYellow,
                Text      = string.Empty
            };

            ToolStripItem toolstripButtonOpenFolder = new ToolStripButton
            {
                Image        = Resources.openfolder,
                Alignment    = ToolStripItemAlignment.Right,
                AutoToolTip  = false,
                ToolTipText  = "Show Screenshot Location",
                DisplayStyle = ToolStripItemDisplayStyle.Image
            };

            toolstripButtonOpenFolder.Click += new EventHandler(showScreenshotLocation_Click);

            toolStrip.Items.Add(toolStripSplitButtonEdit);
            toolStrip.Items.Add(toolStripButtonEmail);
            toolStrip.Items.Add(toolStripSplitButtonConfigure);
            toolStrip.Items.Add(new ToolStripSeparator {
                Alignment = ToolStripItemAlignment.Right
            });
            toolStrip.Items.Add(toolstripButtonOpenFolder);
            toolStrip.Items.Add(toolstripTextBoxFilename);
            toolStrip.Items.Add(toolStripLabelFilename);
            toolStrip.Items.Add(new ToolStripSeparator {
                Alignment = ToolStripItemAlignment.Right
            });

            return(toolStrip);
        }
        private void Start1(object argument)
        {
            #region Set your CancelButton, ProgressBar, and StatusLabel here...
            Form activeForm = this.parentControl;               // set myForm=this;
            ToolStripSplitButton cancelButton = this.cancelButton;
            ToolStripProgressBar progressBar  = this.progressBar;
            ToolStripStatusLabel statusLabel  = this.progressLabel;
            // disable these controls when running...
            Control[] userControls = lockControls;
            #endregion

            bool                    isRunning   = false;
            EventHandler            cancel      = null;
            FormClosingEventHandler formClosing = null;

            BackgroundTask.Start(
                argument,
                delegate(object sender, DoWorkEventArgs e)
                //(object sender, DoWorkEventArgs e) =>
            {
                #region DoWorkEventHandler - main code goes here...
                // IMPORTANT: Do not access any GUI controls here.  (This code is running in the background thread!)
                var w = (BackgroundWorker)sender;
                Thread.CurrentThread.Priority = ThreadPriority.BelowNormal;

                string tablename = e.Argument.ToString();
                var dt           = ds.Tables[tablename];

                var df = new DataFactory(Provider, ConnectionString);
                df.TestConnection();

                int maxRows = (int)df.ExecuteScalar("select count(*) from " + tablename);
                int nr      = 0;

                var sr = new StatusReport();
                sr.SetBackgroundWorker(w, e, 1);
                sr.ReportProgress("Loading", 0, maxRows, 0);

                string query = "select * from " + tablename + " (nolock)";
                foreach (var item in df.ExecuteReader(query))
                {
                    nr++;

                    if (sr.CanReportProgress())
                    {
                        sr.Value = nr;
                        sr.ReportProgress();
                    }

                    var dr = dt.NewRow();
                    DataUtil.CopyRow(item, dr);
                    dt.Rows.Add(dr);
                }

                sr.ReportProgress("Complete", 0, maxRows, maxRows);

                #endregion
            },
                delegate(object sender, EventArgs e)
                //(object sender, DoWorkEventArgs e) =>
            {
                #region EventHandler - initialize code goes here...
                // It is safe to access the GUI controls here...
                progressBar.Visible = true;
                progressBar.Minimum = progressBar.Maximum = progressBar.Value = 0;
                isRunning           = true;

                #region Hookup event handlers for Button.Canceland Form.FormClosing
                var w = sender as BackgroundWorker;
                if (w != null && w.WorkerSupportsCancellation)
                {
                    if (cancelButton != null)
                    {
                        cancel = (object sender2, EventArgs e2) =>
                        {
                            //var w = sender2 as BackgroundWorker;
                            string msg = "The application is still busy processing.  Do you want to stop it now?";
                            if (MessageBox.Show(msg, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                            {
                                w.CancelAsync();
                            }
                        };
                        cancelButton.Click  += cancel;
                        cancelButton.Enabled = true;
                        cancelButton.Visible = true;
                    }
                }

                // also, confirm the user if the user clicks the close button.
                if (activeForm != null)
                {
                    formClosing = (object sender2, FormClosingEventArgs e2) =>
                    {
                        if (!isRunning)
                        {
                            return;
                        }

                        string msg = "The application is still busy processing.  Do you want to close the application anyway?";
                        e2.Cancel  = MessageBox.Show(msg, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                                     MessageBoxDefaultButton.Button2) != DialogResult.Yes;
                    };
                    activeForm.FormClosing += formClosing;
                }
                #endregion

                FormUtil.Busy(activeForm, userControls, true);
                #endregion
            },
                delegate(object sender, ProgressChangedEventArgs e)
                //(object sender, ProgressChangedEventArgs e) =>
            {
                #region ProgressChangedEventHandler - update progress code goes here...
                // It is safe to access the GUI controls here...
                var sr = e.UserState as StatusReport;
                if (sr == null)
                {
                    return;
                }

                StatusReport.UpdateStatusReport(progressBar, sr);
                statusLabel.Text = sr.ToString();
                activeForm.Refresh();
                #endregion
            },
                delegate(object sender, RunWorkerCompletedEventArgs e)
                //(object sender, RunWorkerCompletedEventArgs e) =>
            {
                #region RunWorkerCompletedEventHandler - cleanup code goes here...
                // It is safe to access the GUI controls here...
                try
                {
                    if (e.Error != null)
                    {
                        throw e.Error;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), ex.Message);
                }
                finally
                {
                    FormUtil.Busy(activeForm, userControls, false);
                    progressBar.Visible = false;

                    if (cancel != null)
                    {
                        cancelButton.Click  -= cancel;
                        cancelButton.Enabled = false;
                        cancelButton.Visible = false;
                    }
                    if (formClosing != null)
                    {
                        activeForm.FormClosing -= formClosing;
                    }

                    isRunning        = false;
                    statusLabel.Text = "Ready";
                }
                #endregion
            });
        }
Beispiel #30
0
 public static void PopulateForwardDropDown(ToolStripSplitButton button)
 {
     PopulateMenuWith(button, forwardHistory, Forward);
 }
 // Constructors
 public ToolStripSplitButtonAccessibleObject(ToolStripSplitButton item)
 {
 }