public override void ShowViewForm(long id)
 {
     doData = DALichPhatSong.I.LoadAll(id);
     frmLichPhatSong frm = new frmLichPhatSong(doData, null);
     HelpProtocolForm.ShowModalDialog(this, frm);
 }
        private bool Save()
        {
            if (GetData())
            {
                if (DALichPhatSong.I.Update(doData))
                {
                    if (IsAdd == true)
                    {
                        if (this.parentFix != null)
                        {
                            parentFix.PLRefresh();
                        }
                        HelpMsgBox.ShowNotificationMessage("Lưu thông tin thành công!");
                        ResetControl();
                        EnableNhapAo = false;
                        doData = DALichPhatSong.I.LoadAll(-2);
                        return true;
                    }
                    else
                    {
                        return true;

                    }
                }
                else
                {
                    HelpPhieuMsg.ErrorSave(this);
                    return false;
                }
            } return false;
        }
Example #3
0
        public bool Compare(DOLichPhatSong OrtherMuonTra)
        {
            try
            {
                FieldInfo[] infos = typeof(DOLichPhatSong).GetFields();
                foreach (FieldInfo info in infos)
                {
                    if (info.Name == "NGUOI_CAP_NHAT" || info.Name == "NGAY_CAP_NHAT") continue;

                    object a = info.GetValue(this);
                    object b = info.GetValue(OrtherMuonTra);
                    if ((a == null && b != null) || a != null && b == null)
                        return false;
                    else if (a == null && b == null) continue;
                    if (info.FieldType == typeof(DataSet))
                    {
                        DataSet dsA = a as DataSet;
                        DataSet dsB = b as DataSet;

                        if (dsA.Tables.Count != dsB.Tables.Count)
                            return false;
                        foreach (DataTable dtA in dsA.Tables)
                        {
                            if (dsB.Tables.Contains(dtA.TableName) == false)
                                return false;
                            DataTable dtB = dsB.Tables[dtA.TableName];

                            if (dtA.Columns.Count == 0 && dtB.Columns.Count == 0) continue;
                            if (dtA.Columns.Count != dtB.Columns.Count)
                                return false;

                            if (dtA.Rows.Count == 0 && dtB.Rows.Count == 0) continue;
                            if (dtA.Rows.Count != dtB.Rows.Count)
                                return false;

                            foreach (DataColumn colA in dtA.Columns)
                            {
                                if (dtB.Columns.Contains(colA.ColumnName) == false)
                                    return false;
                                DataView viewA = dtA.DefaultView;
                                DataView viewB = dtB.DefaultView;
                                viewA.Sort = colA.ColumnName;
                                viewB.Sort = colA.ColumnName;
                                for (int i = 0; i < viewA.Count; i++)
                                {
                                    if (viewA[i][colA.ColumnName].Equals(viewB[i][colA.ColumnName]) == false)
                                        return false;
                                }
                            }

                        }
                    }
                    else
                    {
                        if (a.Equals(b) == false)
                            return false;
                    }

                }
                return true;
            }
            catch (Exception ex)
            {

            }
            return false;
        }
 private void InitControls(object id)
 {
     this.FormClosing += delegate(object sender, FormClosingEventArgs e)
     {
         if (NoConfirm == false && (IsAdd == true || IsAdd == false))
         {
             if (HelpMsgBox.ShowConfirmMessage("Bạn có muốn lưu không?") == DialogResult.Yes)
             {
                 if (Save() == false)
                     e.Cancel = true;
             }
         }
     };
     butXoa.Visible = IsAdd == false;
     butLuu.Visible = !(IsAdd == null);
     HelpControlExt.AutoSetTabIndex(this);
     DMTietMuc.InitCtrl(TietMuc, IsAdd == null);
     DMDaiTruyenHinh.InitCtrl(KenhPhat, IsAdd);
     DMNuocSanXuat.InitCtrl(QuocGia, IsAdd);
     txtNoiDung._Init(LichPhatSong.TABLE_NAME, LichPhatSong.NOI_DUNG, "");
     if (id is DOLichPhatSong)
     {
         doData = (DOLichPhatSong)id;
         dateNgayPhat.DateTime = doData.NGAY_PHAT_SONG;
         gioPhat.Time = doData.GIO_PHAT_SONG;
         KenhPhat._setSelectedID(doData.KENH_PHAT);
         txtNoiDung.Text = doData.NOI_DUNG;
         ThoiLuong.Text = doData.THOI_LUONG;
         TietMuc._setSelectedID(doData.TIET_MUC);
         maBang.Text = doData.MA_BANG;
         AppCtrl.SetDecimal(spinTapSo, doData.TAP_SO);
         ghiChu.Text = doData.GHI_CHU;
         checkPhatLai.Checked = doData.PHAT_LAI == "Y" ? true : false;
         checkCTMoi.Checked = !checkPhatLai.Checked;
         AppCtrl.SetMuitiValues(QuocGia, doData.NUOC_SAN_XUAT);
         if (doData.BM_ID >= 0) EnableNhapAo = true;
         if (IsAdd == null)
         {
             btnNhapAo.Enabled = false;
             Search.Enabled = false;
         }
     }
     else
     {
         doData = DALichPhatSong.I.LoadAll(-2);
         dateNgayPhat.DateTime = gioPhat.Time = DateTime.Now;
         dateNgayPhat.EditValue = null;
         gioPhat.EditValue = null;
         ThoiLuong.Text = "";
         spinTapSo.EditValue = null;
         ThoiLuong.Text = "";
     }
 }
Example #5
0
        public DOLichPhatSong Copy()
        {
            DOLichPhatSong pm = new DOLichPhatSong();

            try
            {
                FieldInfo[] infos = typeof(DOLichPhatSong).GetFields();
                foreach (FieldInfo info in infos)
                {
                    if (info.FieldType == typeof(DataSet))
                    {
                        object ds = info.GetValue(this);
                        if (ds == null) continue;
                        info.SetValue(pm, ((DataSet)ds).Copy());
                    }
                    else
                    {
                        info.SetValue(pm, info.GetValue(this));
                    }
                }
            }
            catch
            {

            }
            return pm;
        }