Esempio n. 1
0
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Return:
                if (true /*this.textBox1.TextLength == 6*/)
                {
                    if (comboBox1.SelectedIndex < 0)
                    {
                        MessageBox.Show("帐号选择错误!");
                        return;
                    }
                    Worker w = comboBox1.SelectedItem as Worker;
                    if (true /*w.mm == textBox1.Text*/)
                    {
                        Form_main f = this.Owner as Form_main;
                        f.worker          = w;
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
                break;

            case Keys.Escape:
                this.DialogResult = DialogResult.Cancel;
                Close();
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
 private void Form_shouying_FormClosed(object sender, FormClosedEventArgs e)
 {
     //如果成功收银,恢复环境
     if (this.isInserted)
     {
         Form_main fm = this.Owner as Form_main;
         fm.ResetData();
         fm.ClearPeople();
     }
 }
Esempio n. 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     Form_main main = this.Owner as Form_main;
 }
Esempio n. 4
0
        private void DoWork()
        {
            if (this.textBox_ss.TextLength > 0)
            {
                try
                {
                    ss = float.Parse(this.textBox_ss.Text);
                }
                catch
                {
                    MessageBox.Show("请输入正确数字");
                    this.textBox_ss.SelectAll();
                    ss = 0.0f;
                    return;
                }
                //检查实收金额,小于应收款则出错
                zl = ss - ys;
                if (zl < 0.0f)//找零数小于零的情况下
                {
                    MessageBox.Show("找零为负数,实收现金不足!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.textBox_ss.SelectAll();
                    return;
                }
                else if (zl > 99.99f && js > 0)
                {
                    MessageBox.Show("找零数过大,实收是否输入正确?");
                    this.textBox_ss.SelectAll();
                    return;
                }

                if (ys < 0)//件数为负,表示退货,找零可以为负数
                {
                    if (textBox_ss.Text != "0")
                    {
                        MessageBox.Show("退货时的实收金额只能为0");
                        this.textBox_ss.SelectAll();
                        return;
                    }
                }
                this.SetData();
                //与主窗体间传值
                Form_main f = this.Owner as Form_main;
                f._ss = this.ss;
                f._zl = this.zl;
                return;
            }//if (this.textBox_ss.TextLength > 0)

            //找零款正确,进行打印
            else if (textBox_ss.TextLength == 0 && textBox_ss2.TextLength > 0)
            {
                if (this.isInserted)
                {
                    this.Close();
                    return;
                }

                Form_main mf = this.Owner as Form_main;
                mf.InsertIntoDatabase(isSK);
                this.isInserted = true;
                if (mf.isPrint)
                {
                    mf.Print();
                }
            }
        }
Esempio n. 5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            XmlDocument doc = new XmlDocument();

            doc.Load(Application.StartupPath + "\\yuan.xml");
            XmlNode root = doc.SelectSingleNode("config");
            string  s    = string.Format("data source={0};user id={1};password={2};database={3}",
                                         root.SelectSingleNode("ip").InnerText,
                                         root.SelectSingleNode("user").InnerText,
                                         root.SelectSingleNode("password").InnerText,
                                         root.SelectSingleNode("database").InnerText);

            try
            {
                Form_main.Connection = new MySqlConnection(s);
                Form_main.Connection.Open();
                Form_main.Command            = new MySqlCommand();
                Form_main.Command.Connection = Form_main.Connection;
                //Form_main.Command.CommandText = "set names utf8";
                //Form_main.Command.ExecuteNonQuery();
            }
            catch (MySql.Data.MySqlClient.MySqlException)
            {
                MessageBox.Show("连接到门店电脑数据库时错误!\r\n网络是否正常?", "连接错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
                return;
            }
            XmlNode temp = root.SelectSingleNode("/config/font/title");

            Form_main.title      = new Font(temp.InnerText, float.Parse(temp.Attributes["size"].Value));
            temp                 = root.SelectSingleNode("/config/font/font");
            Form_main.font       = new Font(temp.InnerText, float.Parse(temp.Attributes["size"].Value));
            temp                 = root.SelectSingleNode("/config/font/height");
            Form_main.fontHeight = float.Parse(temp.InnerText);
            temp                 = root.SelectSingleNode("/config/position/x1");
            Form_main.x1         = float.Parse(temp.InnerText);
            temp                 = root.SelectSingleNode("/config/position/x2");
            Form_main.x2         = float.Parse(temp.InnerText);
            temp                 = root.SelectSingleNode("/config/position/x3");
            Form_main.x3         = float.Parse(temp.InnerText);
            var mf = new Form_main();

            mf.windowtitle = root.SelectSingleNode("/config/shop").InnerText;
            mf.address     = root.SelectSingleNode("/config/address").InnerText;
            var name = root.SelectSingleNode("/config/printer").InnerText;

            if (name != null)
            {
                foreach (string n in PrinterSettings.InstalledPrinters)
                {
                    if (name == n)
                    {
                        Form_main.printerName = name;
                        break;
                    }
                }
            }
            Application.Run(mf);
        }