Example #1
0
        public bool Update(DatabaseFB db, DbTransaction dbTrans, DOPhieuX DOX)
        {
            //Dữ liệu cần cập nhật vào KHO TON KHO từ KhoTonKho
            Object obj = DOX.GetAttr(KhoPhieuLienQuan.AttrName);
            PLTransaction plTrans = new PLTransaction(db, dbTrans);

            if (obj != null)
            {
                DOPhieuLienQuan PLQ = (DOPhieuLienQuan)obj;

                DOObjRel1N Obj1N = PLQ.Obj1N;
                if (Obj1N != null)
                {
                    //Danh sách tạo từ chương trình
                    List<DOFWObjRelData> listObjRel = KhoTonKhoHelp.GetData(
                        plTrans, Obj1N.OBJ_SRC_TYPE, Obj1N.OBJ_SRC_ID, DOX);
                    return UpdateX(plTrans, listObjRel, DOX);
                }
            }
            else
            {
                //Danh sách tạo từ chương trình
                List<DOFWObjRelData> listObjRel = KhoTonKhoHelp.GetData(
                    plTrans, 0, 0, DOX);
                return UpdateX(plTrans, listObjRel, DOX);
            }
            return true;
        }
Example #2
0
        public bool Delete(DatabaseFB db, DbTransaction dbTrans, DOPhieuX DOX)
        {
            ITonKho data = (ITonKho)DOX;
            long ky_id = KhoTonKhoHelp.GetKy(new PLTransaction(db, dbTrans), data.GetNgayPhatSinh());
            PLTransaction plTrans = new PLTransaction(db, dbTrans);
            //Danh sách tạo từ chương trình
            List<DOFWObjRelData> listObjRel = KhoTonKhoHelp.GetData(plTrans, 0, 0, DOX);

            //Cập nhật tồn kho từ kỳ hiện tại trở về sau
            foreach (DOFWObjRelData ObjRel in listObjRel)
                KhoTonKhoHelp.CapNhatNhapXuatChuyen(plTrans, ObjRel, 3,ky_id);

            //Xóa phiếu phát sinh
            return DAFWObjRelData.I.Delete(new PLTransaction(db, dbTrans),
                ky_id, DOX.GetID(), DOX.GetPhieuType().GetTypeID());
        }
        public DataTable TimKiem(DateTime InputNgayDauTuan)
        {
            try
            {
                string sql = "select llv.*, nv.NAME from LICH_LAM_VIEC llv, DM_NHAN_VIEN nv where nv.ID = llv.NV_ID and NGAY_DAU_TUAN = @NGAY_DAU_TUAN order by nv.NAME";
                ds = new DataSet();
                db = HelpDB.getDatabase();
                cmd = db.GetSQLStringCommand(sql);
                db.AddInParameter(cmd, "@NGAY_DAU_TUAN", System.Data.DbType.DateTime, InputNgayDauTuan);
                db.LoadDataSet(cmd, ds, "LICH_LAM_VIEC");
                return ds.Tables[0];
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);

            }
        }
 public bool Insert_LichTuan(DOLichLamViec dto)
 {
     if (Exist_LichTuanNhanVien(dto.NGAY_DAU_TUAN, dto.NV_ID))
         return false;
     string sql = "Insert into LICH_LAM_VIEC(ID,NV_ID,NGAY_DAU_TUAN,ST2,CT2,ST3,CT3,ST4,CT4,ST5,CT5,ST6,CT6,ST7,CT7,ST8,CT8,GHI_CHU) values(@ID,@NV_ID,@NGAY_DAU_TUAN,";
     for (int i = 0; i < dto.NGAY.Length; i++)
     {
         sql += "'" + dto.NGAY[i] + "',";
     }
     sql += "'" + dto.GHI_CHU + "')";
     db = HelpDB.getDatabase();
     cmd = db.GetSQLStringCommand(sql);
     if (dto.ID.ToString() != "")
         db.AddInParameter(cmd, "@ID", System.Data.DbType.Int64, dto.ID);
     else
         db.AddInParameter(cmd, "@ID", System.Data.DbType.Int64, getGenID());
     db.AddInParameter(cmd, "@NV_ID", System.Data.DbType.Int64, dto.NV_ID);
     db.AddInParameter(cmd, "@NGAY_DAU_TUAN", System.Data.DbType.DateTime, dto.NGAY_DAU_TUAN);
     if (db.ExecuteNonQuery(cmd) > 0)
         return true;
     return false;
 }
 public bool Insert_LichCoDinh(DOLichLamViec dto)
 {
     if (this.Exist_LCDNhanVien(dto.NV_ID))
         return false;
     string sql = "Insert into LICH_LAM_VIEC(ID,NV_ID,ST2,CT2,ST3,CT3,ST4,CT4,ST5,CT5,ST6,CT6,ST7,CT7,ST8,CT8,GHI_CHU) values(@ID,@NV_ID,";
     for (int i = 0; i < dto.NGAY.Length; i++)
     {
         sql += "'" + dto.NGAY[i] + "',";
     }
     sql += "@GHI_CHU)";
     db = HelpDB.getDatabase();
     cmd = db.GetSQLStringCommand(sql);
     db.AddInParameter(cmd, "@ID", System.Data.DbType.Int64, dto.ID);
     db.AddInParameter(cmd, "@NV_ID", System.Data.DbType.Int64, dto.NV_ID);
     db.AddInParameter(cmd, "@GHI_CHU", System.Data.DbType.String, dto.GHI_CHU);
     if (db.ExecuteNonQuery(cmd) > 0)
         return true;
     return false;
 }
 public DataTable getLichMoiNhat()
 {
     string sql = "SELECT llv.*,nv.NAME "
                 + "FROM LICH_LAM_VIEC llv , DM_NHAN_VIEN nv "
                 + "WHERE nv.ID = llv.NV_ID "
                 + "AND llv.NGAY_DAU_TUAN = (SELECT MAX(llv1.NGAY_DAU_TUAN) FROM  LICH_LAM_VIEC  llv1) "
                 + "AND 1=1 ORDER BY nv.NAME DESC";
     db = HelpDB.getDatabase();
     ds = db.LoadDataSet(sql,"AA");
     if (ds != null)
         return ds.Tables[0];
     return null;
 }
        public DataTable getLichCoDinh()
        {
            try
            {
                string sql = "select llv.*, nv.NAME "
                            + "from LICH_LAM_VIEC llv, DM_NHAN_VIEN nv "
                            + "where nv.ID = llv.NV_ID "
                            + "and NGAY_DAU_TUAN is null order by nv.NAME";
                ds = new DataSet();
                db = HelpDB.getDatabase();
                cmd = db.GetSQLStringCommand(sql);
                db.LoadDataSet(cmd, ds, "LICH_LAM_VIEC");
                return ds.Tables[0];
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);

            }
        }
 public bool Exist_LichTuanNhanVien(DateTime Ngay, long NV_ID)
 {
     string sql = "select * from LICH_LAM_VIEC where NV_ID = @NV_ID and NGAY_DAU_TUAN = @NGAY";
     db = HelpDB.getDatabase();
     cmd = db.GetSQLStringCommand(sql);
     db.AddInParameter(cmd, "@NV_ID", DbType.Int64, NV_ID);
     db.AddInParameter(cmd, "@NGAY", DbType.DateTime, Ngay);
     if (db.LoadDataSet(cmd, "AA").Tables[0].Rows.Count > 0)
         return true;
     return false;
 }
 public bool Exist_LCDNhanVien(long NV_ID)
 {
     string sql = "select * from LICH_LAM_VIEC where NV_ID = @NV_ID and NGAY_DAU_TUAN is null";
     db = HelpDB.getDatabase();
     cmd = db.GetSQLStringCommand(sql);
     db.AddInParameter(cmd, "@NV_ID", DbType.Int64, NV_ID);
     DataSet ds = new DataSet();
     db.LoadDataSet(cmd, ds, "AA");
     if (ds.Tables[0].Rows.Count > 0)
         return true;
     return false;
 }
 public bool DeleteRow(long ID, long NV_ID)
 {
     string sql = "delete from LICH_LAM_VIEC where NV_ID = @NV_ID and ID = @ID";
     db = HelpDB.getDatabase();
     cmd = db.GetSQLStringCommand(sql);
     db.AddInParameter(cmd, "@NV_ID", DbType.Int64, NV_ID);
     db.AddInParameter(cmd, "@ID", DbType.Int64, ID);
     if (db.ExecuteNonQuery(cmd) > 0)
         return true;
     return false;
 }
 public void update(DbCommand cmd, DbTransaction dbTrans, DatabaseFB db, DOBangTheoDoi doBangTheoDoi)
 {
     cmd = db.GetSQLStringCommand("update BANG_THEO_DOI set name=@name,ngay_lap=@ngay_lap,nguoi_lap=@nguoi_lap,ngay_ky=@ngay_ky,nguoi_ky=@nguoi_ky,ngay_hieu_luc=@ngay_hieu_luc,nguoi_quan_ly=@nguoi_quan_ly,tai_lieu=@tai_lieu,ten_tai_lieu=@ten_tai_lieu,tinh_trang=@tinh_trang,hinh_thuc_thong_bao=@hinh_thuc_thong_bao,ghi_chu=@ghi_chu,nguoi_cap_nhat=@nguoi_cap_nhat,ngay_cap_nhat=@ngay_cap_nhat "
                                     + "where btd_id=@btd_id" );
     db.AddInParameter(cmd, "@btd_id", DbType.Int64, doBangTheoDoi.BTD_ID);
     db.AddInParameter(cmd, "@name", DbType.String, doBangTheoDoi.NAME);
     db.AddInParameter(cmd, "@ngay_lap", DbType.DateTime, doBangTheoDoi.NGAY_LAP);
     db.AddInParameter(cmd, "@nguoi_lap", DbType.Int64, doBangTheoDoi.NGUOI_LAP);
     db.AddInParameter(cmd, "@ngay_ky", DbType.DateTime, doBangTheoDoi.NGAY_KY);
     db.AddInParameter(cmd, "@nguoi_ky", DbType.Int64, doBangTheoDoi.NGUOI_KY);
     db.AddInParameter(cmd, "@ngay_hieu_luc", DbType.DateTime, doBangTheoDoi.NGAY_HIEU_LUC);
     db.AddInParameter(cmd, "@nguoi_quan_ly", DbType.Int64, doBangTheoDoi.NGUOI_QUAN_LY);
     db.AddInParameter(cmd, "@tai_lieu", DbType.Binary, doBangTheoDoi.TAI_LIEU);
     db.AddInParameter(cmd, "@ten_tai_lieu", DbType.String, doBangTheoDoi.TEN_TAI_LIEU);
     db.AddInParameter(cmd, "@tinh_trang", DbType.Int64, doBangTheoDoi.TINH_TRANG);
     db.AddInParameter(cmd, "@hinh_thuc_thong_bao", DbType.Int32, doBangTheoDoi.HINH_THUC_THONG_BAO);
     db.AddInParameter(cmd, "@ghi_chu", DbType.String, doBangTheoDoi.GHI_CHU);
     db.AddInParameter(cmd, "@nguoi_cap_nhat", DbType.Int64, doBangTheoDoi.NGUOI_CAP_NHAT);
     db.AddInParameter(cmd, "@ngay_cap_nhat", DbType.DateTime, doBangTheoDoi.NGAY_CAP_NHAT);
     int result2 = db.ExecuteNonQuery(cmd, dbTrans);
 }
 public void insert(DbCommand cmd, DbTransaction dbTrans, DatabaseFB db, DOBangTheoDoi doBangTheoDoi)
 {
     cmd = db.GetSQLStringCommand("insert into BANG_THEO_DOI(btd_id,ma_btd,name,ngay_lap,nguoi_lap,ngay_ky,nguoi_ky,ngay_hieu_luc,nguoi_quan_ly,tai_lieu,ten_tai_lieu,tinh_trang,hinh_thuc_thong_bao,ghi_chu,nguoi_cap_nhat,ngay_cap_nhat) "
                                     + "values(@btd_id,@ma_btd,@name,@ngay_lap,@nguoi_lap,@ngay_ky,@nguoi_ky,@ngay_hieu_luc,@nguoi_quan_ly,@tai_lieu,@ten_tai_lieu,@tinh_trang,@hinh_thuc_thong_bao,@ghi_chu,@nguoi_cap_nhat,@ngay_cap_nhat)");
     db.AddInParameter(cmd, "@btd_id", DbType.Int64, doBangTheoDoi.BTD_ID);
     db.AddInParameter(cmd, "@ma_btd", DbType.String, doBangTheoDoi.MA_BTD);
     db.AddInParameter(cmd, "@name", DbType.String, doBangTheoDoi.NAME);
     db.AddInParameter(cmd, "@ngay_lap", DbType.DateTime, doBangTheoDoi.NGAY_LAP);
     db.AddInParameter(cmd, "@nguoi_lap", DbType.Int64, doBangTheoDoi.NGUOI_LAP);
     db.AddInParameter(cmd, "@ngay_ky", DbType.DateTime, doBangTheoDoi.NGAY_KY);
     db.AddInParameter(cmd, "@nguoi_ky", DbType.Int64, doBangTheoDoi.NGUOI_KY);
     db.AddInParameter(cmd, "@ngay_hieu_luc", DbType.DateTime, doBangTheoDoi.NGAY_HIEU_LUC);
     db.AddInParameter(cmd, "@nguoi_quan_ly", DbType.Int64, doBangTheoDoi.NGUOI_QUAN_LY);
     db.AddInParameter(cmd, "@tai_lieu", DbType.Binary, doBangTheoDoi.TAI_LIEU);
     db.AddInParameter(cmd, "@ten_tai_lieu", DbType.String, doBangTheoDoi.TEN_TAI_LIEU);
     db.AddInParameter(cmd, "@tinh_trang", DbType.Int64, doBangTheoDoi.TINH_TRANG);
     db.AddInParameter(cmd, "@hinh_thuc_thong_bao", DbType.Int32, doBangTheoDoi.HINH_THUC_THONG_BAO);
     db.AddInParameter(cmd, "@ghi_chu", DbType.String, doBangTheoDoi.GHI_CHU);
     db.AddInParameter(cmd, "@nguoi_cap_nhat", DbType.Int64, doBangTheoDoi.NGUOI_CAP_NHAT);
     db.AddInParameter(cmd, "@ngay_cap_nhat", DbType.DateTime, doBangTheoDoi.NGAY_CAP_NHAT);
     int result2 = db.ExecuteNonQuery(cmd, dbTrans);
 }
