/// <summary> /// [ISingleGridPage]删除表格数据 /// </summary> public void DeleteSelectedRows() { int selectedCount = Grid1.SelectedRowIndexArray.Length; if (selectedCount == 0) { Alert.ShowInTop("请至少选择一项纪录!", MessageBoxIcon.Warning); return; } object[] keys = Grid1.DataKeys[Grid1.SelectedRowIndex]; Entity.FinalWasteLog entity = DAL.FinalWasteLog.GetFinalWasteLog(int.Parse(HttpUtility.UrlEncode(keys[0].ToString()))); if (entity.Status == 2) { Alert.ShowInTop("审核通过的不能删除!", MessageBoxIcon.Information); return; } else { int BSuccess = DAL.FinalWasteLog.DeleteFinalWasteLog(int.Parse(HttpUtility.UrlEncode(keys[0].ToString()))); if (BSuccess == 1) { Alert.ShowInTop(" 操作成功!", MessageBoxIcon.Information); BindGrid(); } else { Alert.ShowInTop(" 操作失败!", MessageBoxIcon.Warning); } } }
public static int UpdateFinalWasteLog(Entity.FinalWasteLog entity) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(DAL.Config.con); IDbTransaction trans = thelper.StartTransaction(); try { IDbDataParameter[] prams = { dbFactory.MakeInParam("@LogID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.LogID.GetType().ToString()), entity.LogID, 32), dbFactory.MakeInParam("@DateTime", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.DateTime.GetType().ToString()), entity.DateTime, 0), dbFactory.MakeInParam("@UserID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UserID.GetType().ToString()), entity.UserID, 32), dbFactory.MakeInParam("@UpdateDate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UpdateDate.GetType().ToString()), entity.UpdateDate, 0), dbFactory.MakeInParam("@UpdateUser", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UpdateUser.GetType().ToString()), entity.UpdateUser, 50), dbFactory.MakeInParam("@Status", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Status.GetType().ToString()), entity.Status, 32) }; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "proc_FinalWasteLog_Update", prams); thelper.CommitTransaction(trans); iReturn = 1; } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = 0; } finally { db.Conn.Close(); } return(iReturn); }
/// <summary> /// /// </summary> /// <param name="DealID"> </param> /// <param name="Status"> </param> /// <returns></returns> public static int UpdateFinalWasteLogEx(Entity.FinalWasteLog entity) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(DAL.Config.con); IDbTransaction trans = thelper.StartTransaction(); try { iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, "Update [FinalWasteLog] set UpdateDate='"+ entity.UpdateDate + "',UpdateUser='******',Status='" + entity.Status + "'where LogID='" + entity.LogID + "'", null); iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, "Update [FinalWaste] set Status='"+ entity.Status + "' where LogID='" + entity.LogID + "'", null); thelper.CommitTransaction(trans); iReturn = 1; } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = 0; } finally { db.Conn.Close(); } return(iReturn); }
//public static DataTable QueryFinalWasteLogEx2(string StartTime, string EndTime) //{ // DataTable dt = new DataTable(); // DBOperatorBase db = new DataBase(); // IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); // try // { // StringBuilder sb = new StringBuilder(); // sb.Append("Select DateTime 日期,PondName as 罐池号,WasteName as 废物名称,FromAmount as 数量,HandleManName as 处置人,ReceiverName as 签收人 from [vFinalWasteLog] where Status=2"); // if (!string.IsNullOrEmpty(StartTime)) // { // sb.Append(" and DateTime>='" + StartTime + "'"); // } // if (!string.IsNullOrEmpty(EndTime)) // { // sb.Append(" and DateTime<='" + EndTime + "'"); // } // sb.Append(" order by DateTime desc"); // IDataReader dataReader = db.ExecuteReader(Config.con, CommandType.Text, sb.ToString(), null); // dt = DAL.DataBase.GetDataTableFromIDataReader(dataReader); // } // catch (Exception ex) // { // } // finally // { // db.Conn.Close(); // } // return dt; //} /// <summary> /// /// </summary> /// <param name="DealID"> </param> /// <returns></returns> public static Entity.FinalWasteLog GetFinalWasteLog(int LogID) { Entity.FinalWasteLog entity = null; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); try { IDataReader dataReader = db.ExecuteReader(Config.con, CommandType.Text, "Select * from [vFinalWasteLog] where LogID='" + LogID + "'", null); while (dataReader.Read()) { entity = new Entity.FinalWasteLog(); entity.LogID = DataHelper.ParseToInt(dataReader["LogID"].ToString()); entity.LogNumber = DataHelper.ParseToInt(dataReader["LogNumber"].ToString()); entity.DateTime = DataHelper.ParseToDate(dataReader["DateTime"].ToString()); entity.IYear = DataHelper.ParseToInt(dataReader["IYear"].ToString()); entity.Number = DataHelper.ParseToInt(dataReader["Number"].ToString()); entity.UserID = DataHelper.ParseToInt(dataReader["UserID"].ToString()); entity.RealName = dataReader["RealName"].ToString(); //entity.CreateDate = DataHelper.ParseToDate(dataReader["CreateDate"].ToString()); //entity.CreateUser = dataReader["CreateUser"].ToString(); //entity.UpdateDate = DataHelper.ParseToDate(dataReader["UpdateDate"].ToString()); //entity.UpdateUser = dataReader["UpdateUser"].ToString(); entity.Status = DataHelper.ParseToInt(dataReader["Status"].ToString()); } } catch (Exception ex) { } finally { db.Conn.Close(); } return(entity); }
public static int UpdateFinalWasteLogEntity(Entity.FinalWasteLog entity, List <Entity.FinalWaste> Adds2, List <Entity.FinalWaste> Update2, List <Entity.FinalWaste> Delete2) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(DAL.Config.con); IDbTransaction trans = thelper.StartTransaction(); try { IDbDataParameter[] prams = { dbFactory.MakeInParam("@LogID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.LogID.GetType().ToString()), entity.LogID, 32), dbFactory.MakeInParam("@DateTime", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.DateTime.GetType().ToString()), entity.DateTime, 0), dbFactory.MakeInParam("@UserID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UserID.GetType().ToString()), entity.UserID, 32), dbFactory.MakeInParam("@UpdateDate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UpdateDate.GetType().ToString()), entity.UpdateDate, 0), dbFactory.MakeInParam("@UpdateUser", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UpdateUser.GetType().ToString()), entity.UpdateUser, 50), dbFactory.MakeInParam("@Status", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Status.GetType().ToString()), entity.Status, 32) }; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "proc_FinalWasteLog_Update", prams); foreach (Entity.FinalWaste add in Adds2) { iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, "Insert into [FinalWaste]([LogID],[ItemCode],[Result],[Status]) values ('" + entity.LogID + "','" + add.ItemCode + "','" + add.Result + "','" + add.Status + "')", null); } foreach (Entity.FinalWaste update in Update2) { IDbDataParameter[] pramsf = { dbFactory.MakeInParam("@FWID", DBTypeConverter.ConvertCsTypeToOriginDBType(update.FWID.GetType().ToString()), update.FWID, 32), dbFactory.MakeInParam("@LogID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.LogID.GetType().ToString()), entity.LogID, 32), dbFactory.MakeInParam("@ItemCode", DBTypeConverter.ConvertCsTypeToOriginDBType(update.ItemCode.GetType().ToString()), update.ItemCode, 20), dbFactory.MakeInParam("@Result", DBTypeConverter.ConvertCsTypeToOriginDBType(update.Result.GetType().ToString()), update.Result, 10), dbFactory.MakeInParam("@Status", DBTypeConverter.ConvertCsTypeToOriginDBType(update.Status.GetType().ToString()), update.Status, 32) }; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "proc_FinalWaste_Update", pramsf); } foreach (Entity.FinalWaste delete in Delete2) { iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, "Delete from [FinalWaste] where FWID='" + delete.FWID + "'", null); } thelper.CommitTransaction(trans); iReturn = 1; } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = 0; } finally { db.Conn.Close(); } return(iReturn); }
public static int AddFinalWasteLogEntity(Entity.FinalWasteLog entity, List <Entity.FinalWaste> wastes) { int iReturn = 0; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); SqlTransactionHelper thelper = new SqlTransactionHelper(DAL.Config.con); IDbTransaction trans = thelper.StartTransaction(); try { IDbDataParameter[] prams = { dbFactory.MakeInParam("@LogNumber", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.LogNumber.GetType().ToString()), entity.LogNumber, 32), dbFactory.MakeInParam("@DateTime", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.DateTime.GetType().ToString()), entity.DateTime, 0), dbFactory.MakeInParam("@IYear", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.IYear.GetType().ToString()), entity.IYear, 32), dbFactory.MakeInParam("@Number", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Number.GetType().ToString()), entity.Number, 32), dbFactory.MakeInParam("@UserID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UserID.GetType().ToString()), entity.UserID, 32), dbFactory.MakeInParam("@CreateDate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.CreateDate.GetType().ToString()), entity.CreateDate, 0), dbFactory.MakeInParam("@CreateUser", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.CreateUser.GetType().ToString()), entity.CreateUser, 50), dbFactory.MakeInParam("@UpdateDate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UpdateDate.GetType().ToString()), entity.UpdateDate, 0), dbFactory.MakeInParam("@UpdateUser", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.UpdateUser.GetType().ToString()), entity.UpdateUser, 50), dbFactory.MakeInParam("@Status", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Status.GetType().ToString()), entity.Status, 32), dbFactory.MakeOutReturnParam() }; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "proc_FinalWasteLog_Add", prams); iReturn = int.Parse(prams[10].Value.ToString()); int LogID = int.Parse(prams[10].Value.ToString()); foreach (Entity.FinalWaste waste in wastes) { iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, "Insert into [FinalWaste]([LogID],[ItemCode],[Result],[Status]) values ('" + LogID + "','" + waste.ItemCode + "','" + waste.Result + "','" + entity.Status + "')", null); } thelper.CommitTransaction(trans); iReturn = 1; } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = 0; } finally { db.Conn.Close(); } return(iReturn); }
private void LoadData(string thisGuid) { if (thisGuid != string.Empty) { //BindGrid(); Entity.FinalWasteLog entity = DAL.FinalWasteLog.GetFinalWasteLog(int.Parse(thisGuid)); if (!string.IsNullOrEmpty(entity.DateTime.ToString())) { FDate.SelectedDate = entity.DateTime; } drop_Man.SelectedValue = entity.UserID.ToString(); txt_LogNumber.Text = entity.LogNumber.ToString(); if (entity.Status == 2) { FDate.Readonly = true; drop_Man.Readonly = true; txt_LogNumber.Readonly = true; Grid2.Enabled = false; btn_save.Enabled = false; } } }
protected void btn_Pass_Click(object sender, EventArgs e) { int selectedCount = Grid1.SelectedRowIndexArray.Length; if (selectedCount == 0) { Alert.ShowInTop("请至少选择一项纪录!", MessageBoxIcon.Warning); return; } object[] keys = Grid1.DataKeys[Grid1.SelectedRowIndex]; int LogID = int.Parse(HttpUtility.UrlEncode(keys[0].ToString())); Entity.FinalWasteLog entity = DAL.FinalWasteLog.GetFinalWasteLog(LogID); if (entity.Status == 2) { Alert.ShowInTop("该记录已经审核通过了!", MessageBoxIcon.Warning); return; } //entity.CreateDate = DateTime.Now; //entity.CreateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); entity.UpdateDate = DateTime.Now; entity.UpdateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); entity.Status = 2; //先判断是否可行 int BSuccess = DAL.FinalWasteLog.UpdateFinalWasteLogEx(entity); if (BSuccess == 1) { Alert.ShowInTop(" 操作成功!", MessageBoxIcon.Information); BindGrid(); } else { Alert.ShowInTop(" 操作失败!", MessageBoxIcon.Warning); } }
protected void btn_save_Click(object sender, EventArgs e) { string msg = checkInput(); if (msg != "") { Alert.Show(msg); return; } else { int iReturn = 0; try { Entity.FinalWasteLog entity = new Entity.FinalWasteLog(); entity.CreateDate = DateTime.Now; entity.UpdateDate = DateTime.Now; entity.CreateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); entity.UpdateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); entity.DateTime = FDate.SelectedDate; entity.IYear = DateTime.Now.Year; entity.Number = DAL.FinalWasteLog.GetMaxNumber(entity.IYear) + 1; int Number = DAL.FinalWasteLog.GetCount(entity.DateTime) + 1; entity.LogNumber = int.Parse(GenerateLogNumberEx(entity.DateTime.Value, Number.ToString())); //entity.LogNumber = int.Parse(GenerateLogNumber(entity.IYear, entity.Number.ToString())); entity.Status = 1; entity.UserID = int.Parse(drop_Man.SelectedValue.Trim()); if (string.IsNullOrEmpty(sGuid)) { //Add List <Dictionary <string, object> > newAddedList2 = Grid2.GetNewAddedList(); List <Entity.FinalWaste> Adds2 = new List <Entity.FinalWaste>(); for (int i = 0; i < newAddedList2.Count; i++) { Entity.FinalWaste add = new Entity.FinalWaste(); add.Result = decimal.Parse(newAddedList2[i]["Result2"].ToString()); add.ItemCode = DAL.Waste.GetWasteCodeByName(newAddedList2[i]["WasteName2"].ToString()); Adds2.Add(add); } iReturn = DAL.FinalWasteLog.AddFinalWasteLogEntity(entity, Adds2); } else { //Update entity.LogID = int.Parse(sGuid); List <int> deletedRows2 = Grid2.GetDeletedList(); List <Entity.FinalWaste> Deletes2 = new List <Entity.FinalWaste>(); foreach (int rowIndex in deletedRows2) { Entity.FinalWaste delete = new Entity.FinalWaste(); delete.FWID = Convert.ToInt32(Grid2.DataKeys[rowIndex][1]); Deletes2.Add(delete); } Dictionary <int, Dictionary <string, object> > modifiedDict2 = Grid2.GetModifiedDict(); List <Entity.FinalWaste> Updates2 = new List <Entity.FinalWaste>(); foreach (int rowIndex in modifiedDict2.Keys) { Entity.FinalWaste update = new Entity.FinalWaste(); update.FWID = Convert.ToInt32(Grid2.DataKeys[rowIndex][1]); update.ItemCode = DAL.Waste.GetWasteCodeByName(Grid2.DataKeys[rowIndex][2].ToString()); update.Result = decimal.Parse(Grid2.DataKeys[rowIndex][3].ToString()); update.Status = 1; Updates2.Add(update); } List <Dictionary <string, object> > newAddedList2 = Grid2.GetNewAddedList(); List <Entity.FinalWaste> Adds2 = new List <Entity.FinalWaste>(); for (int i = 0; i < newAddedList2.Count; i++) { Entity.FinalWaste add = new Entity.FinalWaste(); add.Result = decimal.Parse(newAddedList2[i]["Result2"].ToString()); add.ItemCode = DAL.Waste.GetWasteCodeByName(newAddedList2[i]["WasteName2"].ToString()); Adds2.Add(add); } iReturn = DAL.FinalWasteLog.UpdateFinalWasteLogEntity(entity, Adds2, Updates2, Deletes2); } } catch (Exception ex) { } finally { } if (iReturn == 1) { Alert.ShowInTop(" 保存成功!", MessageBoxIcon.Information); // PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { Alert.ShowInTop(" 保存失败!", MessageBoxIcon.Warning); } } #endregion }