Beispiel #1
0
        private void UpdateRecordInDatabase()
        {
            Params.spU_tblOrder Param = new Params.spU_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;
            }

            Param.Param_Ord_GuidID = this.currentID;

            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.spU_tblOrder SP = new SPs.spU_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 update this record:\r\n\r\n" + Param.SqlException.Message, "Error");
                }
                else
                {
                    throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.Windows.Forms.WinForm_tblOrder", "UpdateRecordInDatabase");
                }
            }
        }
        public void Edit_tblOrder_Record(Tables.tblOrder_Record record)
        {
            Params.spU_tblOrder param = new Params.spU_tblOrder(false);

            param.SetUpConnection(string.Empty);

            param.Param_Ord_GuidID = record.Col_Ord_GuidID.Value;

            if (record.Col_Ord_DatOrderedOn == null || record.Col_Ord_DatOrderedOn.UseNull)
            {
                param.Param_ConsiderNull_Ord_DatOrderedOn = true;
                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_ConsiderNull_Ord_LngCustomerID = true;
                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_ConsiderNull_Ord_CurTotal = true;
                param.Param_Ord_CurTotal = SqlMoney.Null;
            }
            else if (!record.Col_Ord_CurTotal.UseDefault)
            {
                param.Param_Ord_CurTotal = record.Col_Ord_CurTotal.Value;
            }


            using (SPs.spU_tblOrder sp = new SPs.spU_tblOrder(true)) {
                sp.Execute(ref param);
                param.Dispose();
            }
        }
Beispiel #3
0
        public void Execute(WSGuid Ord_GuidID, WSDateTime Ord_DatOrderedOn, WSBoolean ConsiderNull_Ord_DatOrderedOn, WSInt32 Ord_LngCustomerID, WSBoolean ConsiderNull_Ord_LngCustomerID, WSDecimal Ord_CurTotal, WSBoolean ConsiderNull_Ord_CurTotal)
        {
            Params.spU_tblOrder param = new Params.spU_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 (ConsiderNull_Ord_DatOrderedOn == null || ConsiderNull_Ord_DatOrderedOn.UseNull)
            {
                param.Param_ConsiderNull_Ord_DatOrderedOn = SqlBoolean.Null;
            }
            else if (!ConsiderNull_Ord_DatOrderedOn.UseDefault)
            {
                param.Param_ConsiderNull_Ord_DatOrderedOn = ConsiderNull_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 (ConsiderNull_Ord_LngCustomerID == null || ConsiderNull_Ord_LngCustomerID.UseNull)
            {
                param.Param_ConsiderNull_Ord_LngCustomerID = SqlBoolean.Null;
            }
            else if (!ConsiderNull_Ord_LngCustomerID.UseDefault)
            {
                param.Param_ConsiderNull_Ord_LngCustomerID = ConsiderNull_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;
            }

            if (ConsiderNull_Ord_CurTotal == null || ConsiderNull_Ord_CurTotal.UseNull)
            {
                param.Param_ConsiderNull_Ord_CurTotal = SqlBoolean.Null;
            }
            else if (!ConsiderNull_Ord_CurTotal.UseDefault)
            {
                param.Param_ConsiderNull_Ord_CurTotal = ConsiderNull_Ord_CurTotal.Value;
            }

            using (SPs.spU_tblOrder sp = new SPs.spU_tblOrder(true)) {
                sp.Execute(ref param);
                param.Dispose();
            }
        }
Beispiel #4
0
        /// <summary>
        /// [To be supplied.]
        /// </summary>
        public void Update()
        {
            if (!this.recordWasLoadedFromDB)
            {
                throw new ArgumentException("No record was loaded from the database. No update is possible.");
            }

            bool ChangesHaveBeenMade = false;

            ChangesHaveBeenMade = (ChangesHaveBeenMade || col_Ord_DatOrderedOnWasUpdated);
            ChangesHaveBeenMade = (ChangesHaveBeenMade || col_Ord_LngCustomerIDWasUpdated);
            ChangesHaveBeenMade = (ChangesHaveBeenMade || col_Ord_CurTotalWasUpdated);

            if (!ChangesHaveBeenMade)
            {
                return;
            }

            bool alreadyOpened = false;

            Params.spU_tblOrder Param = new Params.spU_tblOrder(true);
            Param.CommandTimeOut = this.updateCommandTimeOut;
            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 = this.col_Ord_GuidID;

            if (this.col_Ord_DatOrderedOnWasUpdated)
            {
                Param.Param_Ord_DatOrderedOn = this.col_Ord_DatOrderedOn;
                Param.Param_ConsiderNull_Ord_DatOrderedOn = true;
            }
            else
            {
                Param.Param_Ord_DatOrderedOn = SqlDateTime.Null;
                Param.Param_ConsiderNull_Ord_DatOrderedOn = false;
            }

            if (this.col_Ord_LngCustomerIDWasUpdated)
            {
                Param.Param_Ord_LngCustomerID = this.col_Ord_LngCustomerID;
                Param.Param_ConsiderNull_Ord_LngCustomerID = true;
            }
            else
            {
                Param.Param_Ord_LngCustomerID = SqlInt32.Null;
                Param.Param_ConsiderNull_Ord_LngCustomerID = false;
            }

            if (this.col_Ord_CurTotalWasUpdated)
            {
                Param.Param_Ord_CurTotal = this.col_Ord_CurTotal;
                Param.Param_ConsiderNull_Ord_CurTotal = true;
            }
            else
            {
                Param.Param_Ord_CurTotal = SqlMoney.Null;
                Param.Param_ConsiderNull_Ord_CurTotal = false;
            }

            SPs.spU_tblOrder Sp = new SPs.spU_tblOrder(false);
            if (Sp.Execute(ref Param))
            {
                this.col_Ord_DatOrderedOnWasUpdated  = false;
                this.col_Ord_LngCustomerIDWasUpdated = false;
                this.col_Ord_CurTotalWasUpdated      = false;
            }
            else
            {
                throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.tblOrder_Record", "Update");
            }
            CloseConnection(Sp.Connection, alreadyOpened);
        }
Beispiel #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;
                    }
                }
            }
        }