예제 #1
0
        private void calendar1_ItemDoubleClick(object sender, CalendarItemEventArgs e)
        {
            Visit visit1 = new Visit(Convert.ToInt32(userID), e.Item.StartDate);

            if (e.Item.ID == null)
            {
                e.Item.ID = "0";
            }
            if ((e.Item.ID == "0") && (!visit1.canEditPlan) && (!visit1.canEditFact))
            {
                calendar1.Items.RemoveAt(calendar1.Items.Count - 1);
                MessageBox.Show("Невозможно добавить план в прошлое", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            AddEditVisitPlanDay aeVPD;

            if (e.Item.ID != "0")
                aeVPD = new AddEditVisitPlanDay(new Visit(Convert.ToInt32(e.Item.ID), Convert.ToInt32(userID)));
            else
                aeVPD = new AddEditVisitPlanDay(visit1);

            if ((aeVPD.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) && (e.Item.ID == "0"))
                calendar1.Items.RemoveAt(calendar1.Items.Count - 1);
        }
예제 #2
0
        public Visit(Visit visit1, DateTime date)
        {
            _id = 0;
            this._idUser = visit1._idUser;
            this._dateVisit = date;
            this._idULPU = visit1._idULPU;
            this._plan = visit1._plan;

            _fact = string.Empty;
            _next = string.Empty;
            _idActivity = 1;
            _commRD = string.Empty;
            _status = VisitStatus.Planed;
            _haveNewVisit = false;

            Init();
            SetDefaultHour();
            SetEditRightVisit();
        }
예제 #3
0
        private void calendar1_ItemDeleting(object sender, CalendarItemCancelEventArgs e)
        {
            Visit visit1 = new Visit(Convert.ToInt32(e.Item.ID), userID);

            if (!visit1.canEditPlan)
            {
                MessageBox.Show("Невозможно удалить план в прошлом", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                e.Cancel = true;
                return;
            }

            if ((visit1.CommRD != "") && (globalData.UserAccess > 4))
            {
                MessageBox.Show("С комментариями руководителя нельзя удалить план", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                e.Cancel = true;
            }
            else
            {
                visit1.Delete();
                globalData.update = true;
            }
        }
        public AddEditVisitPlanDay(Visit visit1)
        {
            InitializeComponent();

            this.visit1 = visit1;

            DataTable dt1 = new DataTable();

            dt1 = visit1.GetULPUList();
            fillComboBox(dt1, cbULPU, "ulpu_sname", "ulpu_id");

            dt1 = Activity.getDataTable();
            fillComboBox(dt1, cbActivity, "act_name", "act_id");

            globalData.load = false;
            dt1 = VisitPlanStatus.getDataTable();
            fillComboBox(dt1, cbStatus, "vpst_name", "vpst_id");
            globalData.load = true;

            cbULPU.SelectedValue = visit1.IdULPU;
            tbPlan.Text = visit1.Plan;
            tbFact.Text = visit1.Fact;
            tbNext.Text = visit1.Next;
            cbActivity.SelectedValue = visit1.IdActivity;
            commRD.Text = visit1.CommRD;
            cbStatus.SelectedValue = (int)visit1.Status;

            if (visit1.HaveNewVisitDate)
            {
                enabledNewVisit.Checked = true;
                dateNewVisit.Value = visit1.NewVisitDate;
            }

            setComboBoxEnabled();

            setTextBoxReadlyOnly();
        }
        private void AddEditVisitPlanList_Load(object sender, EventArgs e)
        {
            Sql sql1 = new Sql();
            DataTable dt1 = sql1.GetRecords("exec SelVisitPlanByUser @p1, @p2", userID, date);

            int y = 0, i = 0;

            visit1 = new Visit[dt1.Rows.Count];

            gb1 = new GroupBox[dt1.Rows.Count];
            cb1 = new ComboBox[dt1.Rows.Count, 3];
            lb1 = new Label[dt1.Rows.Count, 7];
            tb1 = new TextBox[dt1.Rows.Count, 4];
            btn1 = new Button[dt1.Rows.Count, 2];
            check1 = new CheckBox[dt1.Rows.Count];
            dateNew1 = new DateTimePicker[dt1.Rows.Count];
            tbCommentRD = new string[dt1.Rows.Count];

            foreach (DataRow row in dt1.Rows)
            {
                visit1[i] = new Visit(Convert.ToInt32(row.ItemArray[0]), Convert.ToInt32(userID));

                gb1[i] = new GroupBox();

                gb1[i].Location = new Point(10, 40 + y);
                gb1[i].Size = new Size(807, 320);
                gb1[i].Name = "gb" + row[0].ToString();

                DateTime date2 = Convert.ToDateTime(row[2]);
                if (date2.Hour < 10)
                    gb1[i].Text = "0" + date2.Hour.ToString() + ":00";
                else
                    gb1[i].Text = date2.Hour.ToString() + ":00";

                lb1[i, 0] = new Label();
                lb1[i, 0].Location = new Point(8, 20);
                lb1[i, 0].Text = "Статус:";
                lb1[i, 0].Size = new Size(44, 13);
                gb1[i].Controls.Add(lb1[i, 0]);

                lb1[i, 1] = new Label();
                lb1[i, 1].Location = new Point(134, 20);
                lb1[i, 1].Text = "Название ЛПУ:";
                lb1[i, 1].Size = new Size(87, 13);
                gb1[i].Controls.Add(lb1[i, 1]);

                lb1[i, 2] = new Label();
                lb1[i, 2].Location = new Point(311, 20);
                lb1[i, 2].Text = "Вид деятельности:";
                lb1[i, 2].Size = new Size(102, 13);
                gb1[i].Controls.Add(lb1[i, 2]);

                lb1[i, 3] = new Label();
                lb1[i, 3].Location = new Point(8, 67);
                lb1[i, 3].Text = "1 - План действий:";
                lb1[i, 3].Size = new Size(101, 13);
                gb1[i].Controls.Add(lb1[i, 3]);

                lb1[i, 4] = new Label();
                lb1[i, 4].Location = new Point(271, 67);
                lb1[i, 4].Text = "2 - Выполнение:";
                lb1[i, 4].Size = new Size(88, 13);
                gb1[i].Controls.Add(lb1[i, 4]);

                lb1[i, 5] = new Label();
                lb1[i, 5].Location = new Point(535, 67);
                lb1[i, 5].Text = "3 - Последующие шаги:";
                lb1[i, 5].Size = new Size(125, 13);
                gb1[i].Controls.Add(lb1[i, 5]);

                lb1[i, 6] = new Label();
                lb1[i, 6].Location = new Point(8, 197);
                lb1[i, 6].Text = "Комментарии руководителя:";
                lb1[i, 6].Size = new Size(153, 13);
                gb1[i].Controls.Add(lb1[i, 6]);

                cb1[i, 0] = new ComboBox();
                cb1[i, 0].Location = new Point(10, 35);
                cb1[i, 0].Size = new Size(105, 21);
                cb1[i, 0].DropDownStyle = ComboBoxStyle.DropDownList;
                cb1[i, 0].FormattingEnabled = true;
                cb1[i, 0].Name = "cmb" + i.ToString();

                DataTable dt2 = new DataTable();
                dt2 = sql1.GetRecords("exec SelVPStatus");
                fillComboBox(dt2, cb1[i, 0], "vpst_name", "vpst_id");
                cb1[i, 0].Enabled = canChangeStatus(visit1[i]);
                cb1[i, 0].SelectedValueChanged += new EventHandler(valid);
                gb1[i].Controls.Add(cb1[i, 0]);

                cb1[i, 1] = new ComboBox();
                cb1[i, 1].Location = new Point(137, 35);
                cb1[i, 1].Size = new Size(171, 21);
                cb1[i, 1].DropDownStyle = ComboBoxStyle.DropDownList;

                DataTable dt3 = new DataTable();
                dt3 = sql1.GetRecords("exec SelULPUbyUserIDVisPlan @p1", userID);
                fillComboBox(dt3, cb1[i, 1], "ulpu_sname", "ulpu_id");
                cb1[i, 1].Enabled = !readlyOnlyEditPlan(visit1[i]);
                gb1[i].Controls.Add(cb1[i, 1]);

                cb1[i, 2] = new ComboBox();
                cb1[i, 2].Location = new Point(314, 35);
                cb1[i, 2].Size = new Size(171, 21);
                cb1[i, 2].DropDownStyle = ComboBoxStyle.DropDownList;

                DataTable dt4 = new DataTable();
                dt4 = sql1.GetRecords("exec SelActivity");
                fillComboBox(dt4, cb1[i, 2], "act_name", "act_id");
                cb1[i, 2].Enabled = !readlyOnlyEditPlan(visit1[i]);
                gb1[i].Controls.Add(cb1[i, 2]);

                tb1[i, 0] = new TextBox();
                tb1[i, 0].Location = new Point(10, 83);
                tb1[i, 0].Multiline = true;
                tb1[i, 0].MaxLength = 500;
                tb1[i, 0].Size = new Size(258, 110);
                tb1[i, 0].Text = row.ItemArray[6].ToString();
                tb1[i, 0].Name = "txb0" + i.ToString();
                tb1[i, 0].TextChanged += new EventHandler(valid);
                tb1[i, 0].MouseDoubleClick += new MouseEventHandler(tbPlan_MouseDoubleClick);

                tb1[i, 0].ReadOnly = readlyOnlyEditPlan(visit1[i]);
                gb1[i].Controls.Add(tb1[i, 0]);

                tb1[i, 1] = new TextBox();
                tb1[i, 1].Location = new Point(274, 83);
                tb1[i, 1].Multiline = true;
                tb1[i, 1].MaxLength = 500;
                tb1[i, 1].Size = new Size(258, 110);
                tb1[i, 1].Text = row.ItemArray[7].ToString();
                tb1[i, 1].Name = "txb1" + i.ToString();
                tb1[i, 1].TextChanged += new EventHandler(valid);
                tb1[i, 1].MouseDoubleClick += new MouseEventHandler(tbFact_MouseDoubleClick);
                tb1[i, 1].ReadOnly = readlyOnlyEditFact(visit1[i]);
                gb1[i].Controls.Add(tb1[i, 1]);

                tb1[i, 2] = new TextBox();
                tb1[i, 2].Location = new Point(538, 83);
                tb1[i, 2].Multiline = true;
                tb1[i, 2].MaxLength = 500;
                tb1[i, 2].Size = new Size(258, 110);
                tb1[i, 2].Text = row.ItemArray[8].ToString();
                tb1[i, 2].Name = "txb2" + i.ToString();
                tb1[i, 2].TextChanged += new EventHandler(valid);
                tb1[i, 2].MouseDoubleClick += new MouseEventHandler(tbNext_MouseDoubleClick);
                tb1[i, 2].ReadOnly = readlyOnlyEditFact(visit1[i]);
                gb1[i].Controls.Add(tb1[i, 2]);

                tb1[i, 3] = new TextBox();
                tb1[i, 3].Location = new Point(11, 213);
                tb1[i, 3].Multiline = true;
                tb1[i, 3].MaxLength = 500;
                tb1[i, 3].Size = new Size(500, 100);
                tb1[i, 3].Text = row.ItemArray[10].ToString();
                tb1[i, 3].TextChanged += new EventHandler(valid);
                tb1[i, 3].MouseDoubleClick += new MouseEventHandler(tbCom_MouseDoubleClick);
                tb1[i, 3].ReadOnly = readlyOnlyAddCommRD(visit1[i]);
                tbCommentRD[i] = row.ItemArray[10].ToString().Trim();
                gb1[i].Controls.Add(tb1[i, 3]);

                check1[i] = new CheckBox();
                check1[i].Location = new Point(538, 197);
                check1[i].Text = "Назначена новая встреча";
                check1[i].Size = new Size(157, 17);
                check1[i].Name = "chk" + i.ToString();
                if (row.ItemArray[14].ToString() != String.Empty)
                    check1[i].Checked = true;
                check1[i].CheckedChanged += new EventHandler(checkBox1_CheckedChanged);
                gb1[i].Controls.Add(check1[i]);

                dateNew1[i] = new DateTimePicker();
                dateNew1[i].Location = new Point(538, 220);
                dateNew1[i].Name = "date" + i.ToString();
                if (row.ItemArray[14].ToString() != String.Empty)
                    dateNew1[i].Value = Convert.ToDateTime(row.ItemArray[14].ToString());
                else
                    dateNew1[i].Visible = false;
                dateNew1[i].Size = new Size(139, 20);
                dateNew1[i].ValueChanged += new EventHandler(dateNewVisit_ValueChanged);
                gb1[i].Controls.Add(dateNew1[i]);

                btn1[i, 0] = new Button();
                btn1[i, 0].Location = new Point(725, 290);
                btn1[i, 0].Size = new Size(75, 23);
                btn1[i, 0].Text = "Сохранить";
                btn1[i, 0].Name = "btn0" + i.ToString();
                btn1[i, 0].Click += new EventHandler(button1_Click);
                gb1[i].Controls.Add(btn1[i, 0]);

                btn1[i, 1] = new Button();
                btn1[i, 1].Location = new Point(690, 215);
                btn1[i, 1].Size = new Size(113, 23);
                btn1[i, 1].Text = "Создать визит";
                btn1[i, 1].Name = "btn1" + i.ToString();
                btn1[i, 1].Click += new EventHandler(button2_Click);
                if (row.ItemArray[14].ToString() == String.Empty)
                    btn1[i, 1].Visible = false;
                gb1[i].Controls.Add(btn1[i, 1]);

                y += 330;
                i++;
            }

            this.Controls.AddRange(gb1);
        }
 private bool readlyOnlyEditPlan(Visit visit1)
 {
     if (visit1.IsMyVisit(globalData.UserID))
         return !visit1.canEditPlan;
     else
         return true;
 }
 private bool readlyOnlyAddCommRD(Visit visit1)
 {
     return visit1.IsMyVisit(globalData.UserID);
 }
 private bool canChangeStatus(Visit visit1)
 {
     if (visit1.IsMyVisit(globalData.UserID))
         return visit1.canEditFact;
     else
         return true;
 }