示例#1
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            if (gridView1.SelectedRowsCount == 0)
            {
                return;
            }
            DataRow drLSX = gridView1.GetDataRow(gridView1.GetSelectedRows()[0]);
            DataRow dr    = ctLichSX.NewRow();

            dr["MTLSXID"]      = drLSX["MTLSXID"];
            dr["DTLSXID"]      = drLSX["DTLSXID"];
            dr["CTLSXID"]      = drLSX["CTLSXID"];
            dr["MaMin"]        = drLSX["MaMin"];
            dr["SoCT"]         = drLSX["SoCT"];
            dr["NgayGiao"]     = drLSX["NgayGiao"];
            dr["GhiChu"]       = drLSX["GhiChu"];
            dr["Description1"] = drLSX["Description1"];
            dr["MaKH"]         = drLSX["MaKH"];
            dr["TenKH"]        = drLSX["TenKH"];
            dr["MaVT"]         = drLSX["MaVT"];
            dr["TenHang"]      = drLSX["TenHang"];
            dr["SoLuong"]      = drLSX["SoLuong"];
            dr["TrangThai"]    = 0;
            dr["SLDaNhap"]     = 0;
            if (schedu.SelectedInterval == null)
            {
                dr["TuNgayKH"]    = DateTime.Parse(DateTime.Now.ToShortDateString());
                dr["DenNgayKH"]   = DateTime.Parse(DateTime.Parse(dr["TuNgayKH"].ToString()).AddHours(2).ToString());
                dr["TongsoGioKH"] = 2;
            }
            else
            {
                dr["TuNgayKH"]    = schedu.SelectedInterval.Start;
                dr["DenNgayKH"]   = schedu.SelectedInterval.End;
                dr["TongsoGioKH"] = schedu.SelectedInterval.Duration.TotalHours;// + schedu.SelectedInterval.Duration.Minutes/60;
            }

            LSXappoint apt = new LSXappoint(schedu, dr, ref ctTangCa);

            // apt.Start = DateTime.Parse(DateTime.Now.ToShortDateString());
            //  apt.End = DateTime.Parse(DateTime.Parse(dr["TuNgayKH"].ToString()).AddHours(2).ToString());

            fAppoint Af = new fAppoint(schedu, apt, false);

            if (Af.ShowDialog() == DialogResult.OK)
            {
                ctLichSXBind.Add(apt);
                ctLichSX.Rows.Add(dr);
                LSXChuaSapLich.Rows.Remove(drLSX);
                LSXChuaSapLich.AcceptChanges();
            }
        }
示例#2
0
        private void Schedu_EditAppointmentFormShowing(object sender, AppointmentFormEventArgs e)
        {
            List <LSXappoint> x = ctLichSXBind.ToList();

            if (e.Appointment.CustomFields["ctID"] == null)
            {
                e.Handled = true;
                fTangca fTca;
                if (schedu.SelectedInterval != null)
                {
                    fTca = new fTangca(schedu.SelectedInterval, schedu.SelectedResource);
                }
                else
                {
                    fTca = new fTangca(new TimeInterval(e.Appointment.Start, e.Appointment.End), null);
                }
                fTca.ctTangca = this.ctTangCa.Clone();
                DataRow drTangca = findTangca(schedu.SelectedInterval, schedu.SelectedResource);

                if (drTangca != null)
                {
                    DataRow dr = fTca.ctTangca.NewRow();
                    dr.ItemArray = (object[])drTangca.ItemArray.Clone();
                    fTca.ctTangca.Rows.Add(dr);
                }
                fTca.dmMIn = dmMayin;

                if (fTca.ShowDialog() == DialogResult.OK)
                {
                    if (fTca.ctTangca.Rows.Count > 0)
                    {
                        if (drTangca == null)
                        {
                            DataRow dr = this.ctTangCa.NewRow();
                            dr.ItemArray = (object[])fTca.ctTangca.Rows[0].ItemArray.Clone();
                            ctTangCa.Rows.Add(dr);
                        }
                        ctTangCa.AcceptChanges();
                        //Tính lại DenNgayKH
                        foreach (LSXappoint apt1 in x)
                        {
                            apt1.ctTangCa = ctTangCa;
                            if (apt1.TrangThai < 2) //khởi tạo hoặc đang chạy
                            {
                                apt1.TongSoGioKH = apt1.TongSoGioKH;
                            }
                        }
                        schedu.RefreshData();
                    }
                }
                return;
            }
            else
            {
                e.Handled = true;
            }
            LSXappoint apt = x.Find(m => m.ctLichSXID.ToString() == e.Appointment.CustomFields["ctID"].ToString());

            if (apt != null)
            {
                fAppoint fA = new fAppoint(schedu, apt, false);
                if (fA.ShowDialog() == DialogResult.OK)
                {
                    e.Appointment.Start = apt.Start;
                    e.Appointment.End   = apt.End;
                }
            }
        }