コード例 #1
0
 private void LoadEntity(Model.Author model, DataRow row)
 {
     model.Id     = row["id"].ToString();
     model.Name   = row["name"].ToString();
     model.Adress = row["adress"].ToString();
     model.Email  = row["email"].ToString();
 }
コード例 #2
0
        public bool Add(Model.Author model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Author(");
            strSql.Append("id,name,adress,email)");
            strSql.Append(" values (");
            strSql.Append("@id,@name,@adress,@email)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",     SqlDbType.NVarChar, 100),
                new SqlParameter("@name",   SqlDbType.NVarChar, 100),
                new SqlParameter("@adress", SqlDbType.NVarChar, 100),
                new SqlParameter("@email",  SqlDbType.NVarChar, 100)
            };
            parameters[0].Value = model.Id;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Adress;
            parameters[3].Value = model.Email;


            int rows = SqlHelp.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
 void DatagridSelectedData(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (dgDetails.Rows.Count > 0)
         {
             if (oFindOption == FIND_OPTION.AUTHOR)
             {
                 oMAuthor             = new Model.Author();
                 oMAuthor.PERSON_ID   = dgDetails.Rows[e.RowIndex].Cells[0].Value.ToString();
                 oMAuthor.FIRST_NAME  = dgDetails.Rows[e.RowIndex].Cells[1].Value.ToString();
                 oMAuthor.MIDDLE_NAME = dgDetails.Rows[e.RowIndex].Cells[2].Value.ToString();
                 oMAuthor.LAST_NAME   = dgDetails.Rows[e.RowIndex].Cells[3].Value.ToString();
                 oMAuthor.STATUS      = dgDetails.Rows[e.RowIndex].Cells[4].Value.ToString();
             }
             else if (oFindOption == FIND_OPTION.CATEGORY)
             {
                 oMCategory             = new Model.Category();
                 oMCategory.CATEGORY_ID = dgDetails.Rows[e.RowIndex].Cells[0].Value.ToString();
                 oMCategory.CATEGORY    = dgDetails.Rows[e.RowIndex].Cells[1].Value.ToString();
                 oMCategory.STATUS      = dgDetails.Rows[e.RowIndex].Cells[2].Value.ToString();
             }
             else if (oFindOption == FIND_OPTION.LOCATION)
             {
                 oMLocation             = new Model.Location();
                 oMLocation.LOCATION_ID = dgDetails.Rows[e.RowIndex].Cells[0].Value.ToString();
                 oMLocation.LOCATION    = dgDetails.Rows[e.RowIndex].Cells[1].Value.ToString();
                 oMLocation.STATUS      = dgDetails.Rows[e.RowIndex].Cells[2].Value.ToString();
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
コード例 #4
0
        public Task ApresentarLivro(HttpContext context)
        {
            Model.Author a     = new Model.Author();
            var          livro = new Model.Book(
                Convert.ToString(context.GetRouteValue("nome")),
                null,
                0
                );


            return(context.Response.WriteAsync("O livro foi adicionado com sucesso"));
        }
コード例 #5
0
        public static Book ConvertModelBookToGraphQLBook(Model.Book modelBook, Model.Author modelAuthor)
        {
            var graphqlBook = new Book()
            {
                Id   = modelBook.Id,
                Name = modelBook.Name
            };

            if (modelAuthor != null)
            {
                graphqlBook.Author = AuthorMapper.ConvertModelAuthorToGraphQLAuthor(modelAuthor, null);
            }

            return(graphqlBook);
        }
コード例 #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            oMAuthor = new Model.Author();
            oAuthor  = new DataAccess.Author();

            if (eVariable.IsFieldEmpty(pnlBody))
            {
                oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.ALL_FIELDS_ARE_REQUIRED.ToString().Replace("_", " "));
                oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                oFrmMsgBox.ShowDialog();
                return;
            }

            if (eVariable.m_ActionType == eVariable.ACTION_TYPE.EDIT)
            {
                oMAuthor.PERSON_ID   = eVariable.sUniqueID;
                oMAuthor.FIRST_NAME  = txtFname.Text;
                oMAuthor.MIDDLE_NAME = txtMname.Text;
                oMAuthor.LAST_NAME   = txtLname.Text;
                oMAuthor.STATUS      = chkActive.Checked == true ? "ACTIVE" : "INACTIVE";
                oAuthor.UpdateAuthor(oMAuthor);
            }
            else
            {
                oMAuthor.FIRST_NAME  = txtFname.Text;
                oMAuthor.MIDDLE_NAME = txtMname.Text;
                oMAuthor.LAST_NAME   = txtLname.Text;

                if (oAuthor.isRecordExists(oMAuthor))
                {
                    oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_IS_ALREADY_EXISTS.ToString().Replace("_", " "));
                    oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }

                oMAuthor.STATUS = chkActive.Checked == true ? "ACTIVE" : "INACTIVE";
                oAuthor.InsertAuthor(oMAuthor);
            }

            oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_HAS_BEEN_SUCESSFULLY_SAVED.ToString().Replace("_", " "));
            oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
            oFrmMsgBox.ShowDialog();
            eVariable.ClearText(pnlBody);
            eVariable.m_ActionType = eVariable.ACTION_TYPE.ADD;
            LoadAuthor();
        }
コード例 #7
0
        public static Author ConvertModelAuthorToGraphQLAuthor(Model.Author modelAuthor, List <Model.Book> modelBooks)
        {
            var graphqlAuthor = new Author()
            {
                Id    = modelAuthor.Id,
                Name  = modelAuthor.Name,
                Email = modelAuthor.Email
            };

            if (modelBooks != null)
            {
                graphqlAuthor.Books = new List <Book>();
                foreach (var modelBook in modelBooks)
                {
                    graphqlAuthor.Books.Add(BookMapper.ConvertModelBookToGraphQLBook(modelBook, modelAuthor));
                }
            }

            return(graphqlAuthor);
        }
コード例 #8
0
 void DatagridSelect(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex >= 0)
         {
             if (dgDetails.Rows.Count > 0)
             {
                 oMAuthor             = new Model.Author();
                 eVariable.sUniqueID  = dgDetails.Rows[e.RowIndex].Cells[0].Value.ToString();
                 oMAuthor.PERSON_ID   = dgDetails.Rows[e.RowIndex].Cells[0].Value.ToString();
                 oMAuthor.FIRST_NAME  = dgDetails.Rows[e.RowIndex].Cells[1].Value.ToString();
                 oMAuthor.MIDDLE_NAME = dgDetails.Rows[e.RowIndex].Cells[2].Value.ToString();
                 oMAuthor.LAST_NAME   = dgDetails.Rows[e.RowIndex].Cells[3].Value.ToString();
                 oMAuthor.STATUS      = dgDetails.Rows[e.RowIndex].Cells[4].Value.ToString().Trim();
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
コード例 #9
0
        public List <Model.Author> GetAllList()
        {
            string sql = "select * from  Author  ";

            DataTable dt = SqlHelp.GetDataTable(sql, CommandType.Text);

            if (dt.Rows.Count > 0)
            {
                List <Model.Author> list = new List <Model.Author>();

                foreach (DataRow row in dt.Rows)
                {
                    Model.Author model = new Model.Author();
                    LoadEntity(model, row);
                    list.Add(model);
                }
                return(list);
            }
            else
            {
                return(null);
            }
        }
コード例 #10
0
 public AuthorViewModel(Model.Author viewData)
 {
     ViewData = viewData;
 }
コード例 #11
0
ファイル: TestInit.cs プロジェクト: jagmeet-chaudhary/ECA
        public static void InitTestDBContext(ECAEntities @this)
        {
            using (SpreadsheetDocument mySpreadsheet = SpreadsheetDocument.Open(@"../../TestData.xlsx", false))
            {
                var sheets = mySpreadsheet.WorkbookPart.Workbook.Sheets;
                SharedStringTable stringTable = mySpreadsheet.WorkbookPart.SharedStringTablePart.SharedStringTable;

                //Author
                Sheet sAuthor = sheets.Descendants<Sheet>().Where(s => s.Name == "Author").FirstOrDefault();
                WorksheetPart wsPart = mySpreadsheet.WorkbookPart.GetPartById(sAuthor.Id) as WorksheetPart;
                SheetData sheetData = wsPart.Worksheet.Elements<SheetData>().First();

                @this.Authors = new FakeDbSet<Model.Author>();
                foreach (Row r in sheetData.Elements<Row>())
                {
                    if (r.RowIndex == 1)
                        continue;

                    ECA.Model.Author author = new Model.Author();
                    author.AuthorId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(0), 0);
                    author.AuthorName = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1);
                    @this.Authors.Add(author);
                }

                //Book
                Sheet sBook = sheets.Descendants<Sheet>().Where(s => s.Name == "Book").FirstOrDefault();
                wsPart = mySpreadsheet.WorkbookPart.GetPartById(sBook.Id) as WorksheetPart;
                sheetData = wsPart.Worksheet.Elements<SheetData>().First();

                @this.Books = new FakeDbSet<Model.Book>();

                foreach (Row r in sheetData.Elements<Row>())
                {
                    if (r.RowIndex == 1)
                        continue;
                    ECA.Model.Book book = new Model.Book();
                    book.ID = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(0), 0);
                    book.Title = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1);
                    book.Description = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(2), 2);
                    book.AuthorId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(3), 3);
                    book.GenreId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(4), 4);
                    book.CategoryId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(5), 5);
                    book.ISBN = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(6), 6);
                    @this.Books.Add(book);
                }
                //Book Category
                Sheet sBookCategory = sheets.Descendants<Sheet>().Where(s => s.Name == "BookCategory").FirstOrDefault();
                wsPart = mySpreadsheet.WorkbookPart.GetPartById(sBookCategory.Id) as WorksheetPart;
                sheetData = wsPart.Worksheet.Elements<SheetData>().First();

                @this.BookCategories  = new FakeDbSet<Model.BookCategory>();

                foreach (Row r in sheetData.Elements<Row>())
                {
                    if (r.RowIndex == 1)
                        continue;
                    ECA.Model.BookCategory category = new Model.BookCategory();
                    category.CategoryId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(0), 0);
                    category.CategoryName = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1);

                    @this.BookCategories.Add(category);
                }

                //Genre
                Sheet sGenre = sheets.Descendants<Sheet>().Where(s => s.Name == "Genre").FirstOrDefault();
                wsPart = mySpreadsheet.WorkbookPart.GetPartById(sGenre.Id) as WorksheetPart;
                sheetData = wsPart.Worksheet.Elements<SheetData>().First();

                @this.Genres = new FakeDbSet<Model.Genre>();

                foreach (Row r in sheetData.Elements<Row>())
                {
                    if (r.RowIndex == 1)
                        continue;
                    ECA.Model.Genre genre = new Model.Genre();
                    genre.GenreId = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(0), 0);
                    genre.GenreName = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1);
                    @this.Genres.Add(genre);
                }
                //Shopping Cart
                Sheet sCart = sheets.Descendants<Sheet>().Where(s => s.Name == "Cart").FirstOrDefault();
                wsPart = mySpreadsheet.WorkbookPart.GetPartById(sCart.Id) as WorksheetPart;
                sheetData = wsPart.Worksheet.Elements<SheetData>().First();

                @this.Carts  = new FakeDbSet<Model.Cart>();

                foreach (Row r in sheetData.Elements<Row>())
                {
                    if (r.RowIndex == 1)
                        continue;
                    ECA.Model.Cart cart = new Model.Cart();

                    cart.UserId  =  Convert.ToInt32( r.Elements<Cell>().ElementAt(0).CellValue.Text);
                    cart.ItemCode = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1);
                    cart.Quantity  = Convert.ToInt32(r.Elements<Cell>().ElementAt(2).CellValue.Text);
                    @this.Carts.Add(cart);
                }
                //Users
                Sheet sUser = sheets.Descendants<Sheet>().Where(s => s.Name == "User").FirstOrDefault();
                wsPart = mySpreadsheet.WorkbookPart.GetPartById(sUser.Id) as WorksheetPart;
                sheetData = wsPart.Worksheet.Elements<SheetData>().First();

                @this.Users  = new FakeDbSet<Model.User>();

                foreach (Row r in sheetData.Elements<Row>())
                {
                    if (r.RowIndex == 1)
                        continue;
                    ECA.Model.User  user = new Model.User();
                    user.UserId = Convert.ToInt32(r.Elements<Cell>().ElementAt(0).CellValue.Text);
                    user.UserName = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1);
                    @this.Users.Add(user);

                }
                //Roles
                Sheet sRoles = sheets.Descendants<Sheet>().Where(s => s.Name == "Role").FirstOrDefault();
                wsPart = mySpreadsheet.WorkbookPart.GetPartById(sRoles.Id) as WorksheetPart;
                sheetData = wsPart.Worksheet.Elements<SheetData>().First();

                @this.webpages_Roles  = new FakeDbSet<Model.webpages_Roles>();

                foreach (Row r in sheetData.Elements<Row>())
                {
                    if (r.RowIndex == 1)
                        continue;
                    ECA.Model.webpages_Roles role = new Model.webpages_Roles();
                    role.RoleId  = Convert.ToInt32(r.Elements<Cell>().ElementAt(0).CellValue.Text);
                    role.RoleName = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(1), 1);
                    @this.webpages_Roles.Add(role);

                }
                @this.webpages_Roles.Where(r => r.RoleId == 1).FirstOrDefault().Users = new List<User>()
                {
                    new User(){ UserId = 1, UserName = "******"},
                    new User(){ UserId = 2,UserName = "******"}
                };
                @this.webpages_Roles.Where(r => r.RoleId == 2).FirstOrDefault().Users = new List<User>()
                {
                    new User(){ UserId = 3, UserName = "******"}
                };
                //Membership
                Sheet sMembership = sheets.Descendants<Sheet>().Where(s => s.Name == "Membership").FirstOrDefault();
                wsPart = mySpreadsheet.WorkbookPart.GetPartById(sMembership.Id) as WorksheetPart;
                sheetData = wsPart.Worksheet.Elements<SheetData>().First();

                @this.webpages_Membership  = new FakeDbSet<Model.webpages_Membership>();

                foreach (Row r in sheetData.Elements<Row>())
                {
                    if (r.RowIndex == 1)
                        continue;
                    ECA.Model.webpages_Membership membership = new Model.webpages_Membership();
                    membership.UserId = Convert.ToInt32(r.Elements<Cell>().ElementAt(0).CellValue.Text);
                    membership.Password  = GetStringValue(stringTable, r.Elements<Cell>().ElementAt(6), 6);
                    @this.webpages_Membership.Add(membership);

                }
            }
        }
