protected void btn_save_Click(object sender, EventArgs e)
        {
            string msg = checkInput();

            if (msg != "")
            {
                Alert.Show(msg);
                return;
            }
            else
            {
                Entity.PondChange entity = new Entity.PondChange();
                entity.PondID     = int.Parse(drop_pond.SelectedValue.Trim()); // = ds.Tables[0].Rows[0]["单位全称"].ToString();
                entity.OldAmount  = decimal.Parse(txt_Old.Text.Trim());        // = ds.Tables[0].Rows[0]["单位曾用名全称"].ToString();
                entity.NewAmount  = decimal.Parse(NB_New.Text.Trim());
                entity.Remark     = txt_Remark.Text.Trim();
                entity.CreateDate = DateTime.Now;
                entity.CreateUser = Request.Cookies["Cookies"].Values["UserName"].ToString();
                //Add
                decimal capacity = decimal.Parse(txt_Capacity.Text.Trim());
                //int success = DAL.PondChange.AddPondChange(entity,capacity);
                int success = DAL.PondChange.AddPondChangeEx(entity);
                if (success == 1)
                {
                    Alert.ShowInTop(" 保存成功!", MessageBoxIcon.Information);
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop(" 保存失败!", MessageBoxIcon.Warning);
                }
            }
        }
Esempio n. 2
0
        public static int AddPondChange(Entity.PondChange entity, decimal Capacity)
        {
            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("@OldAmount",  DBTypeConverter.ConvertCsTypeToOriginDBType(entity.OldAmount.GetType().ToString()),  entity.OldAmount,  10),
                    dbFactory.MakeInParam("@NewAmount",  DBTypeConverter.ConvertCsTypeToOriginDBType(entity.NewAmount.GetType().ToString()),  entity.NewAmount,  10),
                    dbFactory.MakeInParam("@Remark",     DBTypeConverter.ConvertCsTypeToOriginDBType(entity.Remark.GetType().ToString()),     entity.Remark,      0),
                    dbFactory.MakeInParam("@CreateDate", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.CreateDate.GetType().ToString()), entity.CreateDate,  0),
                    dbFactory.MakeInParam("@CreateUser", DBTypeConverter.ConvertCsTypeToOriginDBType(entity.CreateUser.GetType().ToString()), entity.CreateUser, 50)
                };
                iReturn = db.ExecuteNonQueryTrans(trans, CommandType.StoredProcedure, "proc_PondChange_Add", prams);
                //
                decimal Used   = entity.NewAmount;
                decimal Remain = Capacity - entity.NewAmount;
                iReturn = db.ExecuteNonQueryTrans(trans, CommandType.Text, "Update	[Pond] set Used='"+ Used + "',Remain='" + Remain + "' where PondID='" + entity.PondID + "'", null);
                thelper.CommitTransaction(trans);
                iReturn = 1;
            }
            catch (Exception ex)
            {
                thelper.RollTransaction(trans);
                iReturn = 0;
            }
            finally
            {
                db.Conn.Close();
            }
            return(iReturn);
        }