예제 #1
0
        public List <DistributorMaster> GetAllDistributors()
        {
            List <DistributorMaster> DistributorList = new List <DistributorMaster>();

            try
            {
                using (DbCommand command = _db.GetStoredProcCommand(Constants.SpGetAllDistributors))
                {
                    using (DbConnection connection = _db.CreateConnection())
                    {
                        connection.Open();

                        command.Connection = connection;

                        using (IDataReader reader = command.ExecuteReader())
                        {
                            SqlDataReader dr = (SqlDataReader)reader;
                            if (dr.HasRows)
                            {
                                while (dr.Read())
                                {
                                    string            CreatedOn   = String.Empty;
                                    DistributorMaster distributor = new DistributorMaster();
                                    distributor.DistributorId           = Convert.ToInt32(dr["DistributorId"]);
                                    distributor.ARN                     = Convert.ToString(dr["ARN_NO"]);
                                    distributor.MergCode                = Convert.ToString(dr["Merg_CODE"]);
                                    distributor.DistributorName         = Convert.ToString(dr["DistributorName"]);
                                    distributor.DistributorCategoryName = Convert.ToString(dr["DistributorCategoryName"]);
                                    distributor.DistributorCategoryId   = Convert.ToInt32(dr["DistributorCategoryId"]);
                                    distributor.SubRegionId             = Convert.ToInt32(dr["SubRegionId"]);
                                    distributor.SubRegion               = Convert.ToString(dr["SubRegionName"]);
                                    distributor.TaxNo                   = Convert.ToString(dr["TaxNo"]);
                                    distributor.DistributorParentId     = Convert.ToString(dr["DistributorParentId"]);
                                    distributor.DistributorStatus       = Convert.ToBoolean(dr["IsActive"]) ? "Active" : "Inactive";
                                    distributor.CreatedOn               = Convert.ToString(dr["CreatedOn"]);
                                    DistributorList.Add(distributor);
                                }
                            }
                        }

                        connection.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(DistributorList);
        }
예제 #2
0
        public string InsertUpdateDistributor(DistributorMaster distributor)
        {
            string result = string.Empty;

            try
            {
                DistirbutorBL bl = new DistirbutorBL();
                result = bl.InsertUpdateDistributor(distributor);
            }
            catch (Exception ex)
            {
                throw;
            }
            return(result);
        }
예제 #3
0
        public string InsertUpdateDistributor(DistributorMaster distributor)
        {
            string result = string.Empty;

            try
            {
                using (DbCommand command = _db.GetStoredProcCommand(Constants.SpInsertUpdateDistributor))
                {
                    using (DbConnection connection = _db.CreateConnection())
                    {
                        connection.Open();
                        command.Connection = connection;

                        var parameter = command.CreateParameter();
                        parameter.ParameterName = "@DistributorId";
                        parameter.Value         = distributor.DistributorId;
                        command.Parameters.Add(parameter);

                        parameter = command.CreateParameter();
                        parameter.ParameterName = "@ARN_NO";
                        parameter.Value         = distributor.ARN;
                        command.Parameters.Add(parameter);

                        parameter = command.CreateParameter();
                        parameter.ParameterName = "@Merg_CODE";
                        parameter.Value         = distributor.MergCode;
                        command.Parameters.Add(parameter);

                        parameter = command.CreateParameter();
                        parameter.ParameterName = "@DistributorName";
                        parameter.Value         = distributor.DistributorName;
                        command.Parameters.Add(parameter);

                        parameter = command.CreateParameter();
                        parameter.ParameterName = "@DistributorCategoryId";
                        parameter.Value         = distributor.DistributorCategoryId;
                        command.Parameters.Add(parameter);

                        parameter = command.CreateParameter();
                        parameter.ParameterName = "@SubRegionId";
                        parameter.Value         = distributor.SubRegionId;
                        command.Parameters.Add(parameter);

                        parameter = command.CreateParameter();
                        parameter.ParameterName = "@TaxNo";
                        parameter.Value         = distributor.TaxNo;
                        command.Parameters.Add(parameter);

                        parameter = command.CreateParameter();
                        parameter.ParameterName = "@DistributorParentId";
                        parameter.Value         = distributor.DistributorParentId;
                        command.Parameters.Add(parameter);

                        parameter = command.CreateParameter();
                        parameter.ParameterName = "@IsActive";
                        parameter.Value         = distributor.DistributorStatus;
                        command.Parameters.Add(parameter);

                        result = command.ExecuteScalar().ToString();
                        connection.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(result);
        }