/// <summary> /// 删除 /// </summary> public override void EntityDelete() { PaymentHandleRule rule = new PaymentHandleRule(); PaymentHandle entity = EntityGet(); rule.RDelete(entity); }
/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { PaymentHandle MasterEntity = (PaymentHandle)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Finance_PaymentHandle 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); } }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RSave(string p_OrderFormNo, BaseEntity[] p_BE, IDBTransAccess sqlTrans) { try { FormNoControlRule rule = new FormNoControlRule(); string sql = "DELETE FROM Finance_PaymentHandle WHERE OrderFormNo =" + SysString.ToDBString(p_OrderFormNo); sql += " AND ID NOT IN" + string.Format("({0})", GetIDExist(p_BE)); sqlTrans.ExecuteNonQuery(sql); for (int i = 0; i < p_BE.Length; i++) { PaymentHandle entitydts = (PaymentHandle)p_BE[i]; if (entitydts.ID > 0) { this.RUpdate(entitydts, sqlTrans); } else { string FormNo = rule.RGetFormNo("Finance_PaymentHandle", "FormNo", sqlTrans); entitydts.FormNo = FormNo; this.RAdd(entitydts, sqlTrans); rule.RAddSort("Finance_PaymentHandle", "FormNo", sqlTrans); } } } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 设置 /// </summary> public override void EntitySet() { PaymentHandle entity = new PaymentHandle(); entity.ID = HTDataID; bool findFlag = entity.SelectByID(); txtFormNo.Text = entity.FormNo.ToString(); txtFormDate.DateTime = entity.FormDate; txtOrderFormNo.Text = entity.OrderFormNo.ToString(); drpVendorID.EditValue = entity.VendorID; drpSaleOPID.EditValue = entity.SaleOPID; drpCurrency.EditValue = entity.Currency; txtPayMethod.Text = entity.PayMethod.ToString(); txtRemark.Text = entity.Remark.ToString(); txtMakeOPName.Text = entity.MakeOPID.ToString(); txtMakeDate.DateTime = entity.MakeDate; txtQty.Text = entity.Qty.ToString(); txtAmount.Text = entity.Amount.ToString(); txtUnit.EditValue = entity.Unit; drpType.EditValue = entity.Type.ToString(); HTDataSubmitFlag = entity.SubmitFlag; HTDataDelFlag = entity.DelFlag; if (!findFlag) { } }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private PaymentHandle EntityGet() { PaymentHandle entity = new PaymentHandle(); entity.ID = HTDataID; return(entity); }
/// <summary> /// 新增 /// </summary> public override int EntityAdd() { PaymentHandleRule rule = new PaymentHandleRule(); PaymentHandle entity = EntityGet(); rule.RAdd(entity); return(entity.ID); }
public override void btnSubmitCancel_Click(object sender, EventArgs e) { PaymentHandle entity = new PaymentHandle(); entity.ID = HTDataID; entity.SelectByID(); if (entity.ReadFlag == 1) { this.ShowMessage("该单据已阅不能撤销提交"); return; } base.btnSubmitCancel_Click(sender, e); }
/// <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) { PaymentHandle entity = (PaymentHandle)p_BE; bool ret = false; string sql = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, PaymentHandle.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID); DataTable dt = p_sqlTrans.Fill(sql); if (dt.Rows.Count != 0) { ret = true; } return(ret); }
/// <summary> /// 获得数据库里没有被删除的ID(即数据库里有而且UI里也没有删除的数据) /// </summary> /// <param name="p_BE"></param> /// <returns></returns> private string GetIDExist(BaseEntity[] p_BE) { string outstr = "0"; for (int i = 0; i < p_BE.Length; i++) { PaymentHandle entitydts = (PaymentHandle)p_BE[i]; if (entitydts.ID != 0) { outstr += "," + entitydts.ID; } } return(outstr); }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); PaymentHandle entity = (PaymentHandle)p_BE; PaymentHandleCtl control = new PaymentHandleCtl(sqlTrans); control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); PaymentHandle entity = (PaymentHandle)p_BE; PaymentHandleCtl control = new PaymentHandleCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Finance_PaymentHandle, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
public override void btnLoad_Click(object sender, EventArgs e) { if (!FCommon.RightCheck(this.FormID, this.RightFormID, this.FormListAID, this.FormListBID, RightSub.权限0)) { this.ShowMessage("没有此权限,请联系管理员"); return; } ButtonItem btn = (ButtonItem)sender; PaymentHandleRule rule = new PaymentHandleRule(); PaymentHandle entity = new PaymentHandle(); entity.ID = HTDataID; entity.SelectByID(); if (btn.Text == "撤销已阅") { if (entity.ReadFlag == 0) { this.ShowMessage("该单据还未阅,无需撤销"); return; } entity.ReadFlag = 0; rule.RUpdate(entity); } if (btn.Text == "已阅") { if (entity.ReadFlag == 1) { this.ShowMessage("该单据已阅,无需再阅"); return; } entity.ReadFlag = 1; rule.RUpdate(entity); } btnQuery_Click(null, null); ProcessGrid.GridViewFocus(gridView1, new string[] { "ID" }, new string[] { entity.ID.ToString() }); }
private void BtnPay_Click(object sender, EventArgs e) { if (bill.ListBillDetail.Count > 0) { bool result = new PaymentHandle(this).Handle(bill); if (result) { foreach (var tb in this.listTable.listDesk) { if (bill.DeskId.Equals(tb.Id)) { listTable.EmplyDesk(tb); break; } } this.listTable.ListBill.Remove(bill); this.Dispose(); } } else { MessageBox.Show("Vui lòng đặt món"); } }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private PaymentHandle EntityGet() { PaymentHandle entity = new PaymentHandle(); entity.ID = HTDataID; entity.SelectByID(); entity.FormNo = txtFormNo.Text.Trim(); entity.FormDate = txtFormDate.DateTime.Date; entity.OrderFormNo = txtOrderFormNo.Text.Trim(); entity.VendorID = SysConvert.ToString(drpVendorID.EditValue); entity.SaleOPID = SysConvert.ToString(drpSaleOPID.EditValue); entity.Currency = SysConvert.ToString(drpCurrency.EditValue); entity.PayMethod = txtPayMethod.Text.Trim(); entity.Remark = txtRemark.Text.Trim(); entity.Unit = SysConvert.ToString(txtUnit.EditValue); entity.Qty = SysConvert.ToDecimal(txtQty.EditValue); entity.Amount = SysConvert.ToDecimal(txtAmount.EditValue); entity.Type = SysConvert.ToString(drpType.EditValue); entity.MakeDate = txtMakeDate.DateTime.Date; entity.MakeOPID = txtMakeOPName.Text.Trim(); return(entity); }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { PaymentHandle MasterEntity = (PaymentHandle)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Finance_PaymentHandle("); 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("OrderFormNo" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.OrderFormNo) + ","); MasterField.Append("VendorID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.VendorID) + ","); MasterField.Append("SaleOPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SaleOPID) + ","); MasterField.Append("Currency" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Currency) + ","); MasterField.Append("PayMethod" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.PayMethod) + ","); MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("MakeOPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.MakeOPID) + ","); MasterField.Append("MakeDate" + ","); if (MasterEntity.MakeDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.MakeDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Qty" + ","); if (MasterEntity.Qty != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.Qty) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Amount" + ","); if (MasterEntity.Amount != 0) { MasterValue.Append(SysString.ToDBString(MasterEntity.Amount) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Unit" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Unit) + ","); MasterField.Append("SubmitFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SubmitFlag) + ","); MasterField.Append("DelFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.DelFlag) + ","); MasterField.Append("Type" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Type) + ","); MasterField.Append("ReadFlag" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.ReadFlag) + ")"); //执行 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 { PaymentHandle MasterEntity = (PaymentHandle)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Finance_PaymentHandle 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,"); } UpdateBuilder.Append(" OrderFormNo=" + SysString.ToDBString(MasterEntity.OrderFormNo) + ","); UpdateBuilder.Append(" VendorID=" + SysString.ToDBString(MasterEntity.VendorID) + ","); UpdateBuilder.Append(" SaleOPID=" + SysString.ToDBString(MasterEntity.SaleOPID) + ","); UpdateBuilder.Append(" Currency=" + SysString.ToDBString(MasterEntity.Currency) + ","); UpdateBuilder.Append(" PayMethod=" + SysString.ToDBString(MasterEntity.PayMethod) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" MakeOPID=" + SysString.ToDBString(MasterEntity.MakeOPID) + ","); if (MasterEntity.MakeDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" MakeDate=" + SysString.ToDBString(MasterEntity.MakeDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" MakeDate=null,"); } if (MasterEntity.Qty != 0) { UpdateBuilder.Append(" Qty=" + SysString.ToDBString(MasterEntity.Qty) + ","); } else { UpdateBuilder.Append(" Qty=null,"); } if (MasterEntity.Amount != 0) { UpdateBuilder.Append(" Amount=" + SysString.ToDBString(MasterEntity.Amount) + ","); } else { UpdateBuilder.Append(" Amount=null,"); } UpdateBuilder.Append(" Unit=" + SysString.ToDBString(MasterEntity.Unit) + ","); UpdateBuilder.Append(" SubmitFlag=" + SysString.ToDBString(MasterEntity.SubmitFlag) + ","); UpdateBuilder.Append(" DelFlag=" + SysString.ToDBString(MasterEntity.DelFlag) + ","); UpdateBuilder.Append(" Type=" + SysString.ToDBString(MasterEntity.Type) + ","); UpdateBuilder.Append(" ReadFlag=" + SysString.ToDBString(MasterEntity.ReadFlag)); 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); } }
public PaymentHandle[] EntityDtsGet() { int index = dtGrid.Select("ISNULL(Type,'')<>''").Length; if (index < 1) { this.ShowMessage("请先填写附加类型再保存"); } PaymentHandle[] entitydts = new PaymentHandle[index]; index = 0; for (int i = 0; i < dtGrid.Rows.Count; i++) { if (SysConvert.ToString((dtGrid.Rows[i]["Type"])) != "") { entitydts[index] = new PaymentHandle(); if (SysConvert.ToInt32(dtGrid.Rows[i]["ID"]) != 0) { entitydts[index].ID = SysConvert.ToInt32(dtGrid.Rows[i]["ID"]); } entitydts[index].SelectByID(); entitydts[index].FormNo = SysConvert.ToString(dtGrid.Rows[i]["FormNo"]); if (SysConvert.ToString(dtGrid.Rows[i]["FormDate"]) != "") { entitydts[index].FormDate = SysConvert.ToDateTime(dtGrid.Rows[i]["FormDate"]); } else { entitydts[index].FormDate = DateTime.Now; } entitydts[index].Amount = SysConvert.ToDecimal(dtGrid.Rows[i]["Amount"]); entitydts[index].Currency = SysConvert.ToString(dtGrid.Rows[i]["Currency"]); if (SysConvert.ToString(dtGrid.Rows[i]["MakeDate"]) != "") { entitydts[index].MakeDate = SysConvert.ToDateTime(dtGrid.Rows[i]["MakeDate"]); } else { entitydts[index].MakeDate = DateTime.Now; } if (SysConvert.ToString(dtGrid.Rows[i]["MakeOPID"]) != "") { entitydts[index].MakeOPID = SysConvert.ToString(dtGrid.Rows[i]["MakeOPID"]); } else { entitydts[index].MakeOPID = FParamConfig.LoginID; } entitydts[index].OrderFormNo = m_OrderFormNo; entitydts[index].PayMethod = SysConvert.ToString(dtGrid.Rows[i]["PayMethod"]); entitydts[index].Qty = SysConvert.ToDecimal(dtGrid.Rows[i]["Qty"]); entitydts[index].Remark = SysConvert.ToString(dtGrid.Rows[i]["Remark"]); if (SysConvert.ToString(dtGrid.Rows[i]["SaleOPID"]) != "") { entitydts[index].SaleOPID = SysConvert.ToString(dtGrid.Rows[i]["SaleOPID"]); } else { entitydts[index].SaleOPID = FParamConfig.LoginID; } if (SysConvert.ToString(dtGrid.Rows[i]["SubmitFlag"]) != "") { entitydts[index].SubmitFlag = SysConvert.ToInt32(dtGrid.Rows[i]["SubmitFlag"]); } else { entitydts[index].SubmitFlag = 1; } entitydts[index].Type = SysConvert.ToString(dtGrid.Rows[i]["Type"]); entitydts[index].Unit = SysConvert.ToString(dtGrid.Rows[i]["Unit"]); if (SysConvert.ToString(dtGrid.Rows[i]["VendorID"]) != "") { entitydts[index].VendorID = SysConvert.ToString(dtGrid.Rows[i]["VendorID"]); } else { entitydts[index].VendorID = m_VendorID; } index++; } } return(entitydts); }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { PaymentHandle entity = (PaymentHandle)p_BE; }