Ejemplo n.º 1
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_Sup_StrNameWasUpdated);

            if (!ChangesHaveBeenMade)
            {
                return;
            }

            bool alreadyOpened = false;

            Params.spU_tblSupplier Param = new Params.spU_tblSupplier(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_Sup_GuidID = this.col_Sup_GuidID;

            if (this.col_Sup_StrNameWasUpdated)
            {
                Param.Param_Sup_StrName = this.col_Sup_StrName;
                Param.Param_ConsiderNull_Sup_StrName = true;
            }
            else
            {
                Param.Param_Sup_StrName = SqlString.Null;
                Param.Param_ConsiderNull_Sup_StrName = false;
            }

            SPs.spU_tblSupplier Sp = new SPs.spU_tblSupplier(false);
            if (Sp.Execute(ref Param))
            {
                this.col_Sup_StrNameWasUpdated = false;
            }
            else
            {
                throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.Supplier", "Update");
            }
            CloseConnection(Sp.Connection, alreadyOpened);
        }
Ejemplo n.º 2
0
        private void UpdateRecordInDatabase()
        {
            Params.spU_tblSupplier Param = new Params.spU_tblSupplier(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_Sup_GuidID = this.currentID;

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

            SPs.spU_tblSupplier SP = new SPs.spU_tblSupplier(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_tblSupplier", "UpdateRecordInDatabase");
                }
            }
        }
Ejemplo n.º 3
0
        public void Execute(WSGuid Sup_GuidID, WSString Sup_StrName, WSBoolean ConsiderNull_Sup_StrName)
        {
            Params.spU_tblSupplier param = new Params.spU_tblSupplier(true);
            param.SetUpConnection(string.Empty);

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

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

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

            using (SPs.spU_tblSupplier sp = new SPs.spU_tblSupplier(true)) {
                sp.Execute(ref param);
                param.Dispose();
            }
        }
Ejemplo n.º 4
0
        public void Edit_Supplier(Tables.Supplier record)
        {
            Params.spU_tblSupplier param = new Params.spU_tblSupplier(false);

            param.SetUpConnection(string.Empty);

            param.Param_Sup_GuidID = record.Col_Sup_GuidID.Value;

            if (record.Col_Sup_StrName == null || record.Col_Sup_StrName.UseNull)
            {
                param.Param_ConsiderNull_Sup_StrName = true;
                param.Param_Sup_StrName = SqlString.Null;
            }
            else if (!record.Col_Sup_StrName.UseDefault)
            {
                param.Param_Sup_StrName = record.Col_Sup_StrName.Value;
            }


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

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

                Param = new Params.spU_tblSupplier();

                Param.SetUpConnection(ConnectionString);

                Param.Param_Sup_GuidID = CurrentID;

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

                SP = new SPs.spU_tblSupplier();

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

                Param = new Params.spI_tblSupplier();

                Param.SetUpConnection(ConnectionString);

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

                SP = new SPs.spI_tblSupplier();

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

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