Esempio n. 1
0
        private void UpdateRecordInDatabase()
        {
            Params.spU_tblOrderItem Param = new Params.spU_tblOrderItem(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_Oit_GuidID = this.currentID;

            if (Control_Oit_GuidOrderID.SelectedIndex != -1)
            {
                Param.Param_Oit_GuidOrderID = (System.Guid)Control_Oit_GuidOrderID.SelectedValue;
            }

            if (Control_Oit_GuidProductID.SelectedIndex != -1)
            {
                Param.Param_Oit_GuidProductID = (System.Guid)Control_Oit_GuidProductID.SelectedValue;
            }

            if (Control_Oit_LngAmount.Text.Trim() != String.Empty)
            {
                Param.Param_Oit_LngAmount = (System.Data.SqlTypes.SqlInt32)Control_Oit_LngAmount.GetSqlTypesValue;
            }

            SPs.spU_tblOrderItem SP = new SPs.spU_tblOrderItem(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_tblOrderItem", "UpdateRecordInDatabase");
                }
            }
        }
Esempio n. 2
0
        public void Edit_tblOrderItem_Record(Tables.tblOrderItem_Record record)
        {
            Params.spU_tblOrderItem param = new Params.spU_tblOrderItem(false);

            param.SetUpConnection(string.Empty);

            param.Param_Oit_GuidID = record.Col_Oit_GuidID.Value;

            if (record.Col_Oit_GuidOrderID == null || record.Col_Oit_GuidOrderID.UseNull)
            {
                param.Param_ConsiderNull_Oit_GuidOrderID = true;
                param.Param_Oit_GuidOrderID = SqlGuid.Null;
            }
            else if (!record.Col_Oit_GuidOrderID.UseDefault)
            {
                param.Param_Oit_GuidOrderID = record.Col_Oit_GuidOrderID.Value;
            }

            if (record.Col_Oit_GuidProductID == null || record.Col_Oit_GuidProductID.UseNull)
            {
                param.Param_ConsiderNull_Oit_GuidProductID = true;
                param.Param_Oit_GuidProductID = SqlGuid.Null;
            }
            else if (!record.Col_Oit_GuidProductID.UseDefault)
            {
                param.Param_Oit_GuidProductID = record.Col_Oit_GuidProductID.Value;
            }

            if (record.Col_Oit_LngAmount == null || record.Col_Oit_LngAmount.UseNull)
            {
                param.Param_ConsiderNull_Oit_LngAmount = true;
                param.Param_Oit_LngAmount = SqlInt32.Null;
            }
            else if (!record.Col_Oit_LngAmount.UseDefault)
            {
                param.Param_Oit_LngAmount = record.Col_Oit_LngAmount.Value;
            }


            using (SPs.spU_tblOrderItem sp = new SPs.spU_tblOrderItem(true)) {
                sp.Execute(ref param);
                param.Dispose();
            }
        }
        public void Execute(WSGuid Oit_GuidID, WSGuid Oit_GuidOrderID, WSBoolean ConsiderNull_Oit_GuidOrderID, WSGuid Oit_GuidProductID, WSBoolean ConsiderNull_Oit_GuidProductID, WSInt32 Oit_LngAmount, WSBoolean ConsiderNull_Oit_LngAmount)
        {
            Params.spU_tblOrderItem param = new Params.spU_tblOrderItem(true);
            param.SetUpConnection(string.Empty);

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

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

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

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

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

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

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

            using (SPs.spU_tblOrderItem sp = new SPs.spU_tblOrderItem(true)) {
                sp.Execute(ref param);
                param.Dispose();
            }
        }
Esempio n. 4
0
        private void cmdUpdate_Click(object sender, System.EventArgs e)
        {
            if (!CheckValues())
            {
                return;
            }

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

                Param = new Params.spU_tblOrderItem();

                Param.SetUpConnection(ConnectionString);

                Param.Param_Oit_GuidID = CurrentID;

                Param.Param_Oit_GuidOrderID = new Guid(com_Oit_GuidOrderID.SelectedItem.Value);

                Param.Param_Oit_GuidProductID = new Guid(com_Oit_GuidProductID.SelectedItem.Value);

                if (txt_Oit_LngAmount.Text.Trim() != String.Empty)
                {
                    Param.Param_Oit_LngAmount = new System.Data.SqlTypes.SqlInt32(System.Convert.ToInt32(txt_Oit_LngAmount.Text));
                }

                SP = new SPs.spU_tblOrderItem();

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

                Param = new Params.spI_tblOrderItem();

                Param.SetUpConnection(ConnectionString);

                Param.Param_Oit_GuidOrderID = new Guid(com_Oit_GuidOrderID.SelectedItem.Value);

                Param.Param_Oit_GuidProductID = new Guid(com_Oit_GuidProductID.SelectedItem.Value);

                if (txt_Oit_LngAmount.Text.Trim() != String.Empty)
                {
                    Param.Param_Oit_LngAmount = new System.Data.SqlTypes.SqlInt32(System.Convert.ToInt32(txt_Oit_LngAmount.Text));
                }

                SP = new SPs.spI_tblOrderItem();

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

                    if (Param.OtherException != null)
                    {
                        throw Param.OtherException;
                    }
                }
            }
        }
        /// <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_Oit_GuidOrderIDWasUpdated);
            ChangesHaveBeenMade = (ChangesHaveBeenMade || col_Oit_GuidProductIDWasUpdated);
            ChangesHaveBeenMade = (ChangesHaveBeenMade || col_Oit_LngAmountWasUpdated);

            if (!ChangesHaveBeenMade)
            {
                return;
            }

            bool alreadyOpened = false;

            Params.spU_tblOrderItem Param = new Params.spU_tblOrderItem(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_Oit_GuidID = this.col_Oit_GuidID;

            if (this.col_Oit_GuidOrderIDWasUpdated)
            {
                Param.Param_Oit_GuidOrderID = this.col_Oit_GuidOrderID;
                Param.Param_ConsiderNull_Oit_GuidOrderID = true;
            }
            else
            {
                Param.Param_Oit_GuidOrderID = SqlGuid.Null;
                Param.Param_ConsiderNull_Oit_GuidOrderID = false;
            }

            if (this.col_Oit_GuidProductIDWasUpdated)
            {
                Param.Param_Oit_GuidProductID = this.col_Oit_GuidProductID;
                Param.Param_ConsiderNull_Oit_GuidProductID = true;
            }
            else
            {
                Param.Param_Oit_GuidProductID = SqlGuid.Null;
                Param.Param_ConsiderNull_Oit_GuidProductID = false;
            }

            if (this.col_Oit_LngAmountWasUpdated)
            {
                Param.Param_Oit_LngAmount = this.col_Oit_LngAmount;
                Param.Param_ConsiderNull_Oit_LngAmount = true;
            }
            else
            {
                Param.Param_Oit_LngAmount = SqlInt32.Null;
                Param.Param_ConsiderNull_Oit_LngAmount = false;
            }

            SPs.spU_tblOrderItem Sp = new SPs.spU_tblOrderItem(false);
            if (Sp.Execute(ref Param))
            {
                this.col_Oit_GuidOrderIDWasUpdated   = false;
                this.col_Oit_GuidProductIDWasUpdated = false;
                this.col_Oit_LngAmountWasUpdated     = false;
            }
            else
            {
                throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.tblOrderItem_Record", "Update");
            }
            CloseConnection(Sp.Connection, alreadyOpened);
        }