Ejemplo n.º 1
0
        //初始化
        private void Init()
        {
            #region 设置功能按钮可见性
            UIAssistants.SetUCBaseFuncationVisible(this, new ObservableCollection<ButtonEx_sms>()
            {
                btnSave, btnCancel, btnSet, btnView, btnPrint
            });
            #endregion

            #region 初始化下拉框数据绑定
            CommonCtrl.CmbBindDict(cbo_cb_Callback_type, "sys_callback_type", false);    //绑定回访类型
            CommonCtrl.CmbBindDict(cbo_cb_Callback_mode, "sys_callback_mode", false);    //绑定回访方式
            CommonCtrl.CmbBindDict(cbo_member_class, "sys_member_grade", false);    //绑定会员等级
            CommonFuncCall.BindProviceComBox(cbo_province, "请选择");  //绑定省份
            CommonFuncCall.BindCityComBox(cbo_city, "", "请选择");   //绑定城市
            CommonFuncCall.BindCountryComBox(cbo_county, "", "请选择");    //绑定县/区
            cbo_province.SelectedIndexChanged += ddlprovince_SelectedIndexChanged;
            cbo_city.SelectedIndexChanged += ddlcity_SelectedIndexChanged;
            CommonCtrl.CmbBindDict(cbo_cust_type, "sys_customer_category", false);  //客户类别
            #endregion

            lbl_cb_create_by.Text = GlobalStaticObj.CurrUserCom_Name;
            lbl_cb_create_by.Tag = GlobalStaticObj.UserID;
            if (OpType == WindowStatus.Edit || OpType == WindowStatus.View)
            {
                SetCustInfo();
                SetContInfo();
                SetCallbackInfo();
            }
            if (OpType == WindowStatus.View) palQTop.Enabled = false;
            #region 注册功能按钮事件
            #region 选择客户信息
            txt_cust_code.ChooserClick += delegate
            {
                var frmCustomer = new frmCustomerInfo();
                var result = frmCustomer.ShowDialog();
                if (result == DialogResult.OK)
                {
                    CustId = frmCustomer.strCustomerId;
                    txt_cust_code.Tag = CustId;
                    txt_cust_code.Text = frmCustomer.strCustomerNo;
                }

                SetCustInfo();
            };
            #endregion

            #region 选择被回访人
            txt_cb_Callback_by.ChooserClick += delegate
            {
                var frmContacts = new frmContacts();
                var result = frmContacts.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ContId = frmContacts.contID;
                    txt_cb_Callback_by.Tag = ContId;
                    txt_cb_Callback_by.Text = frmContacts.contName;
                    txt_cb_Callback_by_duty.Caption = frmContacts.contDuty;
                    txt_cb_Callback_by_phone.Caption = frmContacts.contPhone;
                }
            };
            #endregion

            #region 选择经办人
            txt_handle_name.ChooserClick += delegate
            {
                var chooser = new frmUsers();
                var result = chooser.ShowDialog();
                if (result == DialogResult.OK)
                {
                    txt_handle_name.Text = chooser.User_Name;
                    txt_handle_name.Tag = chooser.User_ID;
                    txt_cb_handle_org.Caption = chooser.OrgName;
                }
            };
            #endregion

            #region 保存数据
            SaveEvent += delegate
            {
                var check = CheckValue();
                if (!check) return;
                var dicFileds = new Dictionary<String, String>();
                if (OpType == WindowStatus.Add)
                {
                    dicFileds.Add("create_by", GlobalStaticObj.UserID);  //创建人
                    dicFileds.Add("create_time", DBHelper.GetCurrentTime().Ticks.ToString());    //创建时间
                    dicFileds.Add("update_by", GlobalStaticObj.UserID);  //最后编辑人
                    dicFileds.Add("update_time", DBHelper.GetCurrentTime().Ticks.ToString());    //最后编辑时间
                    dicFileds.Add("Callback_id", Guid.NewGuid().ToString());  //客户ID
                    dicFileds.Add("status", "58b325d2-0792-4847-8e4a-22b3f25628f3");   //数据状态
                }
                else if (OpType == WindowStatus.Edit)
                {
                    dicFileds.Add("update_by", GlobalStaticObj.UserID);  //最后编辑人
                    dicFileds.Add("update_time", DBHelper.GetCurrentTime().Ticks.ToString());    //最后编辑时间
                }
                dicFileds.Add("Callback_corp", txt_cust_code.Tag.ToString());  //客户ID
                dicFileds.Add("Callback_time", DBHelper.GetCurrentTime().Ticks.ToString());   //回访时间
                dicFileds.Add("Callback_type", cbo_cb_Callback_type.SelectedValue.ToString()); //回访类型
                dicFileds.Add("Callback_mode", cbo_cb_Callback_mode.SelectedValue.ToString()); //回访方式
                dicFileds.Add("title",txt_cb_title.Caption);    //回访标题
                dicFileds.Add("record", rtx_cb_record.Text);    //回访内容
                dicFileds.Add("Callback_by", txt_cb_Callback_by.Tag.ToString());  //被回访人员名称
                dicFileds.Add("Callback_by_org", txt_cb_Callback_by_org.Caption);   //被回访人员部门名称
                dicFileds.Add("Callback_by_phone", txt_cb_Callback_by_phone.Caption);   //被回访人电话
                dicFileds.Add("Callback_by_duty", txt_cb_Callback_by_duty.Caption); //被回访人职务
                dicFileds.Add("handle_name", txt_handle_name.Tag.ToString());    //经办人
                dicFileds.Add("handle_org", txt_cb_handle_org.Caption); //经办人部门名称
                var result = false;
                try
                {
                    result = DBHelper.Submit_AddOrEdit("保存客户回访", "tb_CustomerSer_Callback", "Callback_id", CallBackId, dicFileds);
                }
                catch (Exception ex)
                {
                    result = false;
                }
                MessageBoxEx.Show(result ? "保存成功!" : "保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                if (result)
                {
                    UCCallBackManager.BindPageData();
                    deleteMenuByTag(Tag.ToString(), UCCallBackManager.Name);
                }
            };
            #endregion
            #endregion
        }
Ejemplo n.º 2
0
        //初始化
        private void Init()
        {
            dgvQData.MultiSelect = false;    //不允许多选操作
            SetUCBaseFuncationVisible();
            #region 初始化时间控件值
            dtpCBSTime.Value = DateTime.Now.AddMonths(-1);
            dtpCBETime.Value = DateTime.Now.AddDays(+1);
            #endregion

            #region 初始化下拉框数据绑定
            CommonCtrl.BindComboBoxByDictionarr(cboCBType, "sys_callback_type", true);    //绑定回访类型
            CommonCtrl.BindComboBoxByDictionarr(cboCBMode, "sys_callback_mode", true);    //绑定回访方式
            #endregion

            #region 注册功能按钮事件
            #region 清除查询条件
            btnClear.Click += delegate 
            {
                txtCBTitle.Caption = String.Empty;
                cboCBType.SelectedValue = String.Empty;
                cboCBMode.SelectedValue = String.Empty;
                dtpCBSTime.Value = DateTime.Now.AddMonths(-1);
                dtpCBETime.Value = DateTime.Now.AddDays(1);
                txtCustomerName.Text = String.Empty;
                txtCustomerName.Tag = String.Empty;
                txtCBPerson.Text = String.Empty;
            };
            #endregion

            #region 查询
            btnQuery.Click += delegate
            {
                BindPageData();
            };
            #endregion

            #region 选择客户信息
            txtCustomerName.ChooserClick += delegate 
            {
                var frmCustomer = new frmCustomerInfo();
                var result = frmCustomer.ShowDialog();
                if (result == DialogResult.OK)
                {
                    txtCustomerName.Text = frmCustomer.strCustomerName;
                    txtCustomerName.Tag = frmCustomer.strCustomerId;
                }
            };
            #endregion
             
            #region 选择回访人
            txtCBPerson.ChooserClick += delegate
            {
                var frmContacts= new frmContacts();
                var result = frmContacts.ShowDialog();
                if (result == DialogResult.OK)
                {
                    txtCBPerson.Text = frmContacts.contName;
                    txtCBPerson.Tag = frmContacts.contID;
                }
            };
            #endregion

            #region 数据翻页
            pageQ.PageIndexChanged += delegate
            {
                BindPageData();
            };
            #endregion

            #region 数据表数据选择
            dgvQData.CellDoubleClick += delegate(object sender, DataGridViewCellEventArgs args)
            {
                if (args.ColumnIndex <= 0) return;
                var uc = new UCCallBackAddOrEdit {OpType = WindowStatus.View, UCCallBackManager = this};
                var selectedData = dgvQData.SelectedRows[0];
                uc.CallBackId = selectedData.Cells["drtxt_Callback_id"].Value.ToString();
                var callbackInfo = DBHelper.GetTable("查询回访信息", "tb_CustomerSer_Callback", "*",
                    "Callback_id = '" + uc.CallBackId + "'", "",
                    "");
                if (callbackInfo != null && callbackInfo.DefaultView.Count != 0)
                {
                    uc.CustId = callbackInfo.DefaultView[0]["Callback_corp"].ToString();
                    uc.ContId = callbackInfo.DefaultView[0]["Callback_by"].ToString();
                    uc.HandleId = callbackInfo.DefaultView[0]["handle_name"].ToString();
                }
                uc.addUserControl(uc, "客户回访-预览", "UCCallBackView", Tag.ToString(), Name);
            };
            #endregion

            #region 数据表格数据格式化
            dgvQData.CellFormatting += delegate(object sender, DataGridViewCellFormattingEventArgs args)
            {
                UIAssistants.DgvCellDataConvert2Table(dgvQData, args, "Callback_by", "tb_contacts", "cont_id", "cont_name");
                UIAssistants.DgvCellDataConvert2Table(dgvQData, args, "handle_name", "sys_user", "user_id", "user_name");
                UIAssistants.DgvCellDataConvert2Table(dgvQData, args, "Callback_corp", "tb_customer", "cust_id", "cust_name");
                UIAssistants.DgvCellDataConvert2Datetime(dgvQData, args, "Callback_time");
                UIAssistants.DgvCellDataConvert2DicData(dgvQData, args, "Callback_type");    //访问类型
                UIAssistants.DgvCellDataConvert2DicData(dgvQData, args, "Callback_mode");    //访问形式
                UIAssistants.DgvCellDataConvert2DicData(dgvQData, args, "status");    //状态

            };
            #endregion

            #region 新增数据
            AddEvent += delegate
            {
                var uc = new UCCallBackAddOrEdit();
                uc.UCCallBackManager = this;
                uc.OpType = WindowStatus.Add;
                uc.addUserControl(uc, "客户回访-新增", "UCCallBackAdd", Tag.ToString(), Name);
            };
            #endregion

            #region 编辑数据
            EditEvent += delegate
            {
                if (dgvQData.SelectedRows.Count > 0)
                {
                    var uc = new UCCallBackAddOrEdit();
                    uc.OpType = WindowStatus.Edit;
                    uc.UCCallBackManager = this;
                    var selectedData = dgvQData.SelectedRows[0];
                    uc.CallBackId = selectedData.Cells["drtxt_Callback_id"].Value.ToString();
                    var callbackInfo = DBHelper.GetTable("查询回访信息", "tb_CustomerSer_Callback", "*",
                        "Callback_id = '" + uc.CallBackId + "'", "",
                        "");
                    if (callbackInfo != null && callbackInfo.DefaultView.Count != 0)
                    {
                        uc.CustId = callbackInfo.DefaultView[0]["Callback_corp"].ToString();
                        uc.ContId = callbackInfo.DefaultView[0]["Callback_by"].ToString();
                        uc.HandleId = callbackInfo.DefaultView[0]["handle_name"].ToString();
                    }
                    uc.addUserControl(uc, "客户回访-编辑", "UCCallBackEdit", Tag.ToString(), Name);
                }
            };
            #endregion

            #region 删除数据
            DeleteEvent += delegate
            {
                try
                {
                    if (dgvQData.SelectedRows.Count == 0)
                    {
                        MessageBoxEx.Show("请选择删除记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    var listField = (from DataGridViewRow selectedRow in dgvQData.SelectedRows select selectedRow.Cells["drtxt_Callback_id"].Value.ToString()).ToList();
                    
                    var result = MessageBoxEx.Show("此操作将永久删除选定信息。\n若要继续,请单击“确定”。", "您确认要删除此条信息吗?", MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Warning);
                    if (result == DialogResult.OK)
                    {
                        var flag = DBHelper.BatchDeleteDataByWhere("删除客户回访信息", "tb_CustomerSer_Callback", String.Format("Callback_id = '{0}'", listField[0]));
                        if (flag)
                        {
                            BindPageData();
                            MessageBoxEx.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            BindPageData();
                        }
                        else
                        {
                            MessageBoxEx.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBoxEx.Show("删除失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            };
            #endregion

            #region 启用/禁用
            StatusEvent += delegate
            {
                if (dgvQData.SelectedRows.Count > 0)
                {
                    var dataView = GetSelectedRowData();
                    var listField = GetCheckRows();
                    if (listField.Count >= 1)
                    {
                        if (MessageBoxEx.Show("确认要" + btnStatus.Caption + "吗?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK)
                        {
                            return;
                        }
                        var flag = false;
                        foreach (DataRowView view in dataView)
                        {
                            var status = CommonCtrl.IsNullToString(view[drtxt_status.DataPropertyName]);
                            flag = DBHelper.Submit_AddOrEdit("启用/停用客户回访记录", "tb_CustomerSer_Callback", "Callback_id",
                                CommonCtrl.IsNullToString(view[drtxt_Callback_id.DataPropertyName]),
                                new Dictionary<string, string>
                                {
                                    {
                                        "status",
                                        status == DbDic2Enum.SYS_DATA_STATUS_QI
                                            ? DbDic2Enum.SYS_DATA_STATUS_JIN
                                            : DbDic2Enum.SYS_DATA_STATUS_QI
                                    },
                                    {
                                        "update_by", GlobalStaticObj.UserID
                                    },
                                    {
                                        "update_time",
                                        Common.LocalDateTimeToUtcLong(GlobalStaticObj.CurrentDateTime).ToString()
                                    }
                                });
                        }
                        MessageBoxEx.Show(btnStatus.Caption + (flag ? "成功!" : "失败!"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        BindPageData();
                    }
                }
            };
            #endregion

            #region 根据选择的数据判断功能按钮的显示状态
            dgvQData.CellMouseUp += delegate
            {
                var dataView = GetSelectedRowData();
                var listField = GetCheckRows();
                btnStatus.Enabled = false;
                btnEdit.Enabled = false;
                btnDelete.Enabled = false;
                if (dataView == null || listField.Count == 0)
                {

                }
                else
                {
                    #region 编辑
                    if (listField.Count == 1)
                    {
                        btnEdit.Enabled = true;
                        btnDelete.Enabled = true;
                    }
                    #endregion

                    #region 启用/禁用
                    var qy = 0;
                    var jy = 0;
                    foreach (DataRowView rowView in dataView)   //启用/禁用
                    {
                        if (rowView["status"].ToString() == DbDic2Enum.SYS_DATA_STATUS_QI)
                        {
                            qy++;
                        }
                        else if (rowView["status"].ToString() == DbDic2Enum.SYS_DATA_STATUS_JIN)
                        {
                            jy++;
                        }
                    }
                    if (qy == 0 && jy != 0)
                    {
                        btnStatus.Enabled = true;
                        btnStatus.Caption = "启用";
                        btnStatus.Width = 60;
                    }
                    else if (qy != 0 && jy == 0)
                    {
                        btnStatus.Enabled = true;
                        btnStatus.Caption = "禁用";
                        btnStatus.Width = 60;
                    }
                    else
                    {
                        btnStatus.Enabled = false;
                        btnStatus.Caption = "启用/禁用";
                        btnStatus.Width = 90;
                    }
                    #endregion
                }
            };
            #endregion

            #endregion

            BindPageData();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 编辑联系人
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmiContactEdit_Click(object sender, EventArgs e)
        {
            if (oldcolcontindex > -1)
            {
                try
                {
                    DataGridViewRow dgvr = gvUserInfoList.Rows[oldcolcontindex];
                    frmContacts frm = new frmContacts();
                    DialogResult result = frm.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        string contID = frm.contID;
                        if (gvUserInfoList.Rows.Count > 0)
                        {
                            foreach (DataGridViewRow dr in gvUserInfoList.Rows)
                            {
                                if (dr.Cells["colcont_id"].Value.ToString() == contID)
                                {
                                    MessageBoxEx.Show("该联系人已经存在与列表中,不能再次添加!");
                                    return;
                                }
                            }
                        }

                        DataTable dt = GetContacts(contID);
                        foreach (DataRow dr in dt.Rows)
                        {
                            dgvr.Cells["colcont_id"].Value = dr["cont_id"];
                            dgvr.Cells["colis_default"].Value = "0";
                            dgvr.Cells["colcont_name"].Value = dr["cont_name"];
                            dgvr.Cells["colcont_post"].Value = dr["con_post_name"];
                            dgvr.Cells["colcont_phone"].Value = dr["phone"];
                            dgvr.Cells["colcont_tel"].Value = dr["cont_tel"];
                            dgvr.Cells["colremark"].Value = dr["remark"];
                            dgvr.Cells["colcont_email"].Value = dr["cont_email"];
                            string createTime = CommonCtrl.IsNullToString(dr["cont_birthday"]);
                            if (createTime.Length > 0)
                            {
                                dgvr.Cells["colcont_birthday"].Value = DateTime.MinValue.AddTicks(Convert.ToInt64(createTime)).ToLocalTime();
                            }
                        }
                    }
                }
                catch (Exception ex)
                { }
                finally
                { oldcolcontindex = -1; }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 选择联系人
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtcontacts_ChooserClick(object sender, EventArgs e)
 {
     frmContacts ChooseContact = new frmContacts();
     ChooseContact.ShowDialog();
     if (!string.IsNullOrEmpty(ChooseContact.contID))
     {
         txtcontacts.Text = ChooseContact.contName;
     }
 }
Ejemplo n.º 5
0
        //初始化
        private void Init()
        {
            dgvQData.MultiSelect = false;    //不允许多选操作

            SetUCBaseFuncationVisible();

            #region 初始化时间控件值
            dtpCBSTime.Value = DateTime.Now.AddMonths(-1);
            dtpCBETime.Value = DateTime.Now.AddDays(+1);
            #endregion

            #region 初始化下拉框数据绑定
            CommonCtrl.BindComboBoxByDictionarr(cboCBType, "sys_callback_type", true);    //绑定反馈类型
            CommonCtrl.BindComboBoxByDictionarr(cboCBMode, "sys_callback_mode", true);    //绑定反馈方式
            #endregion

            #region 注册功能按钮事件
            #region 清除查询条件
            btnClear.Click += delegate 
            {
                txtCBTitle.Caption = String.Empty;
                cboCBType.SelectedValue = String.Empty;
                cboCBMode.SelectedValue = String.Empty;
                dtpCBSTime.Value = DateTime.Now.AddMonths(-1);
                dtpCBETime.Value = DateTime.Now;
                txtCustomerName.Text = String.Empty;
                txtCBPerson.Text = String.Empty;
            };
            #endregion

            #region 查询
            btnQuery.Click += delegate
            {
                BindPageData();
            };
            #endregion

            #region 选择客户信息
            txtCustomerName.ChooserClick += delegate 
            {
                var frmCustomer = new frmCustomerInfo();
                var result = frmCustomer.ShowDialog();
                if (result == DialogResult.OK)
                {
                    txtCustomerName.Text = frmCustomer.strCustomerName;
                    txtCustomerName.Tag = frmCustomer.strCustomerId;
                }
            };
            #endregion

            #region 选择反馈人
            txtCBPerson.ChooserClick += delegate
            {
                var frmContacts= new frmContacts();
                var result = frmContacts.ShowDialog();
                if (result == DialogResult.OK)
                {
                    txtCBPerson.Text = frmContacts.contName;
                    txtCBPerson.Tag = frmContacts.contID;
                }
            };
            #endregion

            #region 数据翻页
            pageQ.PageIndexChanged += delegate
            {
                BindPageData();
            };
            #endregion

            #region 数据表数据选择
            dgvQData.CellDoubleClick += delegate
            {
                if (dgvQData.SelectedRows.Count > 0)
                {
                    var uc = new UCFeedbackAddOrEdit();
                    uc.OpType = WindowStatus.View;
                    uc.UCFeedbakcManager = this;
                    var selectedData = dgvQData.SelectedRows[0];
                    uc.FeedbackId = selectedData.Cells["drtxt_Feedback_id"].Value.ToString();
                    var callbackInfo = DBHelper.GetTable("查询反馈信息", "tb_CustomerSer_Feedback", "*",
                        "Feedback_id = '" + uc.FeedbackId + "'", "",
                        "");
                    if (callbackInfo != null && callbackInfo.DefaultView.Count != 0)
                    {
                        uc.CustId = callbackInfo.DefaultView[0]["corp_id"].ToString();
                        uc.ContId = callbackInfo.DefaultView[0]["Feedback_by"].ToString();
                        uc.HandleId = callbackInfo.DefaultView[0]["handle_name"].ToString();
                    }
                    uc.addUserControl(uc, "信息反馈-详细", "UCFeedbackView", Tag.ToString(), Name);
                }
            };
            #endregion

            #region 数据表格数据格式化
            dgvQData.CellFormatting += delegate(object sender, DataGridViewCellFormattingEventArgs args)
            {
                UIAssistants.DgvCellDataConvert2Table(dgvQData, args, "Feedback_by", "tb_contacts", "cont_id", "cont_name");
                UIAssistants.DgvCellDataConvert2Table(dgvQData, args, "handle_name", "sys_user", "user_id", "user_name");
                UIAssistants.DgvCellDataConvert2Table(dgvQData, args, "corp_id", "tb_customer", "cust_id", "cust_name");
                UIAssistants.DgvCellDataConvert2Datetime(dgvQData, args, "Feedback_time");
                UIAssistants.DgvCellDataConvert2DicData(dgvQData, args, "Feedback_type");    //反馈类型
                UIAssistants.DgvCellDataConvert2DicData(dgvQData, args, "Feedback_mode");    //反馈形式
            };
            #endregion

            #region 新增数据
            AddEvent += delegate
            {
                var uc = new UCFeedbackAddOrEdit();
                uc.UCFeedbakcManager = this;
                uc.OpType = WindowStatus.Add;
                uc.addUserControl(uc, "信息反馈-新增", "UCFeedbackAdd", Tag.ToString(), Name);
            };
            #endregion

            #region 编辑数据
            EditEvent += delegate
            {
                if (dgvQData.SelectedRows.Count > 0)
                {
                    var uc = new UCFeedbackAddOrEdit();
                    uc.OpType = WindowStatus.Edit;
                    uc.UCFeedbakcManager = this;
                    var selectedData = dgvQData.SelectedRows[0];
                    uc.FeedbackId = selectedData.Cells["drtxt_Feedback_id"].Value.ToString();
                    var callbackInfo = DBHelper.GetTable("查询反馈信息", "tb_CustomerSer_Feedback", "*",
                        "Feedback_id = '" + uc.FeedbackId + "'", "",
                        "");
                    if (callbackInfo != null && callbackInfo.DefaultView.Count != 0)
                    {
                        uc.CustId = callbackInfo.DefaultView[0]["corp_id"].ToString();
                        uc.ContId = callbackInfo.DefaultView[0]["Feedback_by"].ToString();
                        uc.HandleId = callbackInfo.DefaultView[0]["handle_name"].ToString();
                    }
                    uc.addUserControl(uc, "信息反馈-编辑", "UCFeedbackEdit", Tag.ToString(), Name);
                }
                BindPageData("1=1");
            };
            #endregion

            #region 删除数据
            DeleteEvent += delegate
            {
                try
                {
                    if (dgvQData.SelectedRows.Count == 0)
                    {
                        MessageBoxEx.Show("请选择删除记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    var listField = (from DataGridViewRow selectedRow in dgvQData.SelectedRows select selectedRow.Cells["drtxt_Feedback_id"].Value.ToString()).ToList();

                    var result = MessageBoxEx.Show("此操作将永久删除选定信息。\n若要继续,请单击“确定”。", "您确认要删除此条信息吗?", MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Warning);
                    if (result == DialogResult.OK)
                    {
                        var flag = DBHelper.DeleteDataByID("删除反馈信息", "tb_CustomerSer_Feedback", "Feedback_id", listField[0]);
                        if (flag)
                        {
                            BindPageData();
                            MessageBoxEx.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            BindPageData();
                        }
                        else
                        {
                            MessageBoxEx.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBoxEx.Show("删除失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                BindPageData("1=1");
            };
            #endregion

            #region 根据选择的数据判断功能按钮的显示状态
            dgvQData.CellMouseUp += delegate
            {
                var dataView = GetSelectedRowData();
                var listField = GetCheckRows();
                btnStatus.Enabled = false;
                btnEdit.Enabled = false;
                btnDelete.Enabled = false;
                if (dataView == null || listField.Count == 0)
                {

                }
                else
                {
                    #region 编辑
                    if (listField.Count == 1)
                    {
                        btnEdit.Enabled = true;
                        btnDelete.Enabled = true;
                    }
                    #endregion
                }
            };
            #endregion

            #endregion

            BindPageData();
        }
Ejemplo n.º 6
0
        private void InitDataGridCellFormatting()   //初始化数据表格
        {
            try
            {
                dgvVehicle.CellFormatting += delegate(object sender, DataGridViewCellFormattingEventArgs args)
                {
                    UIAssistants.DgvCellDataConvert2DicData(dgvVehicle, args, "v_brand");
                    UIAssistants.DgvCellDataConvert2DicData(dgvVehicle, args, "v_model");
                };

                #region 车辆信息
                dgvVehicle.ReadOnly = false;
                dgvVehicle.Rows.Add(3);
                dgvVehicle.AllowUserToAddRows = true;
                tb_vehicle_license_plate.ReadOnly = true;
                tb_vehicle_remark.ReadOnly = true;
                tb_vehicle_v_brand.ReadOnly = true;
                tb_vehicle_v_id.ReadOnly = true;
                tb_vehicle_v_model.ReadOnly = true;
                tb_vehicle_vin.ReadOnly = true;

                dgvVehicle.CellClick += delegate(object sender, DataGridViewCellEventArgs args)
                {
                    if (args.ColumnIndex < 0) return;
                    //if (dgvVehicle.Columns[args.ColumnIndex] != tb_vehicle_license_plate) return;
                    var chooser = new frmVehicleGrade();
                    var result = chooser.ShowDialog();
                    if (result != DialogResult.OK) return;
                    var strId = chooser.strLicensePlate;
                    var dpt = DBHelper.GetTable("查询车辆档案信息", "tb_vehicle", "*", " license_plate='" + strId + "'", "", "");
                    if (dpt.Rows.Count <= 0) return;
                    var dpr = dpt.Rows[0];
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_license_plate"].Value = CommonCtrl.IsNullToString(dpr["license_plate"]);
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_remark"].Value = CommonCtrl.IsNullToString(dpr["remark"]);
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_v_brand"].Value = CommonCtrl.IsNullToString(dpr["v_brand"]);
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_v_id"].Value = CommonCtrl.IsNullToString(dpr["v_id"]);
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_v_model"].Value = CommonCtrl.IsNullToString(dpr["v_model"]);
                    dgvVehicle.Rows[args.RowIndex].Cells["tb_vehicle_vin"].Value = CommonCtrl.IsNullToString(dpr["vin"]);
                };
                #endregion

                #region 联系人信息
                dgvcontacts.CellFormatting += delegate(object sender, DataGridViewCellFormattingEventArgs args)
                {
                    UIAssistants.DgvCellDataConvert2DicData(dgvcontacts, args, "cont_post");
                    UIAssistants.DgvCellDataConvert2Datetime(dgvcontacts, args, "cont_birthday");
                };

                dgvcontacts.ReadOnly = false;
                dgvcontacts.Rows.Add(3);
                dgvcontacts.AllowUserToAddRows = true;
                cont_name.ReadOnly = true;
                cont_post.ReadOnly = true;
                cont_phone.ReadOnly = true;
                cont_tel.ReadOnly = true;
                cont_birthday.ReadOnly = true;
                cont_email.ReadOnly = true;
                is_default.ReadOnly = false;
                remark.ReadOnly = true;

                dgvcontacts.CellContentClick += delegate(object sender, DataGridViewCellEventArgs e)
                {
                    if (e.RowIndex > -1 && e.ColumnIndex > -1)//双击表头或列头时不起作用   
                    {
                        //获取控件的值
                        for (int i = 0; i < dgvcontacts.Rows.Count; i++)
                        {
                            dgvcontacts.Rows[i].Cells["is_default"].Value = "0";
                        }
                        dgvcontacts.Rows[e.RowIndex].Cells["is_default"].Value = "1";
                    }
                };

                dgvcontacts.CellClick += delegate(object sender, DataGridViewCellEventArgs args)
                {
                    if (args.ColumnIndex < 0 || args.RowIndex < 0) return;
                    if (dgvcontacts.Columns[args.ColumnIndex] != cont_name) return;
                     var frmPart = new frmContacts();
                    var result = frmPart.ShowDialog();
                    if (result != DialogResult.OK) return;
                    var strId = frmPart.contID;
                    var dpt = DBHelper.GetTable("查询联系人信息", "v_contacts", string.Format("*,{0} phone ,{1} tel", EncryptByDB.GetDesFieldValue("cont_phone"), EncryptByDB.GetDesFieldValue("cont_tel")), " cont_id='" + strId + "'", "", "");
                    if (dpt.Rows.Count <= 0) return;
                    var dpr = dpt.Rows[0];
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_id"].Value = CommonCtrl.IsNullToString(dpr["cont_id"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_name"].Value = CommonCtrl.IsNullToString(dpr["cont_name"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_post"].Value = CommonCtrl.IsNullToString(dpr["cont_post_name"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_phone"].Value = CommonCtrl.IsNullToString(dpr["phone"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_tel"].Value = CommonCtrl.IsNullToString(dpr["tel"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_birthday"].Value = CommonCtrl.IsNullToString(dpr["cont_birthday"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["cont_email"].Value = CommonCtrl.IsNullToString(dpr["cont_email"]);
                    dgvcontacts.Rows[args.RowIndex].Cells["is_default"].Value = "0";
                    dgvcontacts.Rows[args.RowIndex].Cells["remark"].Value = CommonCtrl.IsNullToString(dpr["remark"]);
                };
                #endregion
            }
            catch (Exception)
            {

            }
        }
Ejemplo n.º 7
0
 private void addUser_Click(object sender, EventArgs e)
 {
     frmContacts contact = new frmContacts();
     DialogResult result = contact.ShowDialog();
     if (result == DialogResult.OK)
     {
         DataTable dut = DBHelper.GetTable("获取联系人(司机)", "tb_contacts", string.Format("*,{0} phone, {1} tel,{2} email", EncryptByDB.GetDesFieldValue("cont_phone"), EncryptByDB.GetDesFieldValue("cont_tel"), EncryptByDB.GetDesFieldValue("cont_email")), "cont_id='" + contact.contID + "'", "", " order by cont_id desc");
         if (dut.Rows.Count > 0)
         {
             DataRow dpr = dut.Rows[0];
             if (listUser.Contains(CommonCtrl.IsNullToString(dpr["cont_name"])))
             {
                 MessageBoxEx.Show("此司机信息已存在,请选择其他司机", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
             dgvUser.CurrentRow.Cells["cont_name"].Value = CommonCtrl.IsNullToString(dpr["cont_name"]);
             dgvUser.CurrentRow.Cells["cont_post"].Value = GetDicName(CommonCtrl.IsNullToString(dpr["cont_post"]));
             dgvUser.CurrentRow.Cells["cont_phone"].Value = CommonCtrl.IsNullToString(dpr["phone"]);
             dgvUser.CurrentRow.Cells["cont_tel"].Value = CommonCtrl.IsNullToString(dpr["tel"]);
             dgvUser.CurrentRow.Cells["cont_email"].Value = CommonCtrl.IsNullToString(dpr["email"]);
             dgvUser.CurrentRow.Cells["cont_birthday"].Value = !string.IsNullOrEmpty(CommonCtrl.IsNullToString(dpr["cont_birthday"])) ? Common.UtcLongToLocalDateTime(Convert.ToInt64(CommonCtrl.IsNullToString(dpr["cont_birthday"]))).ToString() : "";
             dgvUser.CurrentRow.Cells["remark"].Value = CommonCtrl.IsNullToString(dpr["remark"]);
             dgvUser.CurrentRow.Cells["cont_id"].Value = CommonCtrl.IsNullToString(dpr["cont_id"]);
             dgvUser.Rows.Add(1);
             listUser.Add(CommonCtrl.IsNullToString(dpr["cont_name"]));
         }
     }
 }
Ejemplo n.º 8
0
 private void dgvUser_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     frmContacts contact = new frmContacts();
     DialogResult result = contact.ShowDialog();
     if (result == DialogResult.OK)
     {
         DataTable dut = DBHelper.GetTable("获取联系人(司机)", "tb_contacts", "*", "cont_id='" + contact.contID + "'", "", " order by cont_id desc");
         if (dut.Rows.Count > 0)
         {
             DataRow dpr = dut.Rows[0];
             dgvUser.Rows[e.RowIndex].Cells["cont_name"].Value = CommonCtrl.IsNullToString(dpr["cont_name"]);
             dgvUser.Rows[e.RowIndex].Cells["cont_post"].Value = GetDicName(CommonCtrl.IsNullToString(dpr["cont_post"]));
             dgvUser.Rows[e.RowIndex].Cells["cont_phone"].Value = CommonCtrl.IsNullToString(dpr["cont_phone"]);
             dgvUser.Rows[e.RowIndex].Cells["cont_tel"].Value = CommonCtrl.IsNullToString(dpr["cont_tel"]);
             dgvUser.Rows[e.RowIndex].Cells["cont_email"].Value = CommonCtrl.IsNullToString(dpr["cont_email"]);
             dgvUser.Rows[e.RowIndex].Cells["cont_birthday"].Value = !string.IsNullOrEmpty(CommonCtrl.IsNullToString(dpr["cont_birthday"])) ? Common.UtcLongToLocalDateTime(Convert.ToInt64(CommonCtrl.IsNullToString(dpr["cont_birthday"]))).ToString() : "";
             dgvUser.Rows[e.RowIndex].Cells["remark"].Value = CommonCtrl.IsNullToString(dpr["remark"]);
             dgvUser.Rows[e.RowIndex].Cells["cont_id"].Value = CommonCtrl.IsNullToString(dpr["cont_id"]);
             dgvUser.Rows.Add(1);
         }
     }
 }
Ejemplo n.º 9
0
        //初始化
        private void Init()
        {
            #region 设置功能按钮可见性
            UIAssistants.SetUCBaseFuncationVisible(this, new ObservableCollection<ButtonEx_sms>()
            {
                btnSave, btnCancel, btnSet, btnView, btnPrint
            });
            #endregion

            #region 初始化下拉框数据绑定
            CommonCtrl.CmbBindDict(cbo_cb_Callback_type, "sys_callback_type", false);    //绑定回访类型
            CommonCtrl.CmbBindDict(cbo_cb_Callback_mode, "sys_callback_mode", false);    //绑定回访方式
            CommonCtrl.CmbBindDict(cbo_member_class, "sys_member_grade", false);    //绑定会员等级
            CommonFuncCall.BindProviceComBox(cbo_province, "请选择");  //绑定省份
            CommonFuncCall.BindCityComBox(cbo_city, "", "请选择");   //绑定城市
            CommonFuncCall.BindCountryComBox(cbo_county, "", "请选择");    //绑定县/区
            cbo_province.SelectedIndexChanged += ddlprovince_SelectedIndexChanged;
            cbo_city.SelectedIndexChanged += ddlcity_SelectedIndexChanged;
            CommonCtrl.CmbBindDict(cbo_cust_type, "sys_customer_category", false);  //客户类别
            #endregion

            lbl_cb_create_by.Text = GlobalStaticObj.CurrUserCom_Name;
            lbl_cb_create_by.Tag = GlobalStaticObj.UserID;
            if (windowStatus == WindowStatus.Edit || windowStatus == WindowStatus.View)
            {
                SetCustInfo();
                SetContInfo();
                SetCallbackInfo();
            }
            if (windowStatus == WindowStatus.View) palQTop.Enabled = false;
            #region 注册功能按钮事件
            #region 选择客户信息
            txt_cust_code.ChooserClick += delegate
            {
                var frmCustomer = new frmCustomerInfo();
                var result = frmCustomer.ShowDialog();
                if (result == DialogResult.OK)
                {
                    CustId = frmCustomer.strCustomerId;
                    txt_cust_code.Tag = CustId;
                    txt_cust_code.Text = frmCustomer.strCustomerNo;
                    SetCustInfo();
                }
            };
            dataGridViewEx1.CellContentClick += delegate(object sender, DataGridViewCellEventArgs args)
            {
                if (args.ColumnIndex < 0 || args.RowIndex < 0) return;
                if (dataGridViewEx1.Columns[args.ColumnIndex] == drtxt_maintain_no)
                {
                    var ytServiceNo = CommonCtrl.IsNullToString(dataGridViewEx1.Rows[args.RowIndex].Cells[drtxt_maintain_id.Name].Value);
                    if (String.IsNullOrEmpty(CommonCtrl.IsNullToString(ytServiceNo))) return;
                    var uc = new RepairQueryView(ytServiceNo);
                    uc.addUserControl(uc, "维修单-详细信息", "RepairQueryView" + ytServiceNo, Tag.ToString(),
                        Name);
                }
            };
            #endregion

            #region 选择被回访人
            txt_cb_Callback_by.ChooserClick += delegate
            {
                var frmContacts = new frmContacts();
                var result = frmContacts.ShowDialog();
                if (result == DialogResult.OK)
                {
                    ContId = frmContacts.contID;
                    txt_cb_Callback_by.Tag = ContId;
                    txt_cb_Callback_by.Text = frmContacts.contName;
                    txt_cb_Callback_by_duty.Caption = frmContacts.contDuty;
                    txt_cb_Callback_by_phone.Caption = frmContacts.contPhone;
                }
            };
            #endregion

            #region 选择经办人
            txt_handle_name.ChooserClick += delegate
            {
                var chooser = new frmUsers();
                var result = chooser.ShowDialog();
                if (result == DialogResult.OK)
                {
                    txt_handle_name.Text = chooser.User_Name;
                    txt_handle_name.Tag = chooser.User_ID;
                    txt_cb_handle_org.Caption = chooser.OrgName;
                }
            };
            #endregion

            //CancelEvent += (sender, args) => deleteMenuByTag(Tag.ToString(), UCCallBackManager.Name);
            CancelEvent += new ClickHandler(UCCallBackAddOrEdit_CancelEvent);

            #region 保存数据
            SaveEvent += delegate
            {
                var check = CheckValue();
                if (!check) return;
                var dicFileds = new Dictionary<String, String>();
                if (windowStatus == WindowStatus.Add)
                {
                    dicFileds.Add("create_by", GlobalStaticObj.UserID);  //创建人
                    dicFileds.Add("create_time", DBHelper.GetCurrentTime().Ticks.ToString());    //创建时间
                    dicFileds.Add("update_by", GlobalStaticObj.UserID);  //最后编辑人
                    dicFileds.Add("update_time", DBHelper.GetCurrentTime().Ticks.ToString());    //最后编辑时间
                    dicFileds.Add("Callback_id", Guid.NewGuid().ToString());  //客户ID
                    dicFileds.Add("status", "58b325d2-0792-4847-8e4a-22b3f25628f3");   //数据状态
                }
                else if (windowStatus == WindowStatus.Edit)
                {
                    DBHelper.BatchDeleteDataByWhere("删除客户与维修单关系", "tr_maintain_customer_callback", String.Format("callback_id = '{0}'", CallBackId));
                    dicFileds.Add("update_by", GlobalStaticObj.UserID);  //最后编辑人
                    dicFileds.Add("update_time", DBHelper.GetCurrentTime().Ticks.ToString());    //最后编辑时间
                }
                dicFileds.Add("Callback_corp", txt_cust_code.Tag.ToString());  //客户ID
                dicFileds.Add("Callback_time", DBHelper.GetCurrentTime().Ticks.ToString());   //回访时间
                dicFileds.Add("Callback_type", cbo_cb_Callback_type.SelectedValue.ToString()); //回访类型
                dicFileds.Add("Callback_mode", cbo_cb_Callback_mode.SelectedValue.ToString()); //回访方式
                dicFileds.Add("title",txt_cb_title.Caption);    //回访标题
                dicFileds.Add("record", rtx_cb_record.Text);    //回访内容
                dicFileds.Add("Callback_by", txt_cb_Callback_by.Tag.ToString());  //被回访人员名称
                dicFileds.Add("Callback_by_org", txt_cb_Callback_by_org.Caption);   //被回访人员部门名称
                dicFileds.Add("Callback_by_phone", txt_cb_Callback_by_phone.Caption);   //被回访人电话
                dicFileds.Add("Callback_by_duty", txt_cb_Callback_by_duty.Caption); //被回访人职务
                dicFileds.Add("handle_name", txt_handle_name.Tag.ToString());    //经办人
                dicFileds.Add("handle_org", txt_cb_handle_org.Caption); //经办人部门名称
                var result = false;
                try
                {
                    result = DBHelper.Submit_AddOrEdit("保存客户回访", "tb_CustomerSer_Callback", "Callback_id", CallBackId, dicFileds);
                    if (result)
                    {
                        const string sqlStr = "INSERT INTO tr_maintain_customer_callback(id,maintain_id,customer_id ,callback_id) VALUES(@id,@maintain_id,@customer_id,@callback_id)";
                        var list = GetCheckRows();
                        var sysSqlStrList = list.Select(str => new SysSQLString
                        {
                            cmdType = CommandType.Text, sqlString = sqlStr, Param = new Dictionary<string, string>
                            {
                                {"@id", Guid.NewGuid().ToString()}, {"@maintain_id", str}, {"@customer_id", txt_cust_code.Tag.ToString()}, {"@callback_id", String.IsNullOrEmpty(CallBackId) ? dicFileds["Callback_id"] : CallBackId}
                            }
                        }).ToList();
                        DBHelper.BatchExeSQLStringMultiByTrans("添加客户与维修单关系", sysSqlStrList);
                    }
                }
                catch (Exception ex)
                {
                    result = false;
                }
                MessageBoxEx.Show(result ? "保存成功!" : "保存失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                if (result)
                {
                    UCCallBackManager.BindPageData();
                    _autoClose = false;
                    deleteMenuByTag(Tag.ToString(), UCCallBackManager.Name);
                }
            };
            #endregion
            #endregion
        }