예제 #1
0
        private void btnRefresh_Click(object sender, EventArgs e)
        {
            try
            {
                if (bsMain.Filter.Trim().Length != 0)
                {
                    DialogResult result = MessageBox.Show("���¶���������ѡ��'��(Y)',�������������ѡ��'��(N)'", "ѯ��", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    switch (result)
                    {
                        case DialogResult.No:
                            DataGridViewAutoFilter.DataGridViewAutoFilterTextBoxColumn.RemoveFilter(dgvMain);
                            return;
                        case DialogResult.Cancel:
                            return;
                    }
                }

                btnRefresh.Enabled = false;
                btnChart.Enabled = false;

                pnlProgress.Top = (pnlMain.Height - pnlProgress.Height) / 3;
                pnlProgress.Left = (pnlMain.Width - pnlProgress.Width) / 2;
                pnlProgress.Visible = true;
                Application.DoEvents();
                url = configUtil.GetConfig("URL")["URL"];
                Task task = new Task(url);
                try
                {
                    task.Getshelf();
                    task.GetShelf += new Task.GetShelfEventHandler(delegate(bool isSuccess, string msg, ShelfInfo[] shelfInfo)
                    {
                        if (shelfInfo != null)
                        {
                            //bsMain.DataSource = shelfInfo;
                            cellTable = new DataTable();
                            cellTable.Columns.Add("ShelfCode");
                            cellTable.Columns.Add("ShelfName");
                            cellTable.Columns.Add("CellCode");
                            cellTable.Columns.Add("CellName");
                            cellTable.Columns.Add("ProductCode");
                            cellTable.Columns.Add("ProductName");
                            cellTable.Columns.Add("QuantityTiao", typeof(decimal));
                            cellTable.Columns.Add("QuantityJian", typeof(decimal));
                            cellTable.Columns.Add("WareCode");
                            cellTable.Columns.Add("WareName");
                            cellTable.Columns.Add("IsActive");
                            cellTable.Columns.Add("RowNum");
                            cellTable.Columns.Add("ColNum");
                            cellTable.Columns.Add("Shelf");
                            foreach (ShelfInfo shelf in shelfInfo)
                            {
                                this.ShelfInfo = shelf;
                                DataRow dr = cellTable.NewRow();
                                dr["ShelfCode"] = shelf.ShelfCode;
                                dr["ShelfName"] = shelf.ShelfName;
                                dr["CellCode"] = shelf.CellCode;
                                dr["CellName"] = shelf.CellName;
                                dr["ProductCode"] = shelf.ProductCode;
                                dr["ProductName"] = shelf.ProductName;
                                dr["QuantityTiao"] = shelf.QuantityTiao;
                                dr["QuantityJian"] = shelf.QuantityJian;
                                dr["WareCode"] = shelf.WareCode;
                                dr["WareName"] = shelf.WareName;
                                dr["IsActive"] = shelf.IsActive;
                                dr["RowNum"] = shelf.RowNum;
                                dr["ColNum"] = shelf.ColNum;
                                dr["Shelf"] = shelf.Shelf;
                                cellTable.Rows.Add(dr);
                            }
                            if (cellTable.Rows.Count > 0)
                            {
                                btnChart.Enabled = true;
                                pnlProgress.Visible = false;
                                btnRefresh.Enabled = true;
                            }
                            bsMain.DataSource = cellTable;
                        }
                        else
                        {
                            bsMain.DataSource = null;
                        }
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show("��ȡ����ʧ�ܣ�ԭ��" + ex.Message, "��Ϣ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception exp)
            {
                THOKUtil.ShowInfo("��������ʧ�ܣ�ԭ��" + exp.Message);
            }
        }
예제 #2
0
        //ˢ������
        private void RefreshData()
        {
            if (BillMasters == null)
            {
                dgvMain.DataSource = null;
                return;
            }
            sslBillID.Text = "���ݺţ�" + billNo + "                              ";
            sslOperator.Text = "����Ա��" + Environment.MachineName;

            Task task = new Task(url);
            task.GetBillDetailCompleted += new Task.GetBillDetailCompletedEventHandler(delegate(bool isSuccess, string msg, BillDetail[] billDetails)
            {
                InTask = false;

                if (billDetails != null && billDetails.Length != 0)
                {
                    dgvMain.AutoGenerateColumns = false;
                    dgvMain.DataSource = billDetails;

                    foreach (BillDetail billDetail in billDetails)
                    {
                        storageName = billDetail.StorageName;
                        targetStorageName = billDetail.TargetStorageName;
                        if (billDetail.Status == "1")
                        {
                            InTask = true;
                            btnCancel.Enabled = true;
                            btnConfirm.Enabled = true;
                            btnBatConfirm.Enabled = true;
                        }
                        else
                        {
                            btnApply.Enabled = true;
                        }
                    }
                }
                else
                {
                    dgvMain.DataSource = null;
                    isAppyInt = 0;
                }
                ClosePlWailt();
                dgvMain.ClearSelection();
                task.Getshelf();
                task.GetShelf += new Task.GetShelfEventHandler(delegate(bool isSuccesss, string msgs, ShelfInfo[] shelfInfo)
                {
                    if (shelfInfo != null)
                    {
                        cellTable = new DataTable();
                        cellTable.Columns.Add("ShelfCode");
                        cellTable.Columns.Add("ShelfName");
                        cellTable.Columns.Add("CellCode");
                        cellTable.Columns.Add("CellName");
                        cellTable.Columns.Add("ProductCode");
                        cellTable.Columns.Add("ProductName");
                        cellTable.Columns.Add("QuantityTiao", typeof(decimal));
                        cellTable.Columns.Add("QuantityJian", typeof(decimal));
                        cellTable.Columns.Add("WareCode");
                        cellTable.Columns.Add("WareName");
                        cellTable.Columns.Add("IsActive");
                        cellTable.Columns.Add("RowNum");
                        cellTable.Columns.Add("ColNum");
                        cellTable.Columns.Add("Shelf");
                        foreach (ShelfInfo shelf in shelfInfo)
                        {
                            this.ShelfInfo = shelf;
                            DataRow dr = cellTable.NewRow();
                            dr["ShelfCode"] = shelf.ShelfCode;
                            dr["ShelfName"] = shelf.ShelfName;
                            dr["CellCode"] = shelf.CellCode;
                            dr["CellName"] = shelf.CellName;
                            dr["ProductCode"] = shelf.ProductCode;
                            dr["ProductName"] = shelf.ProductName;
                            dr["QuantityTiao"] = shelf.QuantityTiao;
                            dr["QuantityJian"] = shelf.QuantityJian;
                            dr["WareCode"] = shelf.WareCode;
                            dr["WareName"] = shelf.WareName;
                            dr["IsActive"] = shelf.IsActive;
                            dr["RowNum"] = shelf.RowNum;
                            dr["ColNum"] = shelf.ColNum;
                            dr["Shelf"] = shelf.Shelf;
                            cellTable.Rows.Add(dr);
                        }
                        if (cellTable.Rows.Count > 0)
                        {
                            btnChart.Enabled = true;
                        }
                    }
                });
            });
            task.SearchBillDetail(BillMasters, RfidReadProductCode, OperateType, OperateAreas, Environment.MachineName);
            DisplayPlWailt();
        }