public static int Insert(DBLayer.ClientsAbonements.Details det)
        {
            var    adet   = DBLayer.Clients.GetCurrentAbonement(det.ClientId);
            string actual = "0";

            if (adet.Id == 0)
            {
                SetToNull(det.ClientId);
                actual = "1";
            }



            string sql = "INSERT INTO ClientsAbonements (ClientId, AbonementId, DateStart, DateFinish, IsActual, VisitsCount, AdditionalVisitsCount, CoachId, Weekday, [Time]) ";

            sql += " VALUES (" + det.ClientId.ToString() + ", " + det.AbonementId.ToString() + ", '" + det.DateStart.ToString("yyyyMMdd") + "', '" + det.DateFinish.ToString("yyyyMMdd") + "', " + actual + ", " + det.VisitsCount.ToString() + ", " + det.AdditionalCount.ToString() + ", " + det.CoachId.ToString() + ", '" + det.Weekdays + "', '" + det.Time + "')";

            ZFort.DB.Execute.ExecuteString_void(sql);

            sql = "SELECT Max(Id) FROM ClientsAbonements";

            int id = 0;

            id = (int)ZFort.DB.Execute.ExecuteString_Scalar(sql);

            return(id);
        }
        public CtrlCoachesOnVisit(int cId)
        {
            InitializeComponent();

            DBLayer.Abonements.Details aDet = DBLayer.Abonements.GetClientLast(cId);

            if (aDet.Id != 0)
            {
                DBLayer.ClientsAbonements.Details caDet = DBLayer.ClientsAbonements.GetDetails(cId, aDet.Id);

                if ((caDet.Id != 0))
                {
                    if (caDet.CoachId != 0)
                    {
                        DBLayer.Coaches.Details coDet = DBLayer.Coaches.GetDetails(caDet.CoachId);

                        if ((coDet.Id != 0))
                        {
                            lblCoach.Text = DBLayer.Coaches.GetDetails(caDet.CoachId).Name;
                        }
                    }
                    lblTime.Text     = caDet.Time;
                    lblWeekdays.Text = caDet.Weekdays;
                }
            }

            LoadData();
        }
Beispiel #3
0
        public CtrlBoxType(DBLayer.Clients.Details det)
        {
            InitializeComponent();

            int id = det.Sex;

            DBLayer.Abonements.Details aDet = DBLayer.Abonements.GetClientLast(det.Id);

            lblAbonement.Text = aDet.Name;
            lblFIO.Text       = det.FIO;


            DBLayer.ClientsAbonements.Details caDet = DBLayer.ClientsAbonements.GetDetails(det.Id, aDet.Id);

            if (caDet.CoachId != 0)
            {
                lblCoach.Text = DBLayer.Coaches.GetDetails(caDet.CoachId).Name;
            }

            lblTime.Text     = caDet.Time;
            lblWeekdays.Text = caDet.Weekdays;

            try
            {
                lblFinishDate.Text = DBLayer.ClientsAbonements.GetFinishDate(det.Id, aDet.Id).ToString("dd-MMM-yyyy");
            }
            catch
            {
            }

            int doubleBox = DBLayer.Boxes.GetList(1, id);

            int singleBox = DBLayer.Boxes.GetList(2, id);

            if (id == 0)
            {
                int val = 0;

                val = singleBox;

                singleBox = doubleBox;
                doubleBox = val;
            }

            lblSingle.Text = (singleBox - DBLayer.Boxes.GetReserved(1, id).Count).ToString();

            lblDouble.Text = (doubleBox - DBLayer.Boxes.GetReserved(2, id).Count).ToString();
        }
Beispiel #4
0
        public FrmEditClientAbonement(int id)
        {
            InitializeComponent();

            this.Id = id;

            DBLayer.ClientsAbonements.Details det = DBLayer.ClientsAbonements.GetDetails(id);

            this.CADetails = det;

            LoadAbonements(det.AbonementId);
            LoadCoaches(1);

            tbTime.Text     = det.Time;
            tbWeekdays.Text = det.Weekdays;

            tbFinishDate.Text = det.DateFinish.ToString("dd-MMM-yyyy");
            tbStartDate.Text  = det.DateStart.ToString("dd-MMM-yyyy");
        }
