Beispiel #1
0
        private void sorteGoodList_Load(object sender, EventArgs e)
        {
            numberTextBox.Focus();
            Times times = new Times();

            times.TopLevel = false;
            this.timePanel.Controls.Add(times);
            times.Show();

            //if (goodDataGridView.Focused == true)
            //{
            //    MessageBox.Show("true");
            //}
            //else
            //{
            //    MessageBox.Show("false");
            //}
            //goodDataGridView.ClearSelection();

            int hw = redButton.Height;

            if (hw > redButton.Width)
            {
                hw = redButton.Width;
            }
            System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
            gp.AddEllipse(4, 4, hw - 8, hw - 8);
            gp.FillMode            = System.Drawing.Drawing2D.FillMode.Winding;
            redButton.Region       = new Region(gp);
            redButton.BackColor    = Color.Red;
            yellowButton.Region    = new Region(gp);
            yellowButton.BackColor = Color.Yellow;
            greenButton.Region     = new Region(gp);
            greenButton.BackColor  = Color.Green;
            //---
            dt            = ConstantUtil.Branchds.Tables["Zc_sorte_item"];
            result        = dt.Rows[ConstantUtil.index][14];
            textBox2.Text = dt.Rows[ConstantUtil.index][9].ToString();
            sortedao      = new orderDao();
            branchName    = sortedao.getBranchName(result.ToString());
            textBox1.Text = branchName;

            //展示数据
            showInfo();

            //后台刷新数据
            System.Timers.Timer pTimer = new System.Timers.Timer(1000);               //每隔5秒执行一次,没用winfrom自带的
            pTimer.Elapsed  += new System.Timers.ElapsedEventHandler(pTimer_Elapsed); //委托,要执行的方法
            pTimer.AutoReset = true;                                                  //获取该定时器自动执行
            pTimer.Enabled   = true;                                                  //这个一定要写,要不然定时器不会执行的
            Control.CheckForIllegalCrossThreadCalls = false;                          //这个不太懂,有待研究
        }
Beispiel #2
0
        public string[] GetPrintStr()
        {
            //DataTable dt = ConstantUtil.Branchds.Tables["Zc_sorte_item"];
            //string street = dt.Rows[ConstantUtil.index][13].ToString();
            sortedao   = new orderDao();
            branchName = sortedao.getBranchName(ConstantUtil.street);

            StringBuilder sb = new StringBuilder();

            string tou = "宜鲜美配送有限公司";

            string address = "南京市江宁区东麒路66号";

            //string saleID = id_.Text;

            //string item = "品名";

            //decimal price = 25.00M;

            //int count = 5;

            //decimal total = 0.00M;

            //decimal fukuan = 500.00M;



            sb.Append("            " + tou + "     \n");

            sb.Append("-----------------------------------------------------------------\n");

            sb.Append("日期:" + DateTime.Now.ToShortDateString() + "  " + "分店:" + branchName + "\n");

            sb.Append("-----------------------------------------------------------------\n");

            sb.Append("品名" + "\t\t" + "单价" + "\t" + "重/数量" + "\t" + "小计" + "\n");
            //for (int i = 0; i < itemDataGridView.RowCount; i++)
            //{
            //    int actualnums = itemDataGridView[4, i].Value == null ? 0 : Convert.ToInt32(itemDataGridView[4, i].Value);
            //    if (actualnums != 0)
            //    {
            //        string name = itemDataGridView[1, i].Value == null ? "" : itemDataGridView[1, i].Value.ToString();
            //        if (name.Length < 4)
            //        {
            //            name += "\t\t";
            //        }
            //        else if (name.Length <= 6)
            //        {
            //            name += "\t";
            //        }
            //        else
            //        {
            //            name = name.Substring(0, 6) + "... ";
            //        }
            //        string price = itemDataGridView[2, i].Value == null ? "" : itemDataGridView[2, i].Value.ToString();
            //        price = float.Parse(price).ToString("0.00");
            //        string amount = itemDataGridView[7, i].Value == null ? "" : itemDataGridView[7, i].Value.ToString();
            //        amount = float.Parse(amount).ToString("0.00");
            //        sb.Append(name + price + "\t" + actualnums + "\t" + amount + "\n");
            //    }
            //}
            float  totalSum    = 0;
            float  totalAmount = 0;
            string sql         = "select a.goods_id, a.goods_name, a.SORTENUM, a.WEIGHT, b.GOODS_PRICE, b.GOODS_UNIT  from ZC_ORDERS_SORTE a left join ZC_GOODS_MASTER b "
                                 + " on a.GOODS_ID = b.SERIALNUMBER where a.ADDRESS = :street and a.SORTEID = :sorteId order by b.serialnumber ";
            OracleConnection conn = null;
            OracleCommand    cmd  = new OracleCommand();

            try
            {
                conn            = OracleUtil.OpenConn();
                cmd.Connection  = conn;
                cmd.CommandText = sql;
                cmd.Parameters.Add(":street", ConstantUtil.street);
                cmd.Parameters.Add(":sorteId", ConstantUtil.sorte_id);
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    string serialNumber = reader.IsDBNull(0) ? string.Empty : reader.GetString(0);
                    string name         = reader.IsDBNull(1) ? string.Empty : reader.GetString(1);
                    string sorteNum     = reader.IsDBNull(2) ? "0" : reader.GetString(2);
                    string weightString = reader.IsDBNull(3) ? "0" : reader.GetString(3);
                    string goodsPrice   = reader.IsDBNull(4) ? "0" : reader.GetFloat(4).ToString("0.00");
                    string unit         = reader.IsDBNull(5) ? string.Empty : reader.GetString(5);
                    float  weight       = float.Parse(weightString);
                    float  price        = float.Parse(goodsPrice);
                    float  nums         = float.Parse(sorteNum);
                    totalSum    += nums;
                    totalAmount += price * nums;
                    if (name.Length < 4)
                    {
                        name += "\t\t";
                    }
                    else if (name.Length <= 6)
                    {
                        name += "\t";
                    }
                    else
                    {
                        name = name.Substring(0, 6) + "...\t";
                    }
                    if (serialNumber.Length == 5)
                    {
                        sb.Append(name + price.ToString("0.00") + "\t" + weight.ToString("0.000") + "\t" + (price * weight).ToString("0.00") + "\n");
                    }
                    else
                    {
                        sb.Append(name + price.ToString("0.00") + "\t" + sorteNum + unit + "\t" + (price * nums).ToString("0.00") + "\n");
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }
            finally
            {
                cmd.Dispose();
                OracleUtil.CloseConn(conn);
            }
            sb.Append("-----------------------------------------------------------------\n");

            sb.Append("数量: " + totalSum.ToString("0.00") + "\t\t 合计: " + totalAmount.ToString("0.00") + "\n");

            sb.Append("-----------------------------------------------------------------\n");

            sb.Append("地址:" + address + "\n");


            sb.Append("             谢谢惠顾欢迎下次光临                ");
            //log.Error(sb.ToString()+"--------->");
            return(sb.ToString().Split('\n'));
        }
Beispiel #3
0
        public DataSet getGridData()
        {
            result = dt.Rows[ConstantUtil.index][14];
            string remark = dt.Rows[ConstantUtil.index][9].ToString().Trim();

            if (string.IsNullOrEmpty(remark))
            {
                //topPanel.Height = 100;
                messagePanel.Visible    = false;
                goodTablePanel.Location = new Point(3, 117);
                //goodTablePanel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
                textBox2.Text = "";
                //label1.Visible = false;
                //textBox2.Visible = false;
                // goodTablePanel.Height = goodTableGroupBox.Height - topPanel.Height - topPanel.Location.Y;
            }
            else
            {
                //topPanel.Height = 165;
                messagePanel.Visible    = true;
                goodTablePanel.Location = new Point(3, 182);
                //goodTablePanel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
                //goodTablePanel.Height = goodTableGroupBox.Height - topPanel.Height - topPanel.Location.Y - messagePanel.Location.Y - messagePanel.Height;
                //label1.Visible = true;
                //textBox2.Visible = true;
                textBox2.Text = remark;
            }
            sortedao      = new orderDao();
            branchName    = sortedao.getBranchName(result.ToString());
            textBox1.Text = branchName;
            try
            {
                OracleConnection connection = OracleUtil.OpenConn();
                if (connection == null)
                {
                    ds = null;
                }
                else
                {
                    //在每次查找或填充数据前判断ds是否为null
                    if (ds != null)
                    {
                        if (ds.Tables.Count > 0)
                        {
                            ds.Tables[0].Rows.Clear();
                            ds.Tables[0].Columns.Clear();
                            ds.Tables[0].AcceptChanges();
                        }
                    }
                    else
                    {
                        ds = new DataSet();
                    }
                    string sql = "select name,serialNumber,goodsfile_id,sum(nums) as nums,branchid ,sorteNum ,workname,workcode from "
                                 + "(select a.goods_state,a.name,a.nums,c.id as goodsfile_id,c.serialNumber,b.branchid,d.sortenum,e.workname,e.workcode "
                                 + " from zc_order_process_item a "
                                 + " left join zc_order_process b on b.id=a.order_id left join zc_goods_master c on c.id=a.goodsfile_id left join (select SUM(sortenum) as sortenum,goods_id ,address from ZC_ORDERS_SORTE where sorteId = '" + ConstantUtil.sorte_id + "' GROUP by goods_id, address) d on d.goods_id = c.id and b.branchid=d.address  left join zc_workstation e on e.id = c.zcuserinfo"
                                 + " where branchid = '" + result + "' ) "
                                 + "group by name,serialNumber,goodsfile_id,branchid,sorteNum,workname,workcode order by serialNumber";
                    OracleCommand     cmd = new OracleCommand(sql, connection);
                    OracleDataAdapter da  = new OracleDataAdapter(cmd);
                    da.Fill(ds, "Zc_sorte_item");

                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                log.Error("加载各分店商品信息失败", ex);
            }
            return(ds);
        }