Exemple #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (!DataGridViewUtil.CheckPerrmisson(this, sender, e))
            {
                return;
            }
            try
            {
                if (e.RowIndex > -1 && e.ColumnIndex > -1)
                {
                    if (GlobalUtil.EngineUnconnectioned(this))
                    {
                        return;
                    }
                    List <Costume> list = (List <Costume>) this.dataGridView1.DataSource;
                    Costume        item = (Costume)list[e.RowIndex];
                    if (e.ColumnIndex == ColumnPrintBarcode.Index)
                    {
                        this.PrintBarCode(item);
                    }
                    else if (e.ColumnIndex == Column1.Index)
                    {//编辑
                        this.OpenModifyDialog(item, this);
                    }
                    else if (e.ColumnIndex == DeleteColumn.Index)
                    {
                        if (GlobalMessageBox.Show("确定删除该商品吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            InteractResult resultCancel = GlobalCache.ServerProxy.DeleteCostume(item.ID);
                            switch (resultCancel.ExeResult)
                            {
                            case ExeResult.Success:
                                GlobalMessageBox.Show("删除成功!");
                                GlobalCache.CostumeList_OnRemove(item);
                                RefreshPage();
                                break;

                            case ExeResult.Error:
                                GlobalMessageBox.Show(resultCancel.Msg);
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    else if (e.ColumnIndex == Column2.Index)
                    {  //判断库存
                        UpdateCostumeValidPara para = new UpdateCostumeValidPara()
                        {
                            CostumeID = item.ID,
                            IsValid   = false
                        };
                        InteractResult result = GlobalCache.ServerProxy.UpdateCostumeValid(para);
                        switch (result.ExeResult)
                        {
                        case ExeResult.Success:
                            GlobalMessageBox.Show("禁用成功!");
                            item.IsValid = false;
                            GlobalCache.CostumeList_OnChange(item);
                            RefreshPage();
                            break;

                        case ExeResult.Error:
                            GlobalMessageBox.Show(result.Msg);
                            break;

                        default:
                            break;
                        }
                    }
                    else if (e.ColumnIndex == Column3.Index)
                    {
                        UpdateCostumeValidPara paraCancel = new UpdateCostumeValidPara()
                        {
                            CostumeID = item.ID,
                            IsValid   = true
                        };
                        InteractResult resultCancel = GlobalCache.ServerProxy.UpdateCostumeValid(paraCancel);
                        switch (resultCancel.ExeResult)
                        {
                        case ExeResult.Success:
                            GlobalMessageBox.Show("取消禁用成功!");
                            item.IsValid = true;
                            GlobalCache.CostumeList_OnChange(item);
                            RefreshPage();
                            break;

                        case ExeResult.Error:
                            GlobalMessageBox.Show(resultCancel.Msg);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalUtil.ShowError(ex);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }