/// <summary>
        /// 车主信息修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnCustomerModify_Click(object sender, EventArgs e)
        {
            try
            {
                if (null == sender)
                {
                    if (null == m_formCustomer)
                    {
                        m_formCustomer = new CFormCustomer();
                    }
                    m_formCustomer.ClearCoutomerControls();
                    m_formCustomer.ShowDialog(this);
                    //formCustomer.Tag = this.CucipCustomer;
                    //formCustomer.ShowDialog(this);
                }
                else if (typeof(struCustomerInfo) == sender.GetType())
                {
                    struCustomerInfo Customer = (struCustomerInfo)sender;
                    if (null == m_formCustomer)
                    {
                        m_formCustomer = new CFormCustomer();
                    }

                    //m_formCustomer.Tag = this.CucipCustomer;
                    m_formCustomer.FillCustomerInfo(Customer);
                    m_formCustomer.ShowDialog(this);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 /// <summary>
 /// 保存列表中车主信息
 /// </summary>
 /// <param name="customerInfo"></param>
 public bool SaveDgvCustomerInfo(struCustomerInfo customerInfo)
 {
     // 插入
     this.CupttsUers.AddDataItem(customerInfo);
     CStaticClass.SaveStruCUSTInfo(customerInfo, 0);
     //((BindingList<struCustomerInfo>)this.DgvCustomer.DataSource).Add(customerInfo);
     return(true);
 }
Exemplo n.º 3
0
        /// <summary>
        /// 移除数据列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public bool DeleteDataList(object data)
        {
            bool flag = true;

            // 所有列表处理
            if (data.GetType() == typeof(COperatorDto))
            {
                COperatorDto dto = (COperatorDto)data;
                flag = m_lstOperator.RemoveAll(s => s.optcode == dto.optcode) > 0 ? true : false;
            }
            else if (data.GetType() == typeof(struCustomerInfo))
            {
                struCustomerInfo dto = (struCustomerInfo)data;
                flag = m_lstStruCUSTInfo.RemoveAll(s => s.strICCardID == dto.strICCardID && s.strName == dto.strName) > 0 ? true : false;
            }
            else if (data.GetType() == typeof(CSoundDto))
            {
                CSoundDto dto = (CSoundDto)data;
                flag = m_lstSound.RemoveAll(s => s.soundcode == dto.soundcode) > 0 ? true : false;
            }
            else if (data.GetType() == typeof(CLedContentDto))
            {
                CLedContentDto dto = (CLedContentDto)data;
                flag = m_lstLedContent.RemoveAll(s => s.id == dto.id) > 0 ? true : false;
            }
            else if (data.GetType() == typeof(CICCardLogDto))
            {
                CICCardLogDto dto = (CICCardLogDto)data;
                flag = m_lstICCardLog.RemoveAll(s => s.id == dto.id) > 0 ? true : false;
            }
            else if (data.GetType() == typeof(CSystemLogDto))
            {
                CSystemLogDto dto = (CSystemLogDto)data;
                flag = m_lstSystemLog.RemoveAll(s => s.logid == dto.logid) > 0 ? true : false;
            }
            else if (data.GetType() == typeof(CTelegramLogDto))
            {
                CTelegramLogDto dto = (CTelegramLogDto)data;
                flag = m_lstTelegramLog.RemoveAll(s => s.id == dto.id) > 0 ? true : false;
            }
            else if (data.GetType() == typeof(CDeviceFaultLogDto))
            {
                CDeviceFaultLogDto dto = (CDeviceFaultLogDto)data;
                flag = m_lstDeviceFaultLog.RemoveAll(s => s.id == dto.id) > 0 ? true : false;
            }
            else if (data.GetType() == typeof(CDeviceStatusLogDto))
            {
                CDeviceStatusLogDto dto = (CDeviceStatusLogDto)data;
                flag = m_lstDeviceStatusLog.RemoveAll(s => s.id == dto.id) > 0 ? true : false;
            }
            else if (data.GetType() == typeof(CTariffDto))
            {
                CTariffDto dto = (CTariffDto)data;
                flag = m_lstTariff.RemoveAll(s => s.id == dto.id) > 0 ? true : false;
            }

            return(flag);
        }
        /// <summary>
        /// 删除列表中车主信息
        /// </summary>
        /// <param name="customerInfo"></param>
        public void DeleteDgvCustomerInfo(struCustomerInfo customerInfo)
        {
            // 删除
            this.CupttsUers.DeleteDataItem(customerInfo);
            CStaticClass.SaveStruCUSTInfo(customerInfo, 2);
            //BindingList<struCustomerInfo> dataBingList = (BindingList<struCustomerInfo>)this.DgvCustomer.DataSource;
            //struCustomerInfo dgvr = dataBingList.SingleOrDefault(s => s.strICCardID == customerInfo.strICCardID && s.strName == customerInfo.strName);

            //((BindingList<struCustomerInfo>)this.DgvCustomer.DataSource).Remove(dgvr);
        }
        /// <summary>
        /// 双击车主列表行弹出“车主信息”对话框
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DgvCustomer_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {//弹出窗口
                if (e.ColumnIndex > -1 && e.RowIndex > -1)
                {
                    struCustomerInfo Customer = (struCustomerInfo)this.DgvCustomer.Rows[e.RowIndex].DataBoundItem;

                    if (null != BtnModifyClick)
                    {
                        BtnModifyClick(Customer, e);
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 /// <summary>
 /// 修改列表中车主信息
 /// </summary>
 /// <param name="customerInfo"></param>
 public bool ModifyDgvCustomerInfo(struCustomerInfo customerInfo)
 {
     // 更新
     this.CupttsUers.ModifyDataItem(customerInfo);
     CStaticClass.SaveStruCUSTInfo(customerInfo, 1);
     //BindingList<struCustomerInfo> dataBingList = (BindingList<struCustomerInfo>)this.DgvCustomer.DataSource;
     //struCustomerInfo dgvr = dataBingList.SingleOrDefault(s => s.strICCardID == customerInfo.strICCardID);
     //int index = dataBingList.IndexOf(dgvr);
     //if (-1 == index)
     //{
     //    dataBingList.Add(customerInfo);
     //}
     //else
     //{
     //    dataBingList.Remove(dgvr);
     //    dataBingList.Insert(index, customerInfo);
     //}
     return(true);
 }
        /// <summary>
        /// 车主信息修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnCustomerModify_Click(object sender, EventArgs e)
        {
            try
            {//弹出窗口
                if (1 != this.DgvCustomer.SelectedRows.Count)
                {
                    MessageBox.Show("请选择单行!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                struCustomerInfo Customer = (struCustomerInfo)this.DgvCustomer.SelectedRows[0].DataBoundItem;

                if (null != BtnModifyClick)
                {
                    BtnModifyClick(Customer, e);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// 卡类型和卡状态转换格式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DgvCustomer_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            try
            {
                if (null == e.Value)
                {
                    if (e.ColumnIndex > -1 && e.RowIndex > -1)
                    {
                        struCustomerInfo Customer = (struCustomerInfo)this.DgvCustomer.Rows[e.RowIndex].DataBoundItem;

                        switch (e.ColumnIndex)
                        {
                        case 0:
                        {
                            e.Value = Customer.strName;
                            break;
                        }

                        case 1:
                        {
                            e.Value = Customer.strICCardID;
                            break;
                        }

                        case 2:
                        {
                            e.Value = CStaticClass.ConvertICCardStatus(Customer.nICCardStatus);
                            break;
                        }

                        case 3:
                        {
                            e.Value = CStaticClass.ConvertICCardType(Customer.nICCardType);
                            break;
                        }

                        case 4:
                        {
                            e.Value = CStaticClass.ConvertWareHouse(Customer.nWareHouse);
                            break;
                        }

                        case 5:
                        {
                            e.Value = Customer.strCarPOSN;
                            break;
                        }

                        case 6:
                        {
                            e.Value = Customer.strTelphone;
                            break;
                        }

                        case 7:
                        {
                            e.Value = Customer.strMobile;
                            break;
                        }

                        case 8:
                        {
                            e.Value = Customer.strLicPlteNbr;
                            break;
                        }

                        case 9:
                        {
                            e.Value = Customer.strAddress;
                            break;
                        }

                        case 10:
                        {
                            e.Value = CStaticClass.ConvertPriorityID(Customer.nPriorityID);
                            break;
                        }
                        }
                    }

                    return;
                }

                // 卡类型
                if (3 == e.ColumnIndex)
                {
                    e.Value = CStaticClass.ConvertICCardType((int)e.Value);
                }
                // 卡状态
                else if (2 == e.ColumnIndex)
                {
                    e.Value = CStaticClass.ConvertICCardStatus((int)e.Value);
                }
                // 库区4
                else if (4 == e.ColumnIndex)
                {
                    e.Value = CStaticClass.ConvertWareHouse((int)e.Value);
                }
                // 优先级
                else if (10 == e.ColumnIndex)
                {
                    e.Value = CStaticClass.ConvertPriorityID((int)e.Value);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// 关闭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnCustomerDelete_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("确认删除?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);

            if (dr == DialogResult.Cancel)
            {
                return;
            }

            if (!CStaticClass.CheckPushService())
            {// 检查服务
                return;
            }

            QueryServiceClient proxy = new QueryServiceClient();

            try
            {
                //弹出窗口
                if (1 != this.DgvCustomer.SelectedRows.Count)
                {
                    MessageBox.Show("请选择单行!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                struCustomerInfo Customer = (struCustomerInfo)this.DgvCustomer.SelectedRows[0].DataBoundItem;
                if (string.IsNullOrEmpty(Customer.strICCardID))
                {
                    MessageBox.Show("用户卡号不能为空", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                EnmFaultType type = proxy.DeleteCustomer(Customer.strICCardID);

                switch (type)
                {
                case EnmFaultType.Success:
                {
                    DeleteDgvCustomerInfo(Customer);
                    MessageBox.Show("删除成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    break;
                }

                case EnmFaultType.NoICCardInfo:
                {
                    MessageBox.Show("没有制卡!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }

                case EnmFaultType.CarInGarage:
                {
                    MessageBox.Show("当前卡有车存在车库", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }

                case EnmFaultType.TaskOnICCard:
                {
                    MessageBox.Show("当前卡有作业正在操作", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }

                case EnmFaultType.NoBoundCustomer:
                {
                    MessageBox.Show("当前卡没有绑定车主", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }

                case EnmFaultType.NoCustomerInfo:
                {
                    MessageBox.Show("没有车主信息", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }

                case EnmFaultType.FailToDelete:
                {
                    MessageBox.Show("删除数据库失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }

                case EnmFaultType.Exception:
                {
                    MessageBox.Show(CStaticClass.GetExceptionInfo(null), "连接异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }

                default:
                {
                    MessageBox.Show("删除失败", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }
                }
            }
            catch (TimeoutException)
            {
                MessageBox.Show("The service operation timed out. ", "超时", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FaultException exception)
            {
                MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "SOAP错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (CommunicationException exception)
            {
                MessageBox.Show("There was a communication problem. " + CStaticClass.GetExceptionInfo(exception), "通信错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception exception)
            {
                MessageBox.Show(CStaticClass.GetExceptionInfo(exception), "应用程序异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            proxy.Close();
        }
Exemplo n.º 10
0
        /// <summary>
        /// 修改数据项
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ModifyDataItem(object data)
        {
            // 所有列表处理
            if (data.GetType() == typeof(COperatorDto))
            {
                COperatorDto dto   = (COperatorDto)data;
                int          index = m_lstOperator.FindIndex(s => s.optcode == dto.optcode);
                if (-1 == index)
                {
                    m_lstOperator.Add(dto);
                }
                else
                {
                    m_lstOperator.RemoveAt(index);
                    m_lstOperator.Insert(index, dto);
                }
            }
            else if (data.GetType() == typeof(struCustomerInfo))
            {
                struCustomerInfo dto = (struCustomerInfo)data;
                int index            = m_lstStruCUSTInfo.FindIndex(s => s.strICCardID == dto.strICCardID);
                if (-1 == index)
                {
                    m_lstStruCUSTInfo.Add(dto);
                }
                else
                {
                    m_lstStruCUSTInfo.RemoveAt(index);
                    m_lstStruCUSTInfo.Insert(index, dto);
                }
            }
            else if (data.GetType() == typeof(CSoundDto))
            {
                CSoundDto dto   = (CSoundDto)data;
                int       index = m_lstSound.FindIndex(s => s.soundcode == dto.soundcode);
                if (-1 == index)
                {
                    m_lstSound.Add(dto);
                }
                else
                {
                    m_lstSound.RemoveAt(index);
                    m_lstSound.Insert(index, dto);
                }
            }
            else if (data.GetType() == typeof(CLedContentDto))
            {
                CLedContentDto dto   = (CLedContentDto)data;
                int            index = m_lstLedContent.FindIndex(s => s.id == dto.id);
                if (-1 == index)
                {
                    m_lstLedContent.Add(dto);
                }
                else
                {
                    m_lstLedContent.RemoveAt(index);
                    m_lstLedContent.Insert(index, dto);
                }
            }
            else if (data.GetType() == typeof(CICCardLogDto))
            {
                CICCardLogDto dto   = (CICCardLogDto)data;
                int           index = m_lstICCardLog.FindIndex(s => s.id == dto.id);
                if (-1 == index)
                {
                    m_lstICCardLog.Add(dto);
                }
                else
                {
                    m_lstICCardLog.RemoveAt(index);
                    m_lstICCardLog.Insert(index, dto);
                }
            }
            else if (data.GetType() == typeof(CSystemLogDto))
            {
                CSystemLogDto dto   = (CSystemLogDto)data;
                int           index = m_lstSystemLog.FindIndex(s => s.logid == dto.logid);
                if (-1 == index)
                {
                    m_lstSystemLog.Add(dto);
                }
                else
                {
                    m_lstSystemLog.RemoveAt(index);
                    m_lstSystemLog.Insert(index, dto);
                }
            }
            else if (data.GetType() == typeof(CTelegramLogDto))
            {
                CTelegramLogDto dto   = (CTelegramLogDto)data;
                int             index = m_lstTelegramLog.FindIndex(s => s.id == dto.id);
                if (-1 == index)
                {
                    m_lstTelegramLog.Add(dto);
                }
                else
                {
                    m_lstTelegramLog.RemoveAt(index);
                    m_lstTelegramLog.Insert(index, dto);
                }
            }
            else if (data.GetType() == typeof(CDeviceFaultLogDto))
            {
                CDeviceFaultLogDto dto = (CDeviceFaultLogDto)data;
                int index = m_lstDeviceFaultLog.FindIndex(s => s.id == dto.id);
                if (-1 == index)
                {
                    m_lstDeviceFaultLog.Add(dto);
                }
                else
                {
                    m_lstDeviceFaultLog.RemoveAt(index);
                    m_lstDeviceFaultLog.Insert(index, dto);
                }
            }
            else if (data.GetType() == typeof(CDeviceStatusLogDto))
            {
                CDeviceStatusLogDto dto = (CDeviceStatusLogDto)data;
                int index = m_lstDeviceStatusLog.FindIndex(s => s.id == dto.id);
                if (-1 == index)
                {
                    m_lstDeviceStatusLog.Add(dto);
                }
                else
                {
                    m_lstDeviceStatusLog.RemoveAt(index);
                    m_lstDeviceStatusLog.Insert(index, dto);
                }
            }
            else if (data.GetType() == typeof(CTariffDto))
            {
                CTariffDto dto   = (CTariffDto)data;
                int        index = m_lstTariff.FindIndex(s => s.id == dto.id);
                if (-1 == index)
                {
                    m_lstTariff.Add(dto);
                }
                else
                {
                    m_lstTariff.RemoveAt(index);
                    m_lstTariff.Insert(index, dto);
                }
            }

            UpdatePages();
        }