コード例 #1
0
ファイル: whdMstrDataAccess.cs プロジェクト: msza/wh_mgmt
        public void UpdateWhdMstr(model.whdMstrModel in_whdMstr)
        {
            //UPDATE BY ID
            string sqlCommandWhdMstr =
                "update whd_mstr set " +
                "whdm_date = @whdm_date, " +
                "whdm_nbr = @whdm_nbr, " +
                "whdm_cust = @whdm_cust, " +
                "whdm_name = @whdm_name, " +
                "whdm_netto = @whdm_netto, " +
                "whdm_brutto = @whdm_brutto " +
                "where whdm_id = @whdm_id";

            try {
                using (TransactionScope scope = new TransactionScope()) {
                    using (SqlConnection connection = new SqlConnection()) {
                        connection.Open();
                        using (SqlCommand SqlCmd = new SqlCommand(sqlCommandWhdMstr, connection)) {
                            SqlCmd.Parameters.Add("@whdm_date", SqlDbType.DateTime);
                            SqlCmd.Parameters.Add("@whdm_nbr", SqlDbType.NVarChar);
                            SqlCmd.Parameters.Add("@whdm_cust", SqlDbType.NVarChar);
                            SqlCmd.Parameters.Add("@whdm_name", SqlDbType.NVarChar);
                            SqlCmd.Parameters.Add("@whdm_netto", SqlDbType.Decimal);
                            SqlCmd.Parameters.Add("@whdm_brutto", SqlDbType.Decimal);
                            SqlCmd.Parameters.Add("@whdm_id", SqlDbType.Int);

                            SqlCmd.Parameters["@whdm_date"].Value   = in_whdMstr.Whdm_date;
                            SqlCmd.Parameters["@whdm_nbr"].Value    = in_whdMstr.Whdm_nbr;
                            SqlCmd.Parameters["@whdm_cust"].Value   = in_whdMstr.Whdm_cust;
                            SqlCmd.Parameters["@whdm_name"].Value   = in_whdMstr.Whdm_name;
                            SqlCmd.Parameters["@whdm_netto"].Value  = in_whdMstr.Whdm_netto;
                            SqlCmd.Parameters["@whdm_brutto"].Value = in_whdMstr.Whdm_brutto;
                            SqlCmd.Parameters["@whdm_id"].Value     = in_whdMstr.Whdm_id;

                            foreach (SqlParameter sqlParameter in SqlCmd.Parameters)
                            {
                                if (sqlParameter.Value == null)
                                {
                                    sqlParameter.Value = DBNull.Value;
                                }
                            }
                            SqlCmd.ExecuteNonQuery();
                        }
                        trhMstrDataAccess trhist = new trhMstrDataAccess();
                        trhist.CreateTrhMstr(connection, in_whdMstr, "UPDATED");
                    }
                    scope.Complete();
                }
            } catch (Exception) {
                throw;
            }
        }
コード例 #2
0
ファイル: whdMstrDataAccess.cs プロジェクト: msza/wh_mgmt
        public void DeleteWhdMstr(model.whdMstrModel in_whdMstr)
        {
            //DELETE BY ID
            string sqlcommandWhdMstr =
                "delete from whd_mstr where whdm_id = @whdm_id";
            string sqlcommandWhdDet =
                "delete from whd_det where whdd_whdm_id = @whdm_id";

            try {
                using (TransactionScope scope = new TransactionScope()) {
                    using (SqlConnection connection = new SqlConnection()) {
                        connection.Open();
                        using (SqlCommand SqlCmd = new SqlCommand(sqlcommandWhdMstr, connection)) {
                            SqlCmd.Parameters.Add("@whdm_id", SqlDbType.Int);

                            SqlCmd.Parameters["@whdm_id"].Value = in_whdMstr.Whdm_id;

                            foreach (SqlParameter sqlParameter in SqlCmd.Parameters)
                            {
                                if (sqlParameter.Value == null)
                                {
                                    sqlParameter.Value = DBNull.Value;
                                }
                            }
                            SqlCmd.ExecuteNonQuery();
                        }
                        using (SqlCommand SqlCmd = new SqlCommand(sqlcommandWhdDet, connection)) {
                            SqlCmd.Parameters.Add("@whdm_id", SqlDbType.Int);

                            SqlCmd.Parameters["@whdm_id"].Value = in_whdMstr.Whdm_id;

                            foreach (SqlParameter sqlParameter in SqlCmd.Parameters)
                            {
                                if (sqlParameter.Value == null)
                                {
                                    sqlParameter.Value = DBNull.Value;
                                }
                            }
                            SqlCmd.ExecuteNonQuery();
                        }
                        trhMstrDataAccess trhist = new trhMstrDataAccess();
                        trhist.CreateTrhMstr(connection, in_whdMstr, "DELETED");
                    }
                    scope.Complete();
                }
            } catch (Exception Ex) {
                throw;
            }
        }
コード例 #3
0
ファイル: whdMstrDataAccess.cs プロジェクト: msza/wh_mgmt
        public void CreateWhdMstr(model.whdMstrModel in_whdMstr)
        {
            //CREATE BY NEXT ID - SQL SHOULD HANDLE ID NUMERATION
            string sqlCommandWhdMstr =
                "insert into whd_mstr " +
                "(whdm_date, whdm_nbr, whdm_cust, whdm_name, whdm_netto, whdm_brutto) " +
                "values " +
                "(@whdm_date, @whdm_nbr, @whdm_cust, @whdm_name, @whdm_netto, @whdm_brutto)";

            try {
                using (TransactionScope scope = new TransactionScope()) {
                    using (SqlConnection connection = new SqlConnection()) {
                        connection.Open();
                        using (SqlCommand SqlCmd = new SqlCommand(sqlCommandWhdMstr, connection)) {
                            SqlCmd.Parameters.Add("@whdm_date", SqlDbType.DateTime);
                            SqlCmd.Parameters.Add("@whdm_nbr", SqlDbType.NVarChar);
                            SqlCmd.Parameters.Add("@whdm_cust", SqlDbType.NVarChar);
                            SqlCmd.Parameters.Add("@whdm_name", SqlDbType.NVarChar);
                            SqlCmd.Parameters.Add("@whdm_netto", SqlDbType.Decimal);
                            SqlCmd.Parameters.Add("@whdm_brutto", SqlDbType.Decimal);

                            SqlCmd.Parameters["@whdm_date"].Value   = in_whdMstr.Whdm_date;
                            SqlCmd.Parameters["@whdm_nbr"].Value    = in_whdMstr.Whdm_nbr;
                            SqlCmd.Parameters["@whdm_cust"].Value   = in_whdMstr.Whdm_cust;
                            SqlCmd.Parameters["@whdm_name"].Value   = in_whdMstr.Whdm_name;
                            SqlCmd.Parameters["@whdm_netto"].Value  = in_whdMstr.Whdm_netto;
                            SqlCmd.Parameters["@whdm_brutto"].Value = in_whdMstr.Whdm_brutto;

                            foreach (SqlParameter sqlParameter in SqlCmd.Parameters)
                            {
                                if (sqlParameter.Value == null)
                                {
                                    sqlParameter.Value = DBNull.Value;
                                }
                            }
                            SqlCmd.ExecuteNonQuery();
                        }
                        trhMstrDataAccess trhist = new trhMstrDataAccess();
                        trhist.CreateTrhMstr(connection, in_whdMstr, "CREATED");
                    }
                    scope.Complete();
                }
            } catch (Exception Ex) {
                throw;
            }
        }
コード例 #4
0
ファイル: trhMstrDataAccess.cs プロジェクト: msza/wh_mgmt
        //TRANSACTION HISTORY MASTER DATA ACCESS

        #region FIELDS



        #endregion

        #region CONSTRUCTORS



        #endregion

        #region DESTRUCTORS



        #endregion

        #region EVENTS



        #endregion

        #region PROPERTIES



        #endregion

        #region METHODS
        public void CreateTrhMstr(SqlConnection connection,
                                  model.whdMstrModel in_whd_mstr,
                                  string in_tr_type)
        {
            string sqlcommand =
                "insert into trhMstr " +
                "(trh_docid, trh_eff_date, trh_tr_type) " +
                "values " +
                "(@trh_docid, @trh_eff_date, @trh_tr_type)";

            if (connection != null && connection.State == ConnectionState.Closed)
            {
                try {
                    using (SqlCommand SqlCmd = new SqlCommand(sqlcommand, connection)) {
                        SqlCmd.Parameters.Add("@trh_docid", SqlDbType.Int);
                        SqlCmd.Parameters.Add("@trh_eff_date", SqlDbType.DateTime);
                        SqlCmd.Parameters.Add("@trh_ty_type", SqlDbType.NVarChar);

                        SqlCmd.Parameters["@trh_docid"].Value    = in_whd_mstr.Whdm_id;
                        SqlCmd.Parameters["@trh_eff_date"].Value = DateTime.UtcNow;
                        SqlCmd.Parameters["trh_tr_type"].Value   = in_tr_type;

                        foreach (SqlParameter sqlParameter in SqlCmd.Parameters)
                        {
                            if (sqlParameter.Value == null)
                            {
                                sqlParameter.Value = DBNull.Value;
                            }
                        }

                        SqlCmd.ExecuteNonQuery();
                    }
                } catch (Exception ex) {
                    throw;
                }
            }
        }
コード例 #5
0
ファイル: whdMstrDataAccess.cs プロジェクト: msza/wh_mgmt
        public model.whdMstrModel ReadWhdMstr(model.whdMstrModel in_whdMstr)
        {
            model.whdMstrModel retWhdMstrModel = new model.whdMstrModel();

            return(retWhdMstrModel);
        }