/// <summary> /// /// </summary> /// <param name="OutID"> </param> /// <param name="Status"> </param> /// <returns></returns> public static int PassProductOut(Entity.ProductOut entity, decimal Used) { 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("@OutID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.OutID.GetType().ToString()), entity.OutID, 32), dbFactory.MakeInParam("@Status", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Status.GetType().ToString()), entity.Status, 32) }; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "proc_ProductOut_UpdateStatus", prams); iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, "Insert into [PondUsed]([PondID],[Used],[SourceType],[TypeName],[CreateUser],[CreateDate]) values ('" + entity.PondID + "','" + Used + "','4','成品出库','" + entity.CreateUser + "','" + entity.CreateDate + "')", null); iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, "Update [Pond] set Used='"+ Used + "'where PondID='" + entity.PondID + "'", null); thelper.CommitTransaction(trans); iReturn = 1; } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = 0; } finally { db.Conn.Close(); } return(iReturn); }
/// <summary> /// /// </summary> /// <param name="DateTime"> </param> /// <returns></returns> public static List <Entity.ProductOut> GetSumProductOut() { List <Entity.ProductOut> list = new List <Entity.ProductOut>(); DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); try { string Start = string.Format("{0}-01-01", DateTime.Now.Year); string End = string.Format("{0}-12-31", DateTime.Now.Year); IDataReader dataReader = db.ExecuteReader(Config.con, CommandType.Text, "select sum(Amount) as Total,WasteName from vProductOut where Status=2 and DateTime>='" + Start + "' and DateTime<='" + End + "' group by WasteName", null); while (dataReader.Read()) { Entity.ProductOut entity = new Entity.ProductOut(); entity.WasteName = dataReader["WasteName"].ToString(); entity.Amount = decimal.Parse(dataReader["Total"].ToString()); list.Add(entity); } } catch (Exception ex) { } finally { db.Conn.Close(); } return(list); }
private void LoadData(string thisGuid) { if (thisGuid != string.Empty) { Entity.ProductOut entity = DAL.ProductOut.GetProductOut(int.Parse(thisGuid)); txt_enterprise.Text = entity.EnterpriseName; hf_EID.Text = entity.ReceiverEnterpriseID.ToString(); txt_Waste.Text = entity.WasteName; hid_WasteCode.Text = entity.WasteCode; //BindDropdownList(entity.WasteCode); drop_Pond.SelectedValue = entity.PondID.ToString(); Date_Start.SelectedDate = entity.DateTime; NB_Amount.Text = entity.Amount.ToString(); txt_Driver.Text = entity.DriverName; hf_DriverID.Text = entity.DriverID.ToString(); txt_Consignor.Text = entity.ConsignorName; hf_ConsignorID.Text = entity.ConsignorID.ToString(); hf_CarID.Text = entity.CarID.ToString(); txt_CarNumber.Text = entity.CarNumber; if (entity.Status == 2) { //全部只读,而且不可保存 txt_enterprise.Readonly = true; txt_Waste.Readonly = true; drop_Pond.Readonly = true; Date_Start.Readonly = true; NB_Amount.Readonly = true; txt_Driver.Readonly = true; txt_Consignor.Readonly = true; btn_save.Enabled = false; txt_CarNumber.Readonly = true; } } }
/// <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.ProductOut entity = DAL.ProductOut.GetProductOut(int.Parse(HttpUtility.UrlEncode(keys[0].ToString()))); if (entity.Status == 2) { Alert.ShowInTop("审核通过的不能删除!", MessageBoxIcon.Information); return; } else { int BSuccess = DAL.ProductOut.DeleteProductOut(int.Parse(HttpUtility.UrlEncode(keys[0].ToString()))); if (BSuccess == 1) { Alert.ShowInTop(" 操作成功!", MessageBoxIcon.Information); BindGrid(); } else { Alert.ShowInTop(" 操作失败!", MessageBoxIcon.Warning); } } }
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 OutID = int.Parse(HttpUtility.UrlEncode(keys[0].ToString())); Entity.ProductOut entity = DAL.ProductOut.GetProductOut(OutID); if (entity.Status == 2) { Alert.ShowInTop("该记录已经审核通过了!", MessageBoxIcon.Warning); return; } entity.Status = 2; entity.UpdateDate = DateTime.Now; entity.UpdateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); entity.CreateDate = DateTime.Now; entity.CreateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); //先判断是否可行 int PondID = entity.PondID; Entity.Pond pond = DAL.Pond.GetPond(PondID); decimal Used = pond.Used; decimal Now = Used - entity.Amount; if (Now < 0) { Alert.ShowInTop("罐池库存不足!", MessageBoxIcon.Warning); return; } int BSuccess = DAL.ProductOut.PassProductOut(entity, Now); if (BSuccess == 1) { Alert.ShowInTop(" 操作成功!", MessageBoxIcon.Information); BindGrid(); } else { Alert.ShowInTop(" 操作失败!", MessageBoxIcon.Warning); } }
protected void btn_save_Click(object sender, EventArgs e) { string str = checkInfo(); if (str != "") { Alert.ShowInTop(str, MessageBoxIcon.Warning); } else { Entity.ProductOut entity = new Entity.ProductOut(); entity.ReceiverEnterpriseID = int.Parse(hf_EID.Text.Trim()); entity.DriverID = int.Parse(hf_DriverID.Text.Trim()); entity.PondID = int.Parse(drop_Pond.SelectedValue.ToString()); entity.ConsignorID = int.Parse(hf_ConsignorID.Text.Trim()); entity.WasteCode = hid_WasteCode.Text; entity.DateTime = Date_Start.SelectedDate; entity.Amount = decimal.Parse(NB_Amount.Text.Trim()); entity.CreateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); entity.UpdateUser = Request.Cookies["Cookies"].Values["UserName"].ToString(); entity.CreateDate = DateTime.Now; entity.UpdateDate = DateTime.Now; entity.CarID = int.Parse(hf_CarID.Text.Trim()); entity.Status = 1; int iReturn = 0; if (sGuid == string.Empty || sGuid == null) { iReturn = DAL.ProductOut.AddProductOut(entity); } else { entity.OutID = int.Parse(sGuid); iReturn = DAL.ProductOut.UpdateProductOut(entity); } if (iReturn == 1) { Alert.ShowInTop(" 保存成功!", MessageBoxIcon.Information); // PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { Alert.ShowInTop(" 保存失败!", MessageBoxIcon.Warning); } } }
public static int AddProductOut(Entity.ProductOut 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("@PondID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.PondID.GetType().ToString()), entity.PondID, 32), dbFactory.MakeInParam("@WasteCode", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.WasteCode.GetType().ToString()), entity.WasteCode, 20), dbFactory.MakeInParam("@DateTime", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.DateTime.GetType().ToString()), entity.DateTime, 0), dbFactory.MakeInParam("@Amount", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Amount.GetType().ToString()), entity.Amount, 10), dbFactory.MakeInParam("@ReceiverEnterpriseID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.ReceiverEnterpriseID.GetType().ToString()), entity.ReceiverEnterpriseID, 32), dbFactory.MakeInParam("@DriverID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.DriverID.GetType().ToString()), entity.DriverID, 32), dbFactory.MakeInParam("@ConsignorID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.ConsignorID.GetType().ToString()), entity.ConsignorID, 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.MakeInParam("@CarID", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.CarID.GetType().ToString()), entity.CarID, 32), dbFactory.MakeOutReturnParam() }; iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "proc_ProductOut_Add", prams); iReturn = int.Parse(prams[13].Value.ToString()); thelper.CommitTransaction(trans); iReturn = 1; } catch (Exception ex) { thelper.RollTransaction(trans); iReturn = 0; } finally { db.Conn.Close(); } return(iReturn); }
/// <summary> /// /// </summary> /// <param name="OutID"> </param> /// <returns></returns> public static Entity.ProductOut GetProductOut(int OutID) { Entity.ProductOut entity = null; DBOperatorBase db = new DataBase(); IDBTypeElementFactory dbFactory = db.GetDBTypeElementFactory(); try { IDataReader dataReader = db.ExecuteReader(Config.con, CommandType.Text, "Select * from [vProductOut] where OutID='" + OutID + "'", null); while (dataReader.Read()) { entity = new Entity.ProductOut(); entity.OutID = DataHelper.ParseToInt(dataReader["OutID"].ToString()); entity.PondID = DataHelper.ParseToInt(dataReader["PondID"].ToString()); entity.WasteCode = dataReader["Stores"].ToString(); entity.WasteName = dataReader["WasteName"].ToString(); entity.DateTime = DataHelper.ParseToDate(dataReader["DateTime"].ToString()); entity.Amount = decimal.Parse(dataReader["Amount"].ToString()); entity.ReceiverEnterpriseID = DataHelper.ParseToInt(dataReader["ReceiverEnterpriseID"].ToString()); entity.EnterpriseName = dataReader["Name"].ToString(); entity.DriverID = DataHelper.ParseToInt(dataReader["DriverID"].ToString()); entity.DriverName = dataReader["RealName"].ToString(); entity.CarID = DataHelper.ParseToInt(dataReader["CarID"].ToString()); entity.CarNumber = dataReader["CarNumber"].ToString(); entity.ConsignorID = DataHelper.ParseToInt(dataReader["ConsignorID"].ToString()); entity.ConsignorName = dataReader["UserRealName"].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); }