Exemple #1
0
 public static void Delete(int id, string loginUserId)
 {
     WFTPDbContext db = new WFTPDbContext();
     try
     {
         var category = (from categories in db.GetTable<CFileCategory>()
                         where categories.FileCategoryId == id
                         select categories).SingleOrDefault();
         string record = String.Format("FileCategoryId:{0}, ClassName:{1}, ClassNickName:{2}, CreateDate:{3}", category.FileCategoryId, category.ClassName, category.ClassNickName, category.CreateDate);
         DeleteLog.Insert("dbo.FileCategorys", record, loginUserId);
         db.Lv5FileCategorys.DeleteOnSubmit(category);
         db.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
        // Just provide insert for log
        public static void Insert(string tableName, string record, string loginUserId)
        {
            WFTPDbContext db = new WFTPDbContext();

            try
            {
                DeleteLog log = new DeleteLog();
                log.TableName = tableName;
                log.Record = record;
                log.Date = DateTime.Now;
                log.EditUser = loginUserId;
                db.DeleteLogs.InsertOnSubmit(log);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
 public static void Delete(int lineId, string loginUserId)
 {
     WFTPDbContext db = new WFTPDbContext();
     try
     {
         var line = (from lines in db.GetTable<CLv4Line>()
                     where lines.LineId == lineId
                     select lines).SingleOrDefault();
         string record = String.Format("LineId:{0}, BranchId:{1}, LineName:{2}, LineNickName:{3}, CreateDate:{4}", line.LineId, line.BranchId, line.LineName, line.LineNickName, line.CreateDate);
         DeleteLog.Insert("dbo.Lv4Lines", record, loginUserId);
         db.Lv4Lines.DeleteOnSubmit(line);
         db.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #4
0
        public static void InsertOrUpdate(int? lineId, string lineName, string lineNickName, int branchId)
        {
            WFTPDbContext db = new WFTPDbContext();
            if (lineId == null) //Insert
            {
                try
                {
                    CLv4Line line = new CLv4Line();
                    line.LineName = lineName;
                    line.LineNickName = lineNickName;
                    line.CreateDate = DateTime.Now;
                    line.BranchId = branchId;
                    db.Lv4Lines.InsertOnSubmit(line);
                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }
            else //Update
            {
                try
                {
                    var line = (from lines in db.GetTable<CLv4Line>()
                                where lines.LineId == lineId
                                select lines).SingleOrDefault();
                    if (branchId>0)
                        line.BranchId = branchId;

                    if (!String.IsNullOrEmpty(lineName))
                        line.LineName = lineName;

                    if (!String.IsNullOrEmpty(lineNickName))
                    line.LineNickName = lineNickName;

                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemple #5
0
        public static void InsertOrUpdate(int? eId, string account, string pwd, DateTime createDate, DateTime LastLoginDate, string rank, string name, string email, bool? recvNotify, bool? activity)
        {
            WFTPDbContext db = new WFTPDbContext();
            if (eId == null) //Insert
            {
                try
                {
                    CEmployee e = new CEmployee();
                    e.Account = account;
                    e.Activity = (bool)activity;
                    e.Email = email;
                    e.CreateDate = createDate;
                    e.Name = name;
                    e.Password = pwd;
                    e.Rank = rank;
                    e.RecvNotify = (bool)recvNotify;

                    db.Employees.InsertOnSubmit(e);
                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }
            else //Update
            {
                try
                {
                    var empolyee = (from e in db.GetTable<CEmployee>()
                                where e.EId == eId
                                select e).SingleOrDefault();
                    if (!String.IsNullOrEmpty(account))
                        empolyee.Account = account;

                    if (!String.IsNullOrEmpty(pwd))
                        empolyee.Password = pwd;

                    if (!String.IsNullOrEmpty(rank))
                        empolyee.Rank = rank;

                    if (!String.IsNullOrEmpty(name))
                        empolyee.Name = name;

                    if (!String.IsNullOrEmpty(email))
                        empolyee.Email = email;

                    if (!String.IsNullOrEmpty(rank))
                        empolyee.Rank = rank;

                    if (!String.IsNullOrEmpty(rank))
                        empolyee.Rank = rank;

                    empolyee.LastLoginDate = DateTime.Now;

                    if (recvNotify.HasValue)
                        empolyee.RecvNotify = (bool)recvNotify;

                    if (activity.HasValue)
                        empolyee.Activity = (bool)activity;

                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemple #6
0
        public static void Delete(int eid, string loginUserId)
        {
            WFTPDbContext db = new WFTPDbContext();
            try
            {
                var empolyee = (from e in db.GetTable<CEmployee>()
                                where e.EId == eid
                                select e).SingleOrDefault();

                string record = String.Format("EId:{0}, Account:{1}, Email:{2}, LastLoginDate:{3}, Name:{4}, Password:{5}, Rank:{6}, RecvNotify:{7}", empolyee.EId, empolyee.Account, empolyee.Activity, empolyee.Email, empolyee.LastLoginDate, empolyee.Name, empolyee.Password, empolyee.Rank, empolyee.RecvNotify);
                DeleteLog.Insert("dbo.Files", record, loginUserId);
                db.Employees.DeleteOnSubmit(empolyee);
                db.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static void Delete(int branchId, string loginUserId)
        {
            WFTPDbContext db = new WFTPDbContext();
               try
               {
               var branch = (from branches in db.GetTable<CLv3CustomerBranch>()
                             where branches.BranchId == branchId
                             select branches).SingleOrDefault();
               string record = String.Format("BranchId:{0}, BranchName:{1}, BranchNickName:{2}, CompanyId:{3}, CreateDate:{4}", branch.BranchId, branch.BranchName, branch.BranchNickName, branch.CompanyId, branch.CreateDate);
               DeleteLog.Insert("dbo.Lv3CustomerBranches", record, loginUserId);

               db.GetTable<CLv3CustomerBranch>().DeleteOnSubmit(branch);
               db.SubmitChanges();
               }
               catch (Exception ex)
               {
               throw ex;
               }
        }
        public static void InsertOrUpdate(int? branchId, string branchName, string branchNickName, int companyId)
        {
            WFTPDbContext db = new WFTPDbContext();
               if (branchId == null) //Insert
               {
               try
               {
                   CLv3CustomerBranch branch = new CLv3CustomerBranch();
                   branch.BranchName = branchName;
                   branch.BranchNickName = branchNickName;
                   branch.CreateDate = DateTime.Now;
                   branch.CompanyId = companyId;
                   db.Lv3CustomerBranches.InsertOnSubmit(branch);
                   db.SubmitChanges();
               }
               catch (Exception ex)
               {
                   throw ex;
               }

               }
               else //Update
               {
               try
               {
                   var branch = (from branches in db.GetTable<CLv3CustomerBranch>()
                                 where branches.BranchId == branchId
                                 select branches).SingleOrDefault();
                   if (companyId > 0)
                       branch.CompanyId = companyId;

                   if (!String.IsNullOrEmpty(branchName))
                       branch.BranchName = branchName;

                   if (!String.IsNullOrEmpty(branchNickName))
                       branch.BranchNickName = branchNickName;

                   db.SubmitChanges();
               }
               catch (Exception ex)
               {
                   throw ex;
               }
               }
        }
Exemple #9
0
        public static void InsertOrUpdate(int? fileId,int categoryId, int lineId, string originFileName, string fileName, bool? isDelete, string loginUserID, string fileHash)
        {
            WFTPDbContext db = new WFTPDbContext();
            if (fileId == null) //Insert
            {
                try
                {
                    CFile f = new CFile();
                    f.FileCategoryId = categoryId;
                    f.LineId = lineId;
                    f.OriginFileName = originFileName;
                    f.FileName = fileName;
                    f.FileHash = fileHash;
                    f.IsDeleted = false;
                    f.CreateDate = DateTime.Now;
                    f.LastUploadDate = DateTime.Now;
                    f.LastEditUser = loginUserID;
                    f.CreateUser = loginUserID;
                    db.Lv6Files.InsertOnSubmit(f);
                    db.SubmitChanges();
                    f.Path = DBHelper.GenerateFileFullPath(f.FileId);
                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }
            else //Update
            {
                try
                {
                    var file = (from files in db.GetTable<CFile>()
                                where files.FileId == fileId
                                select files).SingleOrDefault();
                    if (categoryId > 0)
                        file.FileCategoryId = categoryId;

                    if (!String.IsNullOrEmpty(fileName))
                        file.FileName = fileName;

                    if (isDelete.HasValue)
                        file.IsDeleted = (bool)isDelete;

                    file.LastEditUser = loginUserID;
                    file.LastUploadDate = DateTime.Now;

                    if(lineId > 0)
                        file.LineId = lineId;

                    if (!String.IsNullOrEmpty(originFileName))
                        file.OriginFileName = originFileName;

                    file.Path = DBHelper.GenerateFileFullPath(file.FileId);
                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemple #10
0
 public static void Delete(int fileId, string loginUserId)
 {
     WFTPDbContext db = new WFTPDbContext();
     try
     {
         var file = (from files in db.GetTable<CFile>()
                     where files.FileId == fileId
                     select files).SingleOrDefault();
         string record = String.Format("FileId:{0}, LineId:{1}, FileName:{2}, FileHash:{3}, Path:{4}, CreateDate:{5}", file.FileId, file.LineId, file.FileName, file.FileHash, file.Path, file.CreateDate);
         DeleteLog.Insert("dbo.Files", record, loginUserId);
         db.Lv6Files.DeleteOnSubmit(file);
         db.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #11
0
        public static void InsertOrUpdate(int? companyId, string companyName, string companyNickName, int classifyId)
        {
            WFTPDbContext db = new WFTPDbContext();
               if (companyId == null) //Insert
               {
               try
               {
                   CLv2Customer newCustomer = new CLv2Customer();
                   newCustomer.CompanyName = companyName;
                   newCustomer.CompanyNickName = companyNickName;
                   newCustomer.CreateDate = DateTime.Now;
                   newCustomer.ClassifyId = classifyId;
                   db.Lv2Customers.InsertOnSubmit(newCustomer);
                   db.SubmitChanges();
               }
               catch (Exception ex)
               {
                   throw ex;
               }

               }
               else //Update
               {
               try
               {
                   var customer = (from customers in db.GetTable<CLv2Customer>()
                                   where customers.CompanyId == companyId
                                   select customers).SingleOrDefault();
                   if (classifyId > 0)
                    customer.ClassifyId = classifyId;

                   if (!String.IsNullOrEmpty(companyName))
                    customer.CompanyName = companyName;

                   if (!String.IsNullOrEmpty(companyNickName))
                   customer.CompanyNickName = companyNickName;

                   db.SubmitChanges();
               }
               catch (Exception ex)
               {
                   throw ex;
               }
               }
        }
Exemple #12
0
 public static void Delete(int companyId, string loginUserId)
 {
     WFTPDbContext db = new WFTPDbContext();
        try
        {
        var customer = (from customers in db.GetTable<CLv2Customer>()
                        where customers.CompanyId == companyId
                        select customers).SingleOrDefault();
        string record = String.Format("ClassifyId:{0}, CompanyId:{1}, CompanyName:{2}, CompanyNickName:{3}", customer.ClassifyId, customer.CompanyId, customer.CompanyName, customer.CompanyNickName);
        DeleteLog.Insert("dbo.Lv2Customers", record, loginUserId);
        db.Lv2Customers.DeleteOnSubmit(customer);
        db.SubmitChanges();
        }
        catch (Exception ex)
        {
        throw ex;
        }
 }
Exemple #13
0
 public static void Delete(int id, string loginUserId)
 {
     WFTPDbContext db = new WFTPDbContext();
     try
     {
         var classify = (from classifies in db.GetTable<CLv1Classify>()
                         where classifies.ClassifyId == id
                         select classifies).SingleOrDefault();
         string record = String.Format("ClassifyId:{0}, ClassName:{1}, NickName:{2}",classify.ClassifyId,classify.ClassName,classify.NickName);
         DeleteLog.Insert("dbo.Lv1Classifications",record,loginUserId);
         db.Lv1Classifications.DeleteOnSubmit(classify);
         db.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #14
0
        public static void InsertOrUpdate(int? id, string className, string nickName)
        {
            WFTPDbContext db = new WFTPDbContext();
            if (id == null) //Insert
            {
                try
                {
                    CLv1Classify newClassify = new CLv1Classify();
                    newClassify.ClassName = className;
                    newClassify.NickName = nickName;
                    db.Lv1Classifications.InsertOnSubmit(newClassify);
                    db.SubmitChanges();
                }
                catch(Exception ex)
                {
                    throw ex;
                }

            }
            else //Update
            {
                try
                {
                    var classify = (from classifies in db.GetTable<CLv1Classify>()
                                    where classifies.ClassifyId == id
                                    select classifies).SingleOrDefault();
                    if (!String.IsNullOrEmpty(className))
                        classify.ClassName = className;

                    if (!String.IsNullOrEmpty(nickName))
                    classify.NickName = nickName;
                    db.SubmitChanges();
                }
                catch(Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemple #15
0
        public static void InsertOrUpdate(int? id, string categoryName, string categoryNickName)
        {
            WFTPDbContext db = new WFTPDbContext();
            if (id == null) //Insert
            {
                try
                {
                    CFileCategory category = new CFileCategory();
                    category.ClassName = categoryName;
                    category.ClassNickName = categoryNickName;
                    category.CreateDate = DateTime.Now;
                    db.Lv5FileCategorys.InsertOnSubmit(category);
                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }
            else //Update
            {
                try
                {
                    var category = (from categories in db.GetTable<CFileCategory>()
                                    where categories.FileCategoryId == id
                                    select categories).SingleOrDefault();
                    if (!String.IsNullOrEmpty(categoryName))
                        category.ClassName = categoryName;

                    if (!String.IsNullOrEmpty(categoryNickName))
                        category.ClassNickName = categoryNickName;

                    db.SubmitChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }