123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- using LYFZ.ComponentLibrary;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.SMSManagement
- {
- public partial class FrmSMSEmployees : LYFZ.Software.UI.SMSManagement.FrmSMSEmployees
- {
- private delegate void UpdateControl();
- public FrmSMSEmployees()
- {
- this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
- this.Shown+=FrmSMSEmployees_Shown;
- this.btnSelect.Click+=btnSelect_Click;
- this.btnAll.Click+=btnAll_Click;
- this.btnSmsSend.Click+=btnSmsSend_Click;
- this.btnClose.Click+=btnClose_Click;
- // dgv.CellValueChanged += dgv_CellValueChanged;
- this.buttonBind.Click += buttonBind_Click;
- #region 短信发送
- this.btnSendMicroMessage.Click += btnSendMicroMessage_Click;
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.SMSEmployeesCompetence, CustomAttributes.OperatingAuthority.SMSSend))
- {
- btnSmsSend.Enabled = true;
- this.btnSendMicroMessage.Enabled = true;
- }
- else
- {
- btnSmsSend.Enabled = false;
- this.btnSendMicroMessage.Enabled = false;
- }
- #endregion
- }
-
- /* void dgv_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex == 6)
- {
- string openID = this.dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
- this.dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Tag = openID;
- if (openID.Trim().Length > 0)
- {
- this.dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "已绑定";
- }
- else {
- this.dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = "";
- }
- }
- }*/
-
- void btnSendMicroMessage_Click(object sender, EventArgs e)
- {
- if (this.dgv.SelectedRows != null && this.dgv.SelectedRows.Count > 0)
- {
- LYFZ.Software.MainBusiness.SMSManagement.SmsSend.frmSendMicroTemplateSMS sendMicro = new SmsSend.frmSendMicroTemplateSMS();
- string openIDs = "";
- for (int i = 0; i < this.dgv.SelectedRows.Count; i++)
- {
- if (this.dgv.SelectedRows[i].Tag != null)
- {
- LYFZ.Model.BindWxOpenID bindOpenID = (LYFZ.Model.BindWxOpenID)this.dgv.SelectedRows[i].Tag;
- if (bindOpenID.OpenID.Trim().Length > 0 && !openIDs.Contains(bindOpenID.OpenID))
- {
- openIDs += bindOpenID.OpenID + ",";
- }
- }
- }
- sendMicro.IsEmployee = true;
- sendMicro.DfTemplateNo = EnumPublic.MicroTemplate.待办事项通知;
- sendMicro.ReceiveOPNIDs = openIDs.Trim(',');
- if (sendMicro.ReceiveOPNIDs.Trim().Length > 0)
- {
- sendMicro.ShowDialog();
- }
- else {
- MessageBoxCustom.Show("选择的员工没有绑定微信,不能发送微信消息");
- }
- }
- else
- {
- MessageBoxCustom.Show("请选择要发送消息的员工");
- }
- }
- #region 加载
- protected void FrmSMSEmployees_Shown(object sender, EventArgs e)
- {
- List<Control> hideControl = new List<Control>();
- List<Control> moveControl = new List<Control>();
- hideControl.Add(buttonBind);
- hideControl.Add(btnSendMicroMessage);
- moveControl.Add(btnAll);
- moveControl.Add(btnSmsSend);
- moveControl.Add(btnClose);
- //LYFZSS.SystemSpecterPossessed.ISystemSpecterPossessed.GetMySystemSpecter = LYFZSS.SystemSpecterType.SST_D;
- bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(
- VersionControl.VersionFunctionEnum.短信管理微信短信推送, hideControl, moveControl, null);
- try
- {
- modInterFace = bllInterface.GetModelMicroInterface(LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID);
- bind();
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- public void bind()
- {
- this.ucPagerEx1.PageCurrent = 1;
- this.ucPagerEx1.PageSize = 100;
- this.ucPagerEx1.Bind();
- }
- #endregion
- #region 查询
- protected void btnSelect_Click(object sender, EventArgs e)
- {
- try
- {
- selectOpenID = "";
- bind();
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- void buttonBind_Click(object sender, EventArgs e)
- {
- try
- {
- selectOpenID = " and len(User_OpenID)>0 ";
- bind();
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- #endregion
- #region 选中全部
- protected void btnAll_Click(object sender, EventArgs e)
- {
- if (dgv.Rows.Count > 0)
- {
- dgv.SelectAll();
- }
- }
- #endregion
- #region 短信发送
- protected void btnSmsSend_Click(object sender, EventArgs e)
- {
- if (dgv.SelectedRows==null||dgv.SelectedRows.Count == 0)
- {
- MessageBoxCustom.Show("请选择你要发送短信的员工!");
- return;
- }
- string Sj1 = "";
- string User_Telephone = "";
- LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms sendSms = new SmsSend.FrmSendSms();
- for (int i = 0; i < dgv.SelectedRows.Count; i++)
- {
- User_Telephone = dgv.SelectedRows[i].Cells["User_Telephone"].Value.ToString();
- //检查手机合法性
- if (!string.IsNullOrEmpty(User_Telephone))
- {
- string ret = LYFZ.WinAPI.CustomPublicMethod.ValidationPhones(User_Telephone);
- if (ret.Trim().Length <=0)
- {
- Sj1 += User_Telephone + ",";
- }
- else if (dgv.SelectedRows.Count==1)
- {
- MessageBoxCustom.Show("手机号无效:"+ret);
- return;
- }
- }
- }
- sendSms.Phone = Sj1.Trim(',');
- sendSms.ShowDialog();
- }
- #region 验证手机
- private bool CheckPhoneNumber(string number)
- {
- return System.Text.RegularExpressions.Regex.IsMatch(number, @"^(1[3,5,8][0-9])\d{8}$");
- }
- #endregion
- #endregion
- #region 关闭
- protected void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- #endregion
- #region 画分页
- BLL.BLL_ErpMicroInterface bllInterface = new BLL.BLL_ErpMicroInterface();
- LYFZ.Model.Model_ErpMicroInterface modInterFace = new Model.Model_ErpMicroInterface();
- LYFZ.BLL.BLL_CustomerAndWxOpen wxOPenBll = new BLL.BLL_CustomerAndWxOpen();
- List<LYFZ.Model.BindWxOpenID> wxOpenIDList = new List<LYFZ.Model.BindWxOpenID>();
- public List<LYFZ.Model.BindWxOpenID> WxOpenIDList
- {
- get {
- if (wxOpenIDList.Count <= 0)
- {
- if (modInterFace.AppID != null && modInterFace.AppID.Trim().Length > 0)
- {
- wxOpenIDList = wxOPenBll.GetWxOpenIdList(1, modInterFace.AppID.Trim());
- }
-
- }
- return wxOpenIDList; }
- }
- string selectOpenID = "";
- /// <summary>
- /// 画分页
- /// </summary>
- /// <param name="e"></param>
- /// <returns></returns>
- private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
- {
- LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
- dgv.DataSource = null;
- DataTable dt = new DataTable();
- StringBuilder str = new StringBuilder();
-
- if (!string.IsNullOrEmpty(txtKeyWords.Text))
- {
- str.Append(" User_DividedShop='"+LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID+"' and User_Status='在职' and 1=1 and (User_Name like '%" + txtKeyWords.Text + "%' or User_Telephone like '%" + txtKeyWords.Text + "%' or User_NowAddress like '%" + txtKeyWords.Text + "%') " + selectOpenID + " and id>1");
- }
- else
- {
- str.Append(" User_DividedShop='"+LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID+"' and User_Status='在职' and 1=1 and id>1 " + selectOpenID + "");
- }
- this.dgv.Rows.Clear();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
-
- pageData.TableName = "View_tb_ErpUser";
- pageData.PageIndex = this.ucPagerEx1.PageCurrent;
- pageData.PageSize = this.ucPagerEx1.PageSize;
- pageData.QueryCondition = str.ToString();
- // pageData.QueryFieldName = "ID,User_DividedShop,User_Account,User_Name,User_EmployeeID,User_Department,User_Positions,User_Competence,User_Sex,User_Status,User_Ethnic,User_Hometown,User_NowAddress,User_HometownAddress,User_IsMarried ,User_ICQAccount,User_Email,User_Attachment,User_CreateDatetime,User_UpdateDatetime,User_SubordinateList,User_Telephone,Dt_Name,User_IsMarriedName,User_DateOfBirthTime,User_DateOfBirth,User_BirthdayLunar,User_OpenID ";
- pageData.QueryFieldName = "ID,User_DividedShop,User_Account,User_Name,User_EmployeeID,User_Department,User_Sex,User_Status,User_Telephone,Dt_Name,User_NowAddress,User_DateOfBirthTime,User_DateOfBirth,User_BirthdayLunar,User_OpenID ";
- pageData.OrderStr = " ID desc ";
- DataSet da = pageData.QueryDataTable();
- dt = da.Tables[0];
- try
- {
- if (this.WxOpenIDList.Count > 0)
- {
- //预加载
- }
- }
- catch { }
- });
- for (int t = 0; t < dt.Rows.Count; t++)
- {
- DataRow drow=dt.Rows[t];
- DataGridViewRow row = new DataGridViewRow();
- row.CreateCells(this.dgv);
- string User_EmployeeID=drow["User_EmployeeID"].ToString();
- row.Cells[0].Value = User_EmployeeID;
- row.Cells[1].Value = drow["User_Name"];
- row.Cells[2].Value = drow["Dt_Name"];
- row.Cells[3].Value = drow["User_Sex"];
- row.Cells[4].Value = drow["User_Telephone"];
- row.Cells[5].Value = drow["User_NowAddress"];
- row.Cells[6].Value = "";
- string oldOpenID = "";
- if (drow["User_OpenID"] != null && drow["User_OpenID"].ToString().Trim().Length > 0)
- {
- oldOpenID = drow["User_OpenID"].ToString().Trim();
- }
- if (this.WxOpenIDList.Any(s => s.UID.ToLower() == User_EmployeeID.ToLower()))
- {
- row.Cells[6].Value = "已绑定";
- row.Tag = this.WxOpenIDList.Find(s => s.UID.ToLower() == User_EmployeeID.ToLower());
- }
- else if (drow["User_DividedShop"].ToString() == "SSN001" && LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID == "SSN001" && oldOpenID.Trim().Length > 0)
- {
- row.Cells[6].Value = "已绑定";
- LYFZ.Model.BindWxOpenID oldBindID = new Model.BindWxOpenID();
- oldBindID.OpenID = oldOpenID;
- oldBindID.UID = User_EmployeeID;
- oldBindID.APPID = modInterFace.AppID.Trim();
- row.Tag = oldBindID;
- }
-
-
- dgv.Rows.Add(row);
- dgv.ClearSelection();
- }
- try
- {
- this.ucPagerEx1.TbDataSource = dt;
- }
- catch { }
- return pageData.TotalCount;
- }
- #endregion
- }
- }
|