private void superGridControl1_DataBindingComplete(object sender, DevComponents.DotNetBar.SuperGrid.GridDataBindingCompleteEventArgs e)
 {
     foreach (GridRow gridRow in e.GridPanel.Rows)
     {
         CmcsSupplierAssignSampler entity = gridRow.DataItem as CmcsSupplierAssignSampler;
         if (entity == null)
         {
             return;
         }
     }
 }
        private void FrmSupplierAssignSampler_Oper_Load(object sender, EventArgs e)
        {
            cmbSampler.Items.Add("01");
            cmbSampler.Items.Add("02");
            cmbSampler.Items.Add("03");
            cmbSampler.SelectedIndex = 0;

            this.cmcsSupplierAssignSampler = Dbers.GetInstance().SelfDber.Get <CmcsSupplierAssignSampler>(this.PId);
            if (this.cmcsSupplierAssignSampler != null)
            {
                txtSupplierName.Text    = cmcsSupplierAssignSampler.SupplierName;
                cmbSampler.SelectedItem = cmcsSupplierAssignSampler.Sampler;
                txtRemark_Goods.Text    = cmcsSupplierAssignSampler.Remark;
            }

            if (this.EditMode == eEditMode.查看)
            {
                btnSubmit.Enabled = false;
                HelperUtil.ControlReadOnly(panelEx2, true);
            }
        }
        private void superGridControl1_CellMouseDown(object sender, GridCellMouseEventArgs e)
        {
            CmcsSupplierAssignSampler entity = Dbers.GetInstance().SelfDber.Get <CmcsSupplierAssignSampler>(superGridControl1.PrimaryGrid.GetCell(e.GridCell.GridRow.Index, superGridControl1.PrimaryGrid.Columns["clmId"].ColumnIndex).Value.ToString());

            switch (superGridControl1.PrimaryGrid.Columns[e.GridCell.ColumnIndex].Name)
            {
            case "clmShow":
                FrmSupplierAssignSampler_Oper frmShow = new FrmSupplierAssignSampler_Oper(entity.Id, eEditMode.查看);
                if (frmShow.ShowDialog() == DialogResult.OK)
                {
                    BindData();
                }
                break;

            case "clmEdit":
                FrmSupplierAssignSampler_Oper frmEdit = new FrmSupplierAssignSampler_Oper(entity.Id, eEditMode.修改);
                if (frmEdit.ShowDialog() == DialogResult.OK)
                {
                    BindData();
                }
                break;

            case "clmDelete":
                // 查询正在使用该供应商的车数
                if (MessageBoxEx.Show("确定要删除该配置信息?", "操作提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    try
                    {
                        Dbers.GetInstance().SelfDber.Delete <CmcsSupplierAssignSampler>(entity.Id);
                    }
                    catch (Exception)
                    {
                        MessageBoxEx.Show("该配置信息正在使用中,禁止删除!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    BindData();
                }
                break;
            }
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtSupplierName.Text))
            {
                MessageBoxEx.Show("供货单位不能为空!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if ((cmcsSupplierAssignSampler == null || cmcsSupplierAssignSampler.SupplierName != txtSupplierName.Text) && Dbers.GetInstance().SelfDber.Entities <CmcsSupplierAssignSampler>(" where SupplierName=:SupplierName", new { SupplierName = txtSupplierName.Text }).Count > 0)
            {
                MessageBoxEx.Show("该供货单位指定采样机计划已存在!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (this.EditMode == eEditMode.修改)
            {
                if (this.SelectedSupplier != null)
                {
                    cmcsSupplierAssignSampler.SupplierId   = this.SelectedSupplier.Id;
                    cmcsSupplierAssignSampler.SupplierName = this.SelectedSupplier.Name;
                }
                cmcsSupplierAssignSampler.Sampler = cmbSampler.SelectedItem.ToString();
                cmcsSupplierAssignSampler.Remark  = txtRemark_Goods.Text;

                Dbers.GetInstance().SelfDber.Update(cmcsSupplierAssignSampler, GlobalVars.LoginUser.UserName);
            }
            else if (this.EditMode == eEditMode.新增)
            {
                cmcsSupplierAssignSampler              = new CmcsSupplierAssignSampler();
                cmcsSupplierAssignSampler.SupplierId   = this.SelectedSupplier.Id;
                cmcsSupplierAssignSampler.SupplierName = this.SelectedSupplier.Name;
                cmcsSupplierAssignSampler.Sampler      = cmbSampler.SelectedItem.ToString();
                cmcsSupplierAssignSampler.Remark       = txtRemark_Goods.Text;
                Dbers.GetInstance().SelfDber.Insert(cmcsSupplierAssignSampler);
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }