public void Execute(WSInt32 Cat_LngID, WSString Cat_StrName)
        {
            Params.spI_tblCategory param = new Params.spI_tblCategory(true);
            param.SetUpConnection(string.Empty);

            if (Cat_LngID == null || Cat_LngID.UseNull)
            {
                param.Param_Cat_LngID = SqlInt32.Null;
            }
            else if (!Cat_LngID.UseDefault)
            {
                param.Param_Cat_LngID = Cat_LngID.Value;
            }

            if (Cat_StrName == null || Cat_StrName.UseNull)
            {
                param.Param_Cat_StrName = SqlString.Null;
            }
            else if (!Cat_StrName.UseDefault)
            {
                param.Param_Cat_StrName = Cat_StrName.Value;
            }

            using (SPs.spI_tblCategory sp = new SPs.spI_tblCategory(true)) {
                sp.Execute(ref param);
                param.Dispose();
            }
        }
示例#2
0
        private void AddRecordInDatabase()
        {
            Params.spI_tblCategory Param = new Params.spI_tblCategory(false);

            switch (this.lastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                break;
            }

            if (Control_Cat_StrName.Text.Trim() != String.Empty)
            {
                Param.Param_Cat_StrName = (System.Data.SqlTypes.SqlString)Control_Cat_StrName.GetSqlTypesValue;
            }

            SPs.spI_tblCategory SP = new SPs.spI_tblCategory(false);

            if (SP.Execute(ref Param))
            {
                this.parameter       = Param;
                this.errorHasOccured = false;
            }
            else
            {
                this.errorHasOccured = true;
                if (Param.SqlException != null && Param.SqlException.Number == 2627)
                {
                    MessageBox.Show(this, "Unable to add this record:\r\n\r\n" + Param.SqlException.Message, "Error");
                }
                else
                {
                    throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.Windows.Forms.WinForm_tblCategory", "AddRecordInDatabase");
                }
            }
        }
示例#3
0
        public Int32 Add_Category(Tables.Category record)
        {
            Params.spI_tblCategory param = new Params.spI_tblCategory(true);

            param.SetUpConnection(string.Empty);

            if (record.Col_Cat_StrName == null || record.Col_Cat_StrName.UseNull)
            {
                param.Param_Cat_StrName = SqlString.Null;
            }
            else if (!record.Col_Cat_StrName.UseDefault)
            {
                param.Param_Cat_StrName = record.Col_Cat_StrName.Value;
            }


            using (SPs.spI_tblCategory sp = new SPs.spI_tblCategory(true)) {
                sp.Execute(ref param);
                Int32 id = param.Param_Cat_LngID.Value;
                param.Dispose();

                return(id);
            }
        }
示例#4
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        /// <param name="record">[To be supplied.]</param>
        /// <returns>[To be supplied.]</returns>
        public IBusinessComponentRecord Add(IBusinessComponentRecord record)
        {
            Category recordToAdd = record as Category;

            if (recordToAdd == null)
            {
                throw new ArgumentException("Invalid record type. Must be 'OlymarsDemo.BusinessComponents.Category'.", "record");
            }

            bool alreadyOpened = false;

            Params.spI_tblCategory Param = new Params.spI_tblCategory(true);
            Param.CommandTimeOut = this.insertCommandTimeOut;
            switch (this.lastKnownConnectionType)
            {
            case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                Param.SetUpConnection(this.connectionString);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                Param.SetUpConnection(this.sqlConnection);
                alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open);
                break;

            case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:
                Param.SetUpConnection(this.sqlTransaction);
                break;
            }

            Param.Param_Cat_LngID   = recordToAdd.Col_Cat_LngID;
            Param.Param_Cat_StrName = recordToAdd.Col_Cat_StrName;

            SPs.spI_tblCategory Sp = new SPs.spI_tblCategory(false);
            if (Sp.Execute(ref Param))
            {
                Category newRecord = null;

                switch (this.lastKnownConnectionType)
                {
                case OlymarsDemo.DataClasses.ConnectionType.ConnectionString:
                    newRecord = new Category(this.connectionString, Param.Param_Cat_LngID);
                    break;

                case OlymarsDemo.DataClasses.ConnectionType.SqlConnection:
                    newRecord = new Category(this.sqlConnection, Param.Param_Cat_LngID);
                    break;

                case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:
                    newRecord = new Category(this.sqlTransaction, Param.Param_Cat_LngID);
                    break;
                }

                CloseConnection(Sp.Connection, alreadyOpened);

                if (internalRecords != null)
                {
                    internalRecords.Add(newRecord);
                }

                if (this.addedRecords == null)
                {
                    this.addedRecords = new System.Collections.ArrayList();
                }
                this.addedRecords.Add(newRecord);

                return(newRecord);
            }
            else
            {
                throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.Categories", "Add");
            }
        }
示例#5
0
        private void cmdUpdate_Click(object sender, System.EventArgs e)
        {
            if (!CheckValues())
            {
                return;
            }

            if (Action == ActionEnum.Edit)
            {
                Params.spU_tblCategory Param = null;
                SPs.spU_tblCategory    SP    = null;

                Param = new Params.spU_tblCategory();

                Param.SetUpConnection(ConnectionString);

                Param.Param_Cat_LngID = CurrentID;

                if (txt_Cat_StrName.Text.Trim() != String.Empty)
                {
                    Param.Param_Cat_StrName = new System.Data.SqlTypes.SqlString(txt_Cat_StrName.Text);
                }

                SP = new SPs.spU_tblCategory();

                if (SP.Execute(ref Param))
                {
                    if (ReturnURL.Visible)
                    {
                        Response.Redirect(String.Format("WebForm_tblCategory.aspx?Action=Edit&ID={0}&ReturnToUrl={1}&ReturnToDisplay={2}", CurrentID.ToString(), ReturnURL.NavigateUrl, ReturnURL.Text));
                    }
                    else
                    {
                        Response.Redirect(String.Format("WebForm_tblCategory.aspx?Action=Edit&ID={0}", CurrentID.ToString()));
                    }
                    return;
                }
                else
                {
                    if (Param.SqlException != null)
                    {
                        throw Param.SqlException;
                    }

                    if (Param.OtherException != null)
                    {
                        throw Param.OtherException;
                    }
                }
            }

            else
            {
                Params.spI_tblCategory Param = null;
                SPs.spI_tblCategory    SP    = null;

                Param = new Params.spI_tblCategory();

                Param.SetUpConnection(ConnectionString);

                if (txt_Cat_StrName.Text.Trim() != String.Empty)
                {
                    Param.Param_Cat_StrName = new System.Data.SqlTypes.SqlString(txt_Cat_StrName.Text);
                }

                SP = new SPs.spI_tblCategory();

                if (SP.Execute(ref Param))
                {
                    if (ReturnURL.Visible)
                    {
                        Response.Redirect(String.Format("WebForm_tblCategory.aspx?Action=Edit&ID={0}&ReturnToUrl={1}&ReturnToDisplay={2}", Param.Param_Cat_LngID.ToString(), ReturnURL.NavigateUrl, ReturnURL.Text));
                    }
                    else
                    {
                        Response.Redirect(String.Format("WebForm_tblCategory.aspx?Action=Edit&ID={0}", Param.Param_Cat_LngID.ToString()));
                    }
                    return;
                }
                else
                {
                    if (Param.SqlException != null)
                    {
                        throw Param.SqlException;
                    }

                    if (Param.OtherException != null)
                    {
                        throw Param.OtherException;
                    }
                }
            }
        }