private void detach_CTPMs(CTPM entity)
 {
     this.SendPropertyChanging();
     entity.SACH = null;
 }
Ejemplo n.º 2
0
        private void btMuon_Click(object sender, EventArgs e)
        {
            string   ngay_hen = dtpkNgay_hen_tra.Value.Date.ToShortDateString();
            DateTime ngayhen  = Convert.ToDateTime(ngay_hen);
            TimeSpan limit    = ngayhen - DateTime.Now;

            if (DateTime.Now > ngayhen)
            {
                this.errorProvider1.SetError(dtpkNgay_hen_tra, "Ngay hen tra phai sau ngay cho muon.");
            }
            else
            {
                if (limit.Days > 60)
                {
                    this.errorProvider1.SetError(dtpkNgay_hen_tra, "Ngay muon toi da la 60 ngay");
                }
                else
                {
                    this.errorProvider1.Clear();
                    if (tbMa_doc_gia.Text != "")
                    {
                        var c = from b in a.PHIEUMUONs
                                orderby b.MAPHIEUMUON descending
                                select b;
                        string t = "";
                        foreach (var tmp1 in c)
                        {
                            t = tmp1.MAPHIEUMUON;
                            break;
                        }
                        t = t.Remove(0, 2);
                        if (tbMa_sach_1.Text != "" || tbMa_sach_2.Text != "")
                        {
                            DateTime mm = Convert.ToDateTime(DateTime.Now.ToShortDateString());

                            string tmp = "PM";
                            if ((Convert.ToInt32(t) + 1) < 10)
                            {
                                tmp += "0";
                            }
                            phieu_muon PM = new phieu_muon(tmp + (Convert.ToInt32(t) + 1).ToString(),
                                                           tbMa_doc_gia.Text, mm,
                                                           ngayhen, tbMa_sach_1.Text, tbMa_sach_2.Text);
                            ds_PM.add(PM);
                            loadlistPM();
                            add_lvSach();
                            MessageBox.Show("Cho muon thanh cong");
                            PHIEUMUON PMmoi = new PHIEUMUON();
                            PMmoi.MAPHIEUMUON = tmp + (Convert.ToInt32(t) + 1).ToString();
                            PMmoi.MADOCGIA    = tbtim_Ma_doc_gia.Text;
                            PMmoi.NGAYHENTRA  = ngayhen;
                            PMmoi.NGAYMUON    = mm;
                            a.PHIEUMUONs.InsertOnSubmit(PMmoi);
                            CTPM ctpm_moi1 = new CTPM();
                            CTPM ctpm_moi2 = new CTPM();
                            ctpm_moi1.MAPHIEUMUON = tmp + (Convert.ToInt32(t) + 1).ToString();
                            ctpm_moi2.MAPHIEUMUON = tmp + (Convert.ToInt32(t) + 1).ToString();
                            if (PM.Ma_sach_1 != "")
                            {
                                ctpm_moi1.MASACH = PM.Ma_sach_1;
                                a.CTPMs.InsertOnSubmit(ctpm_moi1);
                                a.SubmitChanges();
                            }
                            if (PM.Ma_sach_2 != "")
                            {
                                ctpm_moi2.MASACH = PM.Ma_sach_2;
                                a.CTPMs.InsertOnSubmit(ctpm_moi2);
                                a.SubmitChanges();
                            }

                            loadlistPM(); cleardata();
                        }
                        else
                        {
                            MessageBox.Show("Chua chon sach");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Chua nhap ma doc gia");
                    }
                }
            }
        }
 private void attach_CTPMs(CTPM entity)
 {
     this.SendPropertyChanging();
     entity.SACH = this;
 }
 private void attach_CTPMs(CTPM entity)
 {
     this.SendPropertyChanging();
     entity.PHIEUMUON = this;
 }
 partial void DeleteCTPM(CTPM instance);
 partial void UpdateCTPM(CTPM instance);
 partial void InsertCTPM(CTPM instance);