Beispiel #1
0
        public int Update(COAAccount cOAAccount)
        {
            UpdateCommand.Parameters["@ID"].Value = cOAAccount.ID;
            UpdateCommand.Parameters["@AccountCategoryName"].Value = cOAAccount.AccountCategoryName;
            UpdateCommand.Parameters["@AccountCategoryID"].Value   = cOAAccount.AccountCategoryID;
            UpdateCommand.Parameters["@AccountName"].Value         = cOAAccount.AccountName;
            UpdateCommand.Parameters["@ParentGroupID"].Value       = cOAAccount.ParentGroupID;
            UpdateCommand.Parameters["@ParentGroupName"].Value     = cOAAccount.ParentGroupName;
            UpdateCommand.Parameters["@Status"].Value = cOAAccount.Status;

            int returnValue = -1;

            try
            {
                UpdateCommand.Connection.Open();
                returnValue = UpdateCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                UpdateCommand.Connection.Close();
            }
            return(returnValue);
        }
Beispiel #2
0
        public int Insert(COAAccount cOAAccount)
        {
            InsertCommand.Parameters["@AccountCategoryName"].Value = cOAAccount.AccountCategoryName;
            InsertCommand.Parameters["@AccountCategoryID"].Value   = cOAAccount.AccountCategoryID;
            InsertCommand.Parameters["@AccountName"].Value         = cOAAccount.AccountName;
            InsertCommand.Parameters["@ParentGroupID"].Value       = cOAAccount.ParentGroupID;
            InsertCommand.Parameters["@ParentGroupName"].Value     = cOAAccount.ParentGroupName;
            InsertCommand.Parameters["@Status"].Value = cOAAccount.Status;


            int returnValue = -1;

            try
            {
                InsertCommand.Connection.Open();
                returnValue = (int)InsertCommand.ExecuteScalar();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                InsertCommand.Connection.Close();
            }
            return(returnValue);
        }
Beispiel #3
0
        private COAAccount DataTableToEntity(DataTable dt)
        {
            COAAccount cOAAccount = new COAAccount();

            if (Null.IsNotNull(dt) == true && dt.Rows.Count > 0)
            {
                if (Null.IsNotNull(dt.Rows[0]))
                {
                    DataRow dr = dt.Rows[0];
                    if (Null.IsNotNull(dr["ID"]))
                    {
                        cOAAccount.ID = Convert.ToInt32(dr["ID"]);
                    }
                    else
                    {
                        cOAAccount.ID = 0;
                    }
                    if (Null.IsNotNull(dr["AccountCategoryName"]))
                    {
                        cOAAccount.AccountCategoryName = Convert.ToString(dr["AccountCategoryName"]);
                    }
                    else
                    {
                        cOAAccount.AccountCategoryName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["AccountCategoryID"]))
                    {
                        cOAAccount.AccountCategoryID = Convert.ToInt32(dr["AccountCategoryID"]);
                    }
                    else
                    {
                        cOAAccount.AccountCategoryID = 0;
                    }
                    if (Null.IsNotNull(dr["AccountName"]))
                    {
                        cOAAccount.AccountName = Convert.ToString(dr["AccountName"]);
                    }
                    else
                    {
                        cOAAccount.AccountName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["ParentGroupID"]))
                    {
                        cOAAccount.ParentGroupID = Convert.ToInt32(dr["ParentGroupID"]);
                    }
                    else
                    {
                        cOAAccount.ParentGroupID = 0;
                    }
                    if (Null.IsNotNull(dr["ParentGroupName"]))
                    {
                        cOAAccount.ParentGroupName = Convert.ToString(dr["ParentGroupName"]);
                    }
                    else
                    {
                        cOAAccount.ParentGroupName = string.Empty;
                    }
                    if (Null.IsNotNull(dr["Status"]))
                    {
                        cOAAccount.Status = Convert.ToString(dr["Status"]);
                    }
                    else
                    {
                        cOAAccount.Status = string.Empty;
                    }
                }
            }
            return(cOAAccount);
        }