Example #13
0
 public void init(DatabaseFB db, List<Array> lstRowError, int rowError)
 {
     this.db = db;
     this.lstRowError = lstRowError;
     this.rowError = rowError;
 }
Example #14
0
 private void UpdateData()
 {
     try
     {
         gridviewDataTarget.CloseEditor();
         gridviewDataTarget.MoveNext();
         gridviewDataTarget.MovePrev();
         db = DABase.getDatabase();
         AddGen();
         DataView view = (DataView)gridviewDataTarget.DataSource;
         DataSet ds = view.Table.DataSet;
         ds.Tables[0].TableName = ds.Tables[0].TableName.Trim();
         if (db.UpdateTable(ds)!=-1)
         {
             ds.Tables[0].AcceptChanges();
             HelpMsgBox.ShowNotificationMessage("Dữ liệu được cập nhật thành công");
         }
         else
             PLMessageBox.ShowErrorMessage("Thêm dữ liệu không thành công");
     }
     catch(Exception e) {
         PLException.AddException(e);
         PLMessageBox.ShowErrorMessage("Thêm dữ liệu không thành công"); }
 }
Example #15
0
 public frmOldImport()
 {
     InitializeComponent();
     lstFieldGen = new Dictionary<string, string>();
     db = DABase.getDatabase();
 }