示例#1
0
    public int SaveBudget(BudgetUI objUI, System.Data.SqlClient.SqlTransaction objTrans)
    {
        int ID = 0;
        bool flagTransation = true;

        BudgetDB objDB = new BudgetDB();
        objDB.FinancialYear = objUI.FinancialYear;
        objDB.QuarterID = objUI.QuarterID;
        objDB.Budget = objUI.Budget;
        objDB.ModelGroupID = objUI.ModelGroupID;
        objDB.ModelCategoryID = objUI.ModelCategoryID;
        objDB.ModelClutchID = objUI.ModelClutchID;
        objDB.ModelSpecialID = objUI.ModelSpecialID;

        DataAccessLayer objDataAccess = new DataAccessLayer();

        try
        {

            if (objTrans == null)
            {
                flagTransation = false;
                objDataAccess.GetConnection.Open();
                SqlTransaction objTransaction = objDataAccess.GetConnection.BeginTransaction();
                objTrans = objTransaction;
            }
            BudgetManager objManager = new BudgetManager();
            ID = objManager.SaveBudget(objDB, objTrans);
            if (!flagTransation)
                objTrans.Commit();
            return ID;
        }
        catch (Exception ex)
        {
            if (!flagTransation)
                objTrans.Rollback();
            throw ex;
        }
        finally
        {
            objDataAccess.GetConnection.Close();
        }
    }
示例#2
0
    public void SaveInformation()
    {
        BudgetController objController = new BudgetController();
        BudgetUI objUI = new BudgetUI();
        int Status = 0;
        try
        {
            string strDeleteQuery = "Delete from Budget where FinancialYear='" + drp_FinancialYear.SelectedItem.Text + "' and ModelGroupID=" + drpModel.SelectedValue + " and ModelCategoryID=" + drpModelCategory.SelectedValue + " and ModelClutchID=" + drpClutch.SelectedValue + " and ModelSpecialID=" + drpSpecial.SelectedValue; ;
            objQueryController.ExecuteQuery(strDeleteQuery);

            objUI.FinancialYear = drp_FinancialYear.SelectedItem.Text;
            foreach (GridViewRow gr in grdBudget.Rows)
            {
                objUI.QuarterID = Convert.ToInt32(((HiddenField)gr.FindControl("hdnQuarterID")).Value);
                string strBudget = ((TextBox)gr.FindControl("txtBudget")).Text.Trim();
                if (strBudget == "")
                {
                    objUI.Budget = Convert.ToDouble(null);
                }
                else
                {
                    objUI.Budget = Convert.ToDouble(strBudget);
                }
                objUI.ModelGroupID =  Convert.ToInt32(drpModel.SelectedValue);
                objUI.ModelCategoryID = Convert.ToInt32(drpModelCategory.SelectedValue);
                objUI.ModelClutchID = Convert.ToInt32(drpClutch.SelectedValue);
                if (chkSpecial.Checked)
                {
                    objUI.ModelSpecialID = Convert.ToInt32(drpSpecial.SelectedValue);
                }
                else
                {
                    objUI.ModelSpecialID = 0;
                }
                Status = objController.SaveBudget(objUI, null);

            }
        }
        catch
        {
            Status = 0;
        }
        if (Status > 0)
        {
            string str = "<script language = 'javascript'>";
            str += "setMessageText('ctl00_ContentPlaceHolder1_lblMessage','Records Saved Successfully');";
            str += "</script>";
            literal1.Text = str;
        }
        else
        {
            string str = "<script language = 'javascript'>";
            str += "setMessageText('ctl00_ContentPlaceHolder1_lblMessage','Records could not be Saved Successfully');";
            str += "</script>";
            literal1.Text = str;
        }
    }