コード例 #12
0
        private Author ConvertToGraphQLAuthor(Model.Author modelAuthor, bool includeBooks = false)
        {
            var modelBooks = includeBooks ? booksDataSource.GetBooksByAuthor(modelAuthor.Id) : null;

            return(AuthorMapper.ConvertModelAuthorToGraphQLAuthor(modelAuthor, modelBooks));
        }
コード例 #13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            CommentMethods commentMethods = new CommentMethods();
            string         articleName    = context.Request.Form["articleName"]; //文章名字
            string         authorName     = context.Request.Form["authorName"];  //文章名字
            string         content        = context.Request.Form["content"];     //base64字节

            #region 切割base64
            string str   = "base64,";
            int    index = content.IndexOf(str) + str.Length;
            int    end   = content.Length - index;
            content = content.Substring(index, end);
            #endregion


            string path     = context.Server.MapPath("../Papers/system/");
            Random rd       = new Random();
            string fileName = DateTime.Now.ToString("yyyyMMddhhmmss") + "-" + rd.Next(100, 999).ToString() + "-" + articleName;

            byte[] buff = Convert.FromBase64String(content);
            if (commentMethods.ByteToFile(content, path, fileName))
            {
                Bll.AuthorBll authorBll = new Bll.AuthorBll();
                var           author    = new Model.Author()
                {
                    Id     = Guid.NewGuid().ToString(),
                    Name   = authorName,
                    Adress = "",
                    Email  = ""
                };
                if (authorBll.Add(author))
                {
                    Bll.PapersBll papersBll = new Bll.PapersBll();
                    var           paper     = new Model.Papers()
                    {
                        Id       = Guid.NewGuid().ToString(),
                        AuthorId = author.Id,
                        Name     = articleName,
                        Url      = "../Papers/system/" + fileName,
                        Title    = ""
                    };
                    if (papersBll.Add(paper))
                    {
                        var             ketWords    = commentMethods.GetKeyWord(commentMethods.GetAll(path + fileName));
                        Bll.KeyWordsBll keyWordsBll = new Bll.KeyWordsBll();
                        var             keyWord     = new Model.KeyWords()
                        {
                            Id       = Guid.NewGuid().ToString(),
                            PaperId  = paper.Id,
                            KeyWord1 = ketWords[0],
                            KeyWord2 = ketWords[1],
                            KeyWord3 = ketWords[2],
                            KeyWord4 = ketWords[3],
                            KeyWord5 = ketWords[4],
                            KeyWord6 = ketWords[5],
                        };
                        if (keyWordsBll.Add(keyWord))
                        {
                            context.Response.Write(JsonConvert.SerializeObject(new ReturnMessage()
                            {
                                Code = 1, Message = "添加成功"
                            }));
                        }
                    }
                }
            }
        }
コード例 #14
0
 public bool Add(Model.Author model)
 {
     return(dal.Add(model));
 }