Exemple #1
0
        internal void LoadAll(Entities.TourCostGroupCollection groups)
        {
            using (SqlConnection cnn = new SqlConnection(sqlConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("TourCostGroupsGetAll", cnn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cnn.Open();

                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader != null && reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                Entities.TourCostGroup group = new Entities.TourCostGroup();

                                group.Id   = Utils.GetSafeInt32(reader, "GroupId");
                                group.Name = Utils.GetSafeString(reader, "GroupName");

                                groups.Add(group);
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
 private void btnRemoveGroup_Click(object sender, System.EventArgs e)
 {
     Entities.TourCostGroup group =
         (Entities.TourCostGroup)dgvGroups.SelectedItem;
     if (group != null)
     {
         Presentation.Controllers.TourFinance.DeleteGroup(group);
     }
 }
        public FrmTourCostGroupEditor()
        {
            InitializeComponent();

            this.group = new Entities.TourCostGroup();
            CreateControls();
            SetupControls();
            BindControls();
        }
Exemple #4
0
        internal bool Delete(Entities.TourCostGroup group)
        {
            bool res = false;

            using (SqlConnection cnn = new SqlConnection(sqlConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("TourCostGroupDeleteById", cnn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@GroupId", group.Id));
                    cnn.Open();

                    int affected = cmd.ExecuteNonQuery();
                    res = (affected > 0);
                }
            }

            return(res);
        }
Exemple #5
0
        void dgvGroups_SelectionChanged(object sender, System.EventArgs e)
        {
            if (this.dgvGroups.SelectedItem != null)
            {
                Entities.TourCostGroup group =
                    (Entities.TourCostGroup)dgvGroups.SelectedItem;
                if (group == null)
                {
                }
                else
                {
                    if (this.clbRules.Group != group)
                    {
                        this.clbRules.Group = group;
                    }

                    this.clbRules.UpdateBinding();
                }
            }
        }
Exemple #6
0
        internal bool Insert(Entities.TourCostGroup group)
        {
            bool res = false;

            using (SqlConnection cnn = new SqlConnection(sqlConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("TourCostGroupAdd", cnn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("@GroupName", group.Name));
                    cnn.Open();

                    object id = cmd.ExecuteScalar();
                    if (id != null)
                    {
                        group.Id = Convert.ToInt32(id);
                        res      = true;
                    }
                }
            }

            return(res);
        }
 public FrmTourCostGroupEditor(Entities.TourCostGroup group = null)
     : this()
 {
     group.CopyTo(this.group);
     this.editGroup = group;
 }