Exemple #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int code = (int)dataGridView1.Rows[e.RowIndex].Cells["code"].Value;

            //openbox
            if (e.ColumnIndex == 5)
            {
                bool issuccess = bm.Find(code).Open();

                //MessageBox.Show(issuccess.ToString());
                UpdateData();
            }
            //删包裹
            if (e.ColumnIndex == 6)
            {
                DataGridViewDisableButtonCell btnCell = (DataGridViewDisableButtonCell)dataGridView1.Rows[e.RowIndex].Cells["deletePackage"];
                if (btnCell.Enabled)
                {
                    bool issuccess = pm.TakePackage(code, 2);
                    //MessageBox.Show(issuccess.ToString());
                    UpdateData();
                }
            }
            //disable box
            if (e.ColumnIndex == 7)
            {
                //DataGridViewDisableButtonCell btnCell = (DataGridViewDisableButtonCell)dataGridView1.Rows[e.RowIndex].Cells["open"];
                if (bm.Find(code).CurrentState == Box.State.Fault)
                {
                    bm.DisableBox(code);
                    //btnCell.Enabled = true;
                    UpdateData();
                }
                else
                {
                    bm.EnableBox(code);
                    UpdateData();
                }
            }
        }
Exemple #2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int code = (int)dataGridView1.Rows[e.RowIndex].Cells["code"].Value;
                //openbox
                if (e.ColumnIndex == 5)
                {
                    bool issuccess = bm.Find(code).Open();
                    UpdateData();

                    CLog4net.LogInfo("管理员开箱:" + code);
                }
                //删包裹
                if (e.ColumnIndex == 6)
                {
                    DataGridViewDisableButtonCell btnCell = (DataGridViewDisableButtonCell)dataGridView1.Rows[e.RowIndex].Cells[deletePackageColName];
                    if (btnCell.Enabled)
                    {
                        DialogResult dr = MessageBox.Show("确认操作", "Information", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                        if (dr == DialogResult.Cancel)
                        {
                            return;
                        }

                        BoxsManager.GetInstance().ClearBox(code);
                        //MessageBox.Show(issuccess.ToString());
                        UpdateData();

                        bool issuccess = pm.TakePackage(code, 2);
                        CLog4net.LogInfo("管理员删除包裹:" + code + " success:" + issuccess);

                        ServerCallback3 sc = serverService.ManagerDeletePackage(code.ToString(), AboutConfig.GetInstance().GetAbout());
                        if (!sc.Success)
                        {
                            CLog4net.LogInfo("管理员删除包裹失败:" + code + " 服务器信息:" + sc.Message);
                            //return; //如果是因为服务器找不到需要删除的包裹,删包裹失败返回,那么客户端箱子将永远不能清空;
                        }
                    }
                }
                //disable box
                if (e.ColumnIndex == 7)
                {
                    DialogResult dr = MessageBox.Show("确认操作", "Information", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                    if (dr == DialogResult.Cancel)
                    {
                        return;
                    }
                    //DataGridViewDisableButtonCell btnCell = (DataGridViewDisableButtonCell)dataGridView1.Rows[e.RowIndex].Cells["open"];
                    if (bm.Find(code).CurrentState == Box.State.Fault)
                    {
                        bm.EnableBox(code);
                        //btnCell.Enabled = true;
                        UpdateData();

                        CLog4net.LogInfo("管理员启用箱子:" + code);
                    }
                    else
                    {
                        bm.DisableBox(code);
                        UpdateData();

                        CLog4net.LogInfo("管理员停用箱子:" + code);
                    }
                }
            }
            catch (Exception ex)
            {
                CLog4net.LogError("管理员操作异常:" + ex.ToString());
            }
        }