/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { MSGMain MasterEntity = (MSGMain)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM SMS_MSGMain WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(Sql); } else { AffectedRows = sqlTrans.ExecuteNonQuery(Sql); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBDelete), E); } }
private void btnSend_Click(object sender, EventArgs e) { try { if (HTDataID == 0) { this.ShowMessage("请保存数据后发送短信息!"); return; } if (txtRecPhone.Text.Trim() == "") { this.ShowMessage("请输入收件人号码后点击发送短信息!"); return; } if (txtRecPhone.Text.Trim().Length != 11) { this.ShowMessage("请输入正确的收件人号码后点击发送短信息!"); return; } if (!FCommon.RightCheck(this.FormID, this.RightFormID, this.FormListAID, this.FormListBID, RightSub.权限2)) { this.ShowMessage("没有此权限,请联系管理员"); return; } MSGMainRule rule = new MSGMainRule(); MSGMain entity = new MSGMain(); entity.FormDate = DateTime.Now; entity.InsertTime = DateTime.Now; entity.MSGSourceID = (int)EnumMSGSource.快递单; entity.SendPhone = "13916054226"; entity.TargetPhone = txtRecPhone.Text.Trim(); entity.TaregtInfo = txtRecName.Text.Trim(); entity.SendTime = DateTime.Now; string Context = ""; Context += "尊敬的客户:您好!您的快递已寄出,快递公司:"; Context += Common.GetVendorNameByVendorID(drpPostComID.EditValue.ToString()); Context += ",快递单号:"; Context += txtPostCode.Text.Trim(); Context += "请注意查收,如有疑问请来电021-51095188. 上海德奕纺织品有限公司"; entity.Context = Context; entity.SendDesc = "来源:快递管理,单号:" + txtFormNo.Text.Trim() + ",收货单位:" + Common.GetVendorNameByVendorID(drpVendorID.EditValue.ToString()); entity.SendInfo += ",发件人:" + txtFJR.Text.Trim(); entity.DID = HTDataID; rule.RAdd(entity); this.ShowInfoMessage("发送成功!"); lbSendShow.Text = "已发送"; } catch (Exception E) { this.ShowMessage(E.Message); } }
/// <summary> /// 检验字段值是否已存在 /// </summary> /// <param name="p_TableName">表名</param> /// <param name="p_FieldName">字段名</param> /// <param name="p_FieldValue">字段值</param> /// <param name="p_KeyField">主键(只考虑主键为ID的情况)</param> /// <param name="p_KeyValue">主键值</param> /// <param name="p_sqlTrans"></param> /// <returns></returns> private bool CheckFieldValueIsExist(BaseEntity p_BE, string p_FieldName, string p_FieldValue, IDBTransAccess p_sqlTrans) { MSGMain entity = (MSGMain)p_BE; bool ret = false; string sql = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, MSGMain.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID); DataTable dt = p_sqlTrans.Fill(sql); if (dt.Rows.Count != 0) { ret = true; } return(ret); }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); MSGMain entity = (MSGMain)p_BE; MSGMainCtl control = new MSGMainCtl(sqlTrans); control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 增加 /// </summary> private void RAddNews() { string sql = "SELECT InSaleOP FROM Data_Vendor WHERE VendorID=" + SysString.ToDBString(drpVendorID.EditValue.ToString()); DataTable dt = SysUtils.Fill(sql); if (dt.Rows.Count > 0) { string OPID = SysConvert.ToString(dt.Rows[0][0]); if (OPID != string.Empty) { sql = "SELECT OPName,Phone FROM Data_OP WHERE OPID=" + SysString.ToDBString(OPID); dt = SysUtils.Fill(sql); if (dt.Rows.Count > 0) { string tel = SysConvert.ToString(dt.Rows[0]["Phone"]); if (tel.Length == 11) { MSGMainRule rule = new MSGMainRule(); MSGMain entity = new MSGMain(); entity.FormDate = DateTime.Now; entity.InsertTime = DateTime.Now; entity.MSGSourceID = (int)EnumMSGSource.收付款; entity.SendPhone = "13916054226"; entity.TargetPhone = tel; entity.TaregtInfo = SysConvert.ToString(dt.Rows[0]["OPName"]); entity.SendTime = DateTime.Now; string Context = ""; Context += entity.TaregtInfo + "你好!"; Context += Common.GetVendorNameByVendorID(drpVendorID.EditValue.ToString()); Context += "已来款,来款金额是:"; Context += txtExAmount.Text.Trim(); Context += "请查看 上海德奕纺织品有限公司"; entity.Context = Context; entity.SendDesc = "来源:收付款,单号:" + txtFormNo.Text.Trim(); entity.SendInfo += ",发件人:上海德奕纺织品有限公司"; entity.DID = HTDataID; rule.RAdd(entity); this.ShowInfoMessage("短信已发送给业务员!"); } } } } }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); MSGMain entity = (MSGMain)p_BE; MSGMainCtl control = new MSGMainCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.SMS_MSGMain, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
//private void txtMesMakeOPID_SelectedIndexChanged(object sender, EventArgs e) //{ // try // { // string sql = "SELECT Phone FROM Data_MsgPhone WHERE Name =" + SysString.ToDBString(txtMesMakeOPID.Text.Trim()); // DataTable dt = new DataTable(); // dt = SysUtils.Fill(sql); // if (dt.Rows.Count != 0) // { // txtMesPhone.Text = SysConvert.ToString(dt.Rows[0]["Phone"]); // } // } // catch (Exception E) // { // this.ShowMessage(E.Message); // } //} #region 发送和取消 private void btnSend_Click(object sender, EventArgs e) { try { if (HTDataID == 0) { this.ShowMessage("请保存数据后发送短信息!"); return; } MSGMainRule rule = new MSGMainRule(); MSGMain entity = new MSGMain(); for (int i = 0; i < gridView1.RowCount; i++) { entity.FormDate = DateTime.Now; entity.InsertTime = DateTime.Now; entity.MSGSourceID = (int)EnumMSGSource.自定义; entity.SendPhone = "13916054226"; entity.TaregtInfo = SysConvert.ToString(gridView1.GetRowCellValue(i, "MesMakeOPIDDts")); entity.TargetPhone = SysConvert.ToString(gridView1.GetRowCellValue(i, "MesPhoneDts")); //entity.TargetPhone = txtMesPhone.Text.Trim(); //entity.TaregtInfo = txtMesMakeOPID.Text.Trim(); entity.SendTime = DateTime.Now; entity.Context = txtContext.Text.Trim(); entity.SendDesc = "来源:自定义发送"; entity.SendInfo += ",发件人:" + txtTargetOPID.Text.Trim(); entity.DID = HTDataID; rule.RAdd(entity); } this.ShowInfoMessage("发送成功!"); lbSendShow.Text = "已发送"; } catch (Exception E) { this.ShowMessage(E.Message); } }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { MSGMain MasterEntity = (MSGMain)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO SMS_MSGMain("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("FormNo" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.FormNo) + ","); MasterField.Append("FormDate" + ","); if (MasterEntity.FormDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.FormDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("InsertTime" + ","); if (MasterEntity.InsertTime != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.InsertTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("MSGSourceID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MSGSourceID) + ","); MasterField.Append("Context" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Context) + ","); MasterField.Append("SendInfo" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SendInfo) + ","); MasterField.Append("SendDesc" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SendDesc) + ","); MasterField.Append("SendPhone" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SendPhone) + ","); MasterField.Append("TargetPhone" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.TargetPhone) + ","); MasterField.Append("TaregtInfo" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.TaregtInfo) + ","); MasterField.Append("TargetDesc" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.TargetDesc) + ","); MasterField.Append("SendTime" + ","); if (MasterEntity.SendTime != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.SendTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("SendFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SendFlag) + ","); MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("DID" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.DID) + ")"); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBInsert), E); } }
/// <summary> /// 修改 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { MSGMain MasterEntity = (MSGMain)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE SMS_MSGMain SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" FormNo=" + SysString.ToDBString(MasterEntity.FormNo) + ","); if (MasterEntity.FormDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" FormDate=" + SysString.ToDBString(MasterEntity.FormDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" FormDate=null,"); } if (MasterEntity.InsertTime != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" InsertTime=" + SysString.ToDBString(MasterEntity.InsertTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" InsertTime=null,"); } UpdateBuilder.Append(" MSGSourceID=" + SysString.ToDBString(MasterEntity.MSGSourceID) + ","); UpdateBuilder.Append(" Context=" + SysString.ToDBString(MasterEntity.Context) + ","); UpdateBuilder.Append(" SendInfo=" + SysString.ToDBString(MasterEntity.SendInfo) + ","); UpdateBuilder.Append(" SendDesc=" + SysString.ToDBString(MasterEntity.SendDesc) + ","); UpdateBuilder.Append(" SendPhone=" + SysString.ToDBString(MasterEntity.SendPhone) + ","); UpdateBuilder.Append(" TargetPhone=" + SysString.ToDBString(MasterEntity.TargetPhone) + ","); UpdateBuilder.Append(" TaregtInfo=" + SysString.ToDBString(MasterEntity.TaregtInfo) + ","); UpdateBuilder.Append(" TargetDesc=" + SysString.ToDBString(MasterEntity.TargetDesc) + ","); if (MasterEntity.SendTime != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" SendTime=" + SysString.ToDBString(MasterEntity.SendTime.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" SendTime=null,"); } UpdateBuilder.Append(" SendFlag=" + SysString.ToDBString(MasterEntity.SendFlag) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" DID=" + SysString.ToDBString(MasterEntity.DID)); UpdateBuilder.Append(" WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID)); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(UpdateBuilder.ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(UpdateBuilder.ToString()); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBUpdate), E); } }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { MSGMain entity = (MSGMain)p_BE; }