Пример #1
0
        private void AddRecordInDatabase()
        {
            Params.spI_tblOrder Param = new Params.spI_tblOrder(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_Ord_DatOrderedOn.Text.Trim() != String.Empty)
            {
                Param.Param_Ord_DatOrderedOn = (System.Data.SqlTypes.SqlDateTime)Control_Ord_DatOrderedOn.GetSqlTypesValue;
            }

            if (Control_Ord_LngCustomerID.SelectedIndex != -1)
            {
                Param.Param_Ord_LngCustomerID = (System.Int32)Control_Ord_LngCustomerID.SelectedValue;
            }

            if (Control_Ord_CurTotal.Text.Trim() != String.Empty)
            {
                Param.Param_Ord_CurTotal = (System.Data.SqlTypes.SqlMoney)Control_Ord_CurTotal.GetSqlTypesValue;
            }

            SPs.spI_tblOrder SP = new SPs.spI_tblOrder(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_tblOrder", "AddRecordInDatabase");
                }
            }
        }
Пример #2
0
        public void Execute(WSGuid Ord_GuidID, WSDateTime Ord_DatOrderedOn, WSInt32 Ord_LngCustomerID, WSDecimal Ord_CurTotal)
        {
            Params.spI_tblOrder param = new Params.spI_tblOrder(true);
            param.SetUpConnection(string.Empty);

            if (Ord_GuidID == null || Ord_GuidID.UseNull)
            {
                param.Param_Ord_GuidID = SqlGuid.Null;
            }
            else if (!Ord_GuidID.UseDefault)
            {
                param.Param_Ord_GuidID = Ord_GuidID.Value;
            }

            if (Ord_DatOrderedOn == null || Ord_DatOrderedOn.UseNull)
            {
                param.Param_Ord_DatOrderedOn = SqlDateTime.Null;
            }
            else if (!Ord_DatOrderedOn.UseDefault)
            {
                param.Param_Ord_DatOrderedOn = Ord_DatOrderedOn.Value;
            }

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

            if (Ord_CurTotal == null || Ord_CurTotal.UseNull)
            {
                param.Param_Ord_CurTotal = SqlMoney.Null;
            }
            else if (!Ord_CurTotal.UseDefault)
            {
                param.Param_Ord_CurTotal = Ord_CurTotal.Value;
            }

            using (SPs.spI_tblOrder sp = new SPs.spI_tblOrder(true)) {
                sp.Execute(ref param);
                param.Dispose();
            }
        }
        public Guid Add_tblOrder_Record(Tables.tblOrder_Record record)
        {
            Params.spI_tblOrder param = new Params.spI_tblOrder(true);

            param.SetUpConnection(string.Empty);

            if (record.Col_Ord_DatOrderedOn == null || record.Col_Ord_DatOrderedOn.UseNull)
            {
                param.Param_Ord_DatOrderedOn = SqlDateTime.Null;
            }
            else if (!record.Col_Ord_DatOrderedOn.UseDefault)
            {
                param.Param_Ord_DatOrderedOn = record.Col_Ord_DatOrderedOn.Value;
            }

            if (record.Col_Ord_LngCustomerID == null || record.Col_Ord_LngCustomerID.UseNull)
            {
                param.Param_Ord_LngCustomerID = SqlInt32.Null;
            }
            else if (!record.Col_Ord_LngCustomerID.UseDefault)
            {
                param.Param_Ord_LngCustomerID = record.Col_Ord_LngCustomerID.Value;
            }

            if (record.Col_Ord_CurTotal == null || record.Col_Ord_CurTotal.UseNull)
            {
                param.Param_Ord_CurTotal = SqlMoney.Null;
            }
            else if (!record.Col_Ord_CurTotal.UseDefault)
            {
                param.Param_Ord_CurTotal = record.Col_Ord_CurTotal.Value;
            }


            using (SPs.spI_tblOrder sp = new SPs.spI_tblOrder(true)) {
                sp.Execute(ref param);
                Guid id = param.Param_Ord_GuidID.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)
        {
            tblOrder_Record recordToAdd = record as tblOrder_Record;

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

            switch (this.parentType)
            {
            case tblOrder_CollectionParentType.Col_Ord_LngCustomerID:
                recordToAdd.Col_Ord_LngCustomerID = ((tblCustomer_Record)this.parent).Col_Cus_LngID;
                break;
            }

            bool alreadyOpened = false;

            Params.spI_tblOrder Param = new Params.spI_tblOrder(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_Ord_GuidID        = recordToAdd.Col_Ord_GuidID;
            Param.Param_Ord_DatOrderedOn  = recordToAdd.Col_Ord_DatOrderedOn;
            Param.Param_Ord_LngCustomerID = recordToAdd.Col_Ord_LngCustomerID;
            Param.Param_Ord_CurTotal      = recordToAdd.Col_Ord_CurTotal;

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

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

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

                case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction:
                    newRecord = new tblOrder_Record(this.sqlTransaction, Param.Param_Ord_GuidID);
                    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.tblOrder_Collection", "Add");
            }
        }
Пример #5
0
        private void cmdUpdate_Click(object sender, System.EventArgs e)
        {
            if (!CheckValues())
            {
                return;
            }

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

                Param = new Params.spU_tblOrder();

                Param.SetUpConnection(ConnectionString);

                Param.Param_Ord_GuidID = CurrentID;

                if (txt_Ord_DatOrderedOn.Text.Trim() != String.Empty)
                {
                    Param.Param_Ord_DatOrderedOn = new System.Data.SqlTypes.SqlDateTime(System.Convert.ToDateTime(txt_Ord_DatOrderedOn.Text));
                }

                Param.Param_Ord_LngCustomerID = Convert.ToInt32(com_Ord_LngCustomerID.SelectedItem.Value);

                if (txt_Ord_CurTotal.Text.Trim() != String.Empty)
                {
                    Param.Param_Ord_CurTotal = new System.Data.SqlTypes.SqlMoney(System.Convert.ToDecimal(txt_Ord_CurTotal.Text));
                }

                SP = new SPs.spU_tblOrder();

                if (SP.Execute(ref Param))
                {
                    if (ReturnURL.Visible)
                    {
                        Response.Redirect(String.Format("WebForm_tblOrder.aspx?Action=Edit&ID={0}&ReturnToUrl={1}&ReturnToDisplay={2}", CurrentID.ToString(), ReturnURL.NavigateUrl, ReturnURL.Text));
                    }
                    else
                    {
                        Response.Redirect(String.Format("WebForm_tblOrder.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_tblOrder Param = null;
                SPs.spI_tblOrder    SP    = null;

                Param = new Params.spI_tblOrder();

                Param.SetUpConnection(ConnectionString);

                if (txt_Ord_DatOrderedOn.Text.Trim() != String.Empty)
                {
                    Param.Param_Ord_DatOrderedOn = new System.Data.SqlTypes.SqlDateTime(System.Convert.ToDateTime(txt_Ord_DatOrderedOn.Text));
                }

                Param.Param_Ord_LngCustomerID = Convert.ToInt32(com_Ord_LngCustomerID.SelectedItem.Value);

                if (txt_Ord_CurTotal.Text.Trim() != String.Empty)
                {
                    Param.Param_Ord_CurTotal = new System.Data.SqlTypes.SqlMoney(System.Convert.ToDecimal(txt_Ord_CurTotal.Text));
                }

                SP = new SPs.spI_tblOrder();

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

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