public static BG_Supplementary AddBG_Supplementary(BG_Supplementary bG_Supplementary)
        {
            string sql =
                "INSERT BG_Supplementary (SuppMon, Year)" +
                "VALUES (@SuppMon, @Year)";

            sql += " ; SELECT @@IDENTITY";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@SuppMon", bG_Supplementary.SuppMon),
                    new SqlParameter("@Year", bG_Supplementary.Year)
                };

                string IdStr = DBUnity.ExecuteScalar(CommandType.Text, sql, para);
                int newId = Convert.ToInt32(IdStr);
                return GetBG_SupplementaryBySuppID(newId);

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 protected void btnadd_DirectClick(object sender, DirectEventArgs e)
 {
     int curtime = common.IntSafeConvert(txtSuppyear.Text.Trim());
     DataTable dtpre = BG_PreLogic.GetBG_PreByyear(curtime - 1);
     decimal premon = 0;
     if (dtpre.Rows.Count<=0)
     {
         premon = 0;
     }
     else
     {
         premon = ParToDecimal.ParToDel(dtpre.Rows[0]["PreMon"].ToString());
     }
     if (!BG_SupplementaryLogic.IsSuppByYear(curtime))
     {
         BG_Supplementary bg_sup = new BG_Supplementary();
         bg_sup.SuppMon = ParToDecimal.ParToDel(txtSupp.Text.Trim()) - premon;
         bg_sup.Year = Convert.ToInt32(txtSuppyear.Text.Trim());
         BG_SupplementaryManager.AddBG_Supplementary(bg_sup);
         X.Msg.Alert("提示", "添加成功!").Show();
     }
     else
     {
         BG_Supplementary bg_sup = new BG_Supplementary();
         DataTable bgsuid = BG_SupplementaryLogic.GetBG_SupplementaryByyear(curtime);
         bg_sup.SuppID = common.IntSafeConvert(bgsuid.Rows[0]["SuppID"].ToString());
         bg_sup.SuppMon = ParToDecimal.ParToDel(txtSupp.Text.Trim()) - premon;
         bg_sup.Year = Convert.ToInt32(txtSuppyear.Text.Trim());
         bool flag = BG_SupplementaryManager.ModifyBG_Supplementary(bg_sup);
         if (flag)
         {
             X.Msg.Alert("提示", "修改成功!").Show();
         }
         else
         {
             X.Msg.Alert("提示", "修改失败,请与管理员联系!").Show();
         }
     }
 }
 public static bool ModifyBG_Supplementary(BG_Supplementary bG_Supplementary)
 {
     return BG_SupplementaryService.ModifyBG_Supplementary(bG_Supplementary);
 }
 public static bool DeleteBG_Supplementary(BG_Supplementary bG_Supplementary)
 {
     return BG_SupplementaryService.DeleteBG_Supplementary(bG_Supplementary);
 }
 public static BG_Supplementary AddBG_Supplementary(BG_Supplementary bG_Supplementary)
 {
     return BG_SupplementaryService.AddBG_Supplementary(bG_Supplementary);
 }
        public static BG_Supplementary GetBG_SupplementaryBySuppID(int suppID)
        {
            string sql = "SELECT * FROM BG_Supplementary WHERE SuppID = @SuppID";

            try
            {
                SqlParameter para = new SqlParameter("@SuppID", suppID);
                DataTable dt = DBUnity.AdapterToTab(sql, para);

                if(dt.Rows.Count > 0)
                {
                    BG_Supplementary bG_Supplementary = new BG_Supplementary();

                    bG_Supplementary.SuppID = dt.Rows[0]["SuppID"] == DBNull.Value ? 0 : (int)dt.Rows[0]["SuppID"];
                    bG_Supplementary.SuppMon = dt.Rows[0]["SuppMon"] == DBNull.Value ? 0 : (decimal)dt.Rows[0]["SuppMon"];
                    bG_Supplementary.Year = dt.Rows[0]["Year"] == DBNull.Value ? 0 : (int)dt.Rows[0]["Year"];

                    return bG_Supplementary;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
 public static bool DeleteBG_Supplementary(BG_Supplementary bG_Supplementary)
 {
     return DeleteBG_SupplementaryBySuppID( bG_Supplementary.SuppID );
 }
        public static bool ModifyBG_Supplementary(BG_Supplementary bG_Supplementary)
        {
            string sql =
                "UPDATE BG_Supplementary " +
                "SET " +
                    "SuppMon = @SuppMon, " +
                    "Year = @Year " +
                "WHERE SuppID = @SuppID";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@SuppID", bG_Supplementary.SuppID),
                    new SqlParameter("@SuppMon", bG_Supplementary.SuppMon),
                    new SqlParameter("@Year", bG_Supplementary.Year)
                };

                int t = DBUnity.ExecuteNonQuery(CommandType.Text, sql, para);
                if(t>0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }