Exemple #1
0
        public int UpdateTerritoryWiseSBGAndBrand(List <BO.Brand> objList)
        {
            try
            {
                int returnStatus     = 0;
                int transationStatus = 0;
                using (var connection = new DCommon().CreateCon())
                {
                    SqlDataAdapter da = new SqlDataAdapter();
                    da.SelectCommand = connection.CreateCommand();
                    SqlTransaction transaction = null;

                    try
                    {
                        // BeginTransaction() Requires Open Connection
                        if (connection.State == System.Data.ConnectionState.Closed)
                        {
                            connection.Open();
                        }
                        transaction = connection.BeginTransaction();
                        // Assign Transaction to Command
                        da.SelectCommand.Connection  = connection;
                        da.SelectCommand.Transaction = transaction;

                        foreach (var obj in objList)
                        {
                            da.SelectCommand.CommandText = "DCR_SP_DELETE_TerritoryWiseSBGAndBrand";
                            da.SelectCommand.CommandType = CommandType.StoredProcedure;
                            da.SelectCommand.Connection  = connection;
                            da.SelectCommand.Parameters.Add("@TerritoryID", System.Data.SqlDbType.BigInt).Value = obj.TerritoryID;
                            da.SelectCommand.Parameters.Add("@BrandID", System.Data.SqlDbType.Int).Value        = obj.BrandID;
                            //da.SelectCommand.Parameters.Add("@SBGID", System.Data.SqlDbType.Int).Value = obj.SBGID;
                            transationStatus = da.SelectCommand.ExecuteNonQuery();
                            if (transationStatus <= 0)
                            {
                                transaction.Rollback();
                                break;
                            }

                            da.SelectCommand.Parameters.Clear();
                        }
                        transaction.Commit();
                        returnStatus = 1;
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                        returnStatus = 0;
                    }
                    finally
                    {
                        if (connection.State == System.Data.ConnectionState.Open)
                        {
                            connection.Close();
                        }
                    }
                }
                return(returnStatus);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public int UpdateSBGWiseBrand(BO.Brand objBrand)
        {
            try
            {
                int retunstatus      = 0;
                int transationStatus = 0;
                using (var connection = new DCommon().CreateCon())
                {
                    SqlDataAdapter da = new SqlDataAdapter();
                    da.SelectCommand = connection.CreateCommand();
                    SqlTransaction transaction = null;
                    try
                    {
                        // BeginTransaction() Requires Open Connection
                        if (connection.State == System.Data.ConnectionState.Closed)
                        {
                            connection.Open();
                        }
                        transaction = connection.BeginTransaction();
                        // Assign Transaction to Command
                        da.SelectCommand.Connection  = connection;
                        da.SelectCommand.Transaction = transaction;
                        da.SelectCommand.CommandText = "DCR_SP_Update_Brand";
                        da.SelectCommand.CommandType = CommandType.StoredProcedure;
                        da.SelectCommand.Parameters.Add("@BrandID", System.Data.SqlDbType.BigInt).Value                = objBrand.BrandID;
                        da.SelectCommand.Parameters.Add("@BrandName", System.Data.SqlDbType.VarChar, 100).Value        = objBrand.BrandName;
                        da.SelectCommand.Parameters.Add("@BrandDescription", System.Data.SqlDbType.VarChar, 500).Value = objBrand.BrandDescription;
                        da.SelectCommand.CommandType = CommandType.StoredProcedure;
                        da.SelectCommand.Connection  = connection;
                        transationStatus             = da.SelectCommand.ExecuteNonQuery();
                        da.SelectCommand.Parameters.Clear();
                        if (transationStatus <= 0)
                        {
                            transaction.Rollback();
                            //break;
                        }
                        else
                        {
                            //foreach (var objSBG in objBrand.SBGBrnadList)
                            //{
                            //    if (objSBG.IsNewData == true)
                            //    {
                            //        #region InsertBrandWiseSBG
                            //        da.SelectCommand.CommandText = "DCR_SP_INSERT_BrandWiseSBG";
                            //        da.SelectCommand.Parameters.Add("@BrandID", System.Data.SqlDbType.Int).Value = objBrand.BrandID;
                            //        da.SelectCommand.Parameters.Add("@SBGID", System.Data.SqlDbType.Int).Value = objSBG.SBGID;
                            //        da.SelectCommand.CommandType = CommandType.StoredProcedure;
                            //        transationStatus = da.SelectCommand.ExecuteNonQuery();
                            //        da.SelectCommand.Parameters.Clear();
                            //        #endregion

                            //    }
                            //    if (objSBG.IsDelete == true)
                            //    {
                            //        #region DeleteBrandWiseSBG
                            //        da.SelectCommand.CommandText = "DCR_SP_DELETE_SBGWiseBrand";
                            //        da.SelectCommand.Parameters.Add("@BrandID", System.Data.SqlDbType.BigInt).Value = objBrand.BrandID;
                            //        da.SelectCommand.Parameters.Add("@SBGID", System.Data.SqlDbType.Int).Value = objSBG.SBGID;
                            //        da.SelectCommand.CommandType = CommandType.StoredProcedure;
                            //        transationStatus = da.SelectCommand.ExecuteNonQuery();
                            //        da.SelectCommand.Parameters.Clear();
                            //        #endregion
                            //    }
                            //}
                        }

                        transaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        transaction.Rollback();
                    }
                    finally
                    {
                        if (connection.State == System.Data.ConnectionState.Open)
                        {
                            connection.Close();
                        }
                        if (transationStatus == 1)
                        {
                            retunstatus = 1;
                        }
                    }
                }
                return(retunstatus);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }