Exemplo n.º 1
0
        public static int AddPondLog(Entity.PondLog entity, decimal U1, decimal R1, decimal U2, decimal R2)
        {
            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("@SourceID",   DBTypeConverter.ConvertCsTypeToOriginDBType(entity.SourceID.GetType().ToString()),   entity.SourceID,   32),
                    dbFactory.MakeInParam("@ToID",       DBTypeConverter.ConvertCsTypeToOriginDBType(entity.ToID.GetType().ToString()),       entity.ToID,       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("@Amount",     DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Amount.GetType().ToString()),     entity.Amount, 10)
                };
                iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "proc_PondLog_Add", prams);
                iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, "Update	[Pond] set Used='"+ U1 + "',Remain='" + R1 + "' where PondID='" + entity.SourceID + "'", null);
                iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, "Update	[Pond] set Used='"+ U2 + "',Remain='" + R2 + "' where PondID='" + entity.ToID + "'", null);
                thelper.CommitTransaction(trans);
                iReturn = 1;
            }
            catch (Exception ex)
            {
                thelper.RollTransaction(trans);
                iReturn = 0;
            }
            finally
            {
                db.Conn.Close();
            }
            return(iReturn);
        }
Exemplo n.º 2
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            string msg = checkInput();

            if (msg != "")
            {
                Alert.Show(msg);
                return;
            }
            else
            {
                Entity.PondLog entity = new Entity.PondLog();
                entity.SourceID   = int.Parse(drop_Source.SelectedValue.Trim());
                entity.ToID       = int.Parse(drop_To.SelectedValue.Trim());
                entity.CreateDate = DateTime.Now;
                entity.CreateUser = Request.Cookies["Cookies"].Values["UserName"].ToString();
                entity.Amount     = decimal.Parse(NB_New.Text.Trim());
                //Add
                //decimal capacity = decimal.Parse(txt_Capacity.Text.Trim());
                int         PondID1 = int.Parse(drop_Source.SelectedValue.Trim());
                Entity.Pond entity1 = DAL.Pond.GetPond(PondID1);
                decimal     used1   = entity1.Used;
                //decimal used1 = DAL.PondUsed.GetPondUsedAmount(entity1.PondID);
                decimal     Capacity = entity1.Capacity;
                int         PondID2  = int.Parse(drop_To.SelectedValue.Trim());
                Entity.Pond entity2  = DAL.Pond.GetPond(PondID2);
                decimal     used2    = entity2.Used;
                //decimal used2 = DAL.PondUsed.GetPondUsedAmount(entity2.PondID);
                decimal Capacity2 = entity2.Capacity;

                decimal U1 = used1 - entity.Amount;
                decimal U2 = used2 + entity.Amount;
                //decimal R1 = Capacity - used1 + entity.Amount;
                //decimal R2 = Capacity2 - used2 - entity.Amount;
                //int success = DAL.PondLog.AddPondLog(entity, U1,R1,U2,R2);
                int success = DAL.PondLog.AddPondLogEx(entity, U1, U2);
                if (success == 1)
                {
                    Alert.ShowInTop(" 保存成功!", MessageBoxIcon.Information);
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop(" 保存失败!", MessageBoxIcon.Warning);
                }
            }
        }