示例#1
0
        private void AddRecordInDatabase()
        {
            Params.spI_Job Param = new Params.spI_Job(false);

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

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

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

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

            if (Control_StartDate.Text.Trim() != String.Empty)
            {
                Param.Param_StartDate = (System.Data.SqlTypes.SqlDateTime)Control_StartDate.GetSqlTypesValue;
            }

            if (Control_EndDate.Text.Trim() != String.Empty)
            {
                Param.Param_EndDate = (System.Data.SqlTypes.SqlDateTime)Control_EndDate.GetSqlTypesValue;
            }

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

            SPs.spI_Job SP = new SPs.spI_Job(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 Bob.DataClasses.CustomException(Param, "Bob.Windows.Forms.WinForm_Job", "AddRecordInDatabase");
                }
            }
        }
示例#2
0
        private void UpdateRecordInDatabase()
        {
            Params.spU_JobPartType Param = new Params.spU_JobPartType(false);

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

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

            Param.Param_JobPartTypeId = this.currentID;

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

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

            SPs.spU_JobPartType SP = new SPs.spU_JobPartType(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 Bob.DataClasses.CustomException(Param, "Bob.Windows.Forms.WinForm_JobPartType", "UpdateRecordInDatabase");
                }
            }
        }
示例#3
0
        private void AddRecordInDatabase()
        {
            Params.spI_Title Param = new Params.spI_Title(false);

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

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

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

            SPs.spI_Title SP = new SPs.spI_Title(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 Bob.DataClasses.CustomException(Param, "Bob.Windows.Forms.WinForm_Title", "AddRecordInDatabase");
                }
            }
        }