Beispiel #5
0
        private void LoadClient()
        {
            if (this.Details.Id != 0)
            {
                lblMyVisits.Visible      = true;
                lblMyVisitsCount.Visible = true;
                lblVisitsCount.Visible   = true;
                lblVisitsLabel.Visible   = true;
                btnVisit.Visible         = true;

                lblClient.Text = this.Details.FIO;

                DBLayer.Abonements.Details aDet = DBLayer.Clients.GetCurrentAbonement(this.Details.Id);
                if (aDet.Id != 0)
                {
                    lblAbonement.Text = aDet.Name;

                    if (aDet.AdditionalVisits > 0)
                    {
                        lblVisitsCount.Text = aDet.AdditionalVisits.ToString();

                        DBLayer.ClientsAbonements.Details caDet = DBLayer.ClientsAbonements.GetDetails(this.Details.Id, aDet.Id);

                        lblMyVisits.Text = caDet.AdditionalCount.ToString();

                        if (caDet.AdditionalCount > 0)
                        {
                            this.CADetails   = caDet;
                            btnVisit.Enabled = true;
                        }
                        else
                        {
                            btnVisit.Enabled = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Данный абонемент не предусматривает дополнительных посещений!");
                    }
                }
            }
        }
        public static void Update(DBLayer.ClientsAbonements.Details det)
        {
            ZFort.DB.Execute.ExecuteString_void("UPDATE ClientsAbonements SET [ClientId] = " + det.ClientId.ToString() + " WHERE [Id] = " + det.Id.ToString());

            ZFort.DB.Execute.ExecuteString_void("UPDATE ClientsAbonements SET [CoachId] = " + det.CoachId.ToString() + " WHERE [Id] = " + det.Id.ToString());

            ZFort.DB.Execute.ExecuteString_void("UPDATE ClientsAbonements SET [AbonementId] = " + det.AbonementId.ToString() + " WHERE [Id] = " + det.Id.ToString());

            ZFort.DB.Execute.ExecuteString_void("UPDATE ClientsAbonements SET [VisitsCount] = " + det.VisitsCount.ToString() + " WHERE [Id] = " + det.Id.ToString());

            ZFort.DB.Execute.ExecuteString_void("UPDATE ClientsAbonements SET [AdditionalVisitsCount] = " + det.AdditionalCount.ToString() + " WHERE [Id] = " + det.Id.ToString());

            ZFort.DB.Execute.ExecuteString_void("UPDATE ClientsAbonements SET [DateStart] = '" + det.DateStart.ToString("yyyyMMdd") + "' WHERE [Id] = " + det.Id.ToString());

            ZFort.DB.Execute.ExecuteString_void("UPDATE ClientsAbonements SET [Weekday] = '" + det.Weekdays + "' WHERE [Id] = " + det.Id.ToString());

            ZFort.DB.Execute.ExecuteString_void("UPDATE ClientsAbonements SET [Time] = '" + det.Time + "' WHERE [Id] = " + det.Id.ToString());

            ZFort.DB.Execute.ExecuteString_void("UPDATE ClientsAbonements SET [DateFinish] = '" + det.DateFinish.ToString("yyyyMMdd") + "' WHERE [Id] = " + det.Id.ToString());
        }
        public static void Delete(int id)
        {
            string user = ((DBLayer.Users.Details)AppDomain.CurrentDomain.GetData("User")).FIO;

            DBLayer.ClientsAbonements.Details det = DBLayer.ClientsAbonements.GetDetails(id);

            DBLayer.Clients.Details cDet = DBLayer.Clients.GetDetails(det.ClientId);

            DBLayer.Abonements.Details aDet = DBLayer.Abonements.GetDetails(det.AbonementId);

            DBLayer.DeletingLog.DeletingLog_Details dlDet = new DeletingLog.DeletingLog_Details();

            dlDet.Date = DateTime.Now;
            dlDet.Name = aDet.Name + "/" + cDet.FIO + "(" + aDet.Cost.ToString() + ")";
            dlDet.Type = 0;
            dlDet.User = user;

            DBLayer.DeletingLog.Insert(dlDet);

            ZFort.DB.Execute.ExecuteString_void("DELETE FROM ClientsAbonements WHERE [Id] = " + id.ToString());
        }
Beispiel #8
0
        public CtrlInfo(DBLayer.Clients.Details det, DateTime date, int number, int type, bool key, int coachId)
        {
            InitializeComponent();

            this.Details    = det;
            this.Date       = date;
            this.Type       = type;
            this.Number     = number;
            this.WithoutKey = key;
            this.CoachId    = coachId;


            LoadCoaches();

            string text = "";

            switch (type)
            {
            case 1:
                text = "Женский";
                break;

            case 2:
                text = "Мужской";
                break;

            case 3:
                text = "Женский";
                break;

            case 4:
                text = "Мужской";
                break;
            }

            lblClient.Text = det.FIO;

            byte[] result = DBLayer.Clients.DownloadPhoto(det.Id);
            try
            {
                MemoryStream ms = new MemoryStream(result, 0, result.Length);
                Image        im = Image.FromStream(ms);
                pbPhoto.Image = im;
            }
            catch (Exception ee)
            {
                pbPhoto.Image = null;
            }

            DBLayer.Abonements.Details aDet = DBLayer.Abonements.GetClientLast(det.Id);

            lblAbonement.Text = aDet.Name;
            lblTime.Text      = aDet.Time;
            lblWeekdays.Text  = aDet.Weekdays;
            try
            {
                lblCoach.Text = DBLayer.Coaches.GetDetails(aDet.CoachId).Name;
            }
            catch
            {
                lblCoach.Text = "Не указан";
            }

            DBLayer.ClientsAbonements.Details caDet = DBLayer.ClientsAbonements.GetDetails(det.Id, aDet.Id);

            CADetails = caDet;

            if (caDet.VisitsCount > 0)
            {
                lblVisitCount.Text = caDet.VisitsCount.ToString();
            }

            lblDate.Text   = date.ToString("dd-MMM-yyyy hh mm");
            lblNumber.Text = number.ToString() + " " + text;
        }
Beispiel #9
0
        private void btnFinish_Click(object sender, EventArgs e)
        {
            DBLayer.Visits.Visits_Details det = new FitnessProject.DBLayer.Visits.Visits_Details();

            DBLayer.Abonements.Details aDet = DBLayer.Abonements.GetClientLast(this.Details.Id);

            int number = Lib.ServiceFunctions.WeekdayToNumber();

            DBLayer.ClientsAbonements.Details caDet = DBLayer.ClientsAbonements.GetDetails(this.Details.Id, aDet.Id);

            if (caDet.Weekdays.IndexOf(number.ToString()) == -1)
            {
                if (MessageBox.Show("Клиент пришел не в свой день. Все равно пропустить его?", Lib.StringConstants.ProjectName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    MessageBox.Show("Невозможно пропустить клиента в зал! График не соблюден!", Lib.StringConstants.ProjectName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            /*MessageBox.Show(this.Type.ToString());
             * MessageBox.Show(this.Details.Sex.ToString());
             * MessageBox.Show(this.Number.ToString());*/

            //MessageBox.Show(this.Type.ToString());

            if (this.Details.Sex == 1)
            {
                this.Type = 1;
            }

            det.BoxId      = DBLayer.Boxes.GetId(this.Type, this.Details.Sex, this.Number);
            det.ClientId   = this.Details.Id;
            det.Date       = DateTime.Now;
            det.Time       = DateTime.Now.ToShortTimeString();
            det.Type       = 0;
            det.TimeOff    = "";
            det.WithoutKey = this.WithoutKey;
            det.CoachId    = this.CoachId;

            if (((Lib.ServiceFunctions.ListItem)cbCoaches.SelectedItem).ID != 0)
            {
                det.IsSubstitution = true;

                det.CoachId = ((Lib.ServiceFunctions.ListItem)cbCoaches.SelectedItem).ID;
            }


            bool val = true;

            DBLayer.Abonements.Details aDetails = DBLayer.Abonements.GetDetails(CADetails.AbonementId);

            if (aDetails.IsSpecial)
            {
                if (MessageBox.Show("Учитывать посещение к тренеру?", Lib.StringConstants.ProjectName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    val = false;
                }
            }

            if (val)
            {
                CADetails.VisitsCount--;

                DBLayer.ClientsAbonements.Update(CADetails);

                det.CoachId = ((Lib.ServiceFunctions.ListItem)cbCoaches.SelectedItem).ID;
            }

            DBLayer.Visits.Insert(det);

            SimulateFinish();
        }