Advertisement
Guest User

Untitled

a guest
Jan 1st, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.57 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Windows.Forms;
  4. using Models;
  5.  
  6. namespace BTLibrary
  7. {
  8.  
  9.  
  10.     static class Program
  11.     {
  12.  
  13.  
  14.         /// <summary>
  15.         /// The main entry point for the application.
  16.         /// </summary>
  17.         [STAThread]
  18.         public static void Main()
  19.         {
  20.            
  21.  
  22.  
  23.             Person CurrentUser = new Person();
  24.             Application.EnableVisualStyles();
  25.             Application.SetCompatibleTextRenderingDefault(false);
  26.             FormInstances OFormInstances = new FormInstances();
  27.              
  28.            
  29.             Application.Run(OFormInstances.OLoginFrm);
  30.         }
  31.     }
  32. }
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. using System;
  40. using System.Collections.Generic;
  41. using System.Linq;
  42. using System.Text;
  43. using System.Threading.Tasks;
  44.  
  45. namespace BTLibrary
  46. {
  47.     public class FormInstances
  48.     {
  49.        
  50.         public MainFrm OMainFrm = new MainFrm();
  51.         public AddBookFrm OAddFrm = new AddBookFrm();
  52.         public LoginFrm OLoginFrm = new LoginFrm();
  53.     }
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. using System;
  63. using System.Collections.Generic;
  64. using System.ComponentModel;
  65. using System.Data;
  66. using System.Drawing;
  67. using System.Linq;
  68. using System.Text;
  69. using System.Threading.Tasks;
  70. using System.Windows.Forms;
  71. using Models;
  72. using BTLibrary;
  73.  
  74. namespace BTLibrary
  75. {
  76.  
  77.     public partial class LoginFrm : Telerik.WinControls.UI.RadForm
  78.     {
  79.        
  80.         BTLibraryEntities db = new BTLibraryEntities();
  81.  
  82.         public LoginFrm()
  83.         {
  84.            
  85.             InitializeComponent();
  86.         }
  87.  
  88.         private void LoginBtn_Click(object sender, EventArgs e)
  89.         {
  90.            
  91.             var EnteredUser = db.Persons.Where(a => a.UserName == UserNameTxt.Text && a.Password == PasswordTxt.Text).ToList();
  92.             if (EnteredUser.Count > 0)
  93.             {
  94.                 var LoginRole = (from r in EnteredUser
  95.                                  join Title in db.Titles on r.Title_Person_Fk equals Title.ID
  96.                                  select new
  97.                                  {
  98.                                      Role = Title.Title1
  99.                                  }).ToList();
  100.  
  101.  
  102.  
  103.                 if (LoginRole[0].Role == "Admin"||LoginRole[0].Role=="User"|| LoginRole[0].Role == "Guest")
  104.                 {
  105.                    
  106.                     //OMainFrm.Show();
  107.                     this.Hide();
  108.                 }
  109.                 else
  110.                 {
  111.  
  112.                 }
  113.             }
  114.  
  115.  
  116.         }
  117.     }
  118. }
  119.  
  120.  
  121.  
  122.  
  123.  
  124. using System;
  125. using System.Collections.Generic;
  126. using System.ComponentModel;
  127. using System.Data;
  128. using System.Drawing;
  129. using System.Linq;
  130. using System.Text;
  131. using System.Threading.Tasks;
  132. using System.Windows.Forms;
  133. using Models;
  134. using BTLibrary;
  135.  
  136. namespace BTLibrary
  137. {
  138.     public partial class MainFrm : Telerik.WinControls.UI.RadRibbonForm
  139.     {
  140.  
  141.         public MainFrm()
  142.         {
  143.  
  144.             InitializeComponent();
  145.         }
  146.  
  147.         private void MainFrm_Load(object sender, EventArgs e)
  148.         {
  149.             BTLibraryEntities db = new BTLibraryEntities();
  150.             MainGrid.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
  151.  
  152.             MainGrid.DataSource = (from row in db.Books select row).ToList();
  153.         }
  154.  
  155.          public void radButtonElement1_Click(object sender, EventArgs e)
  156.         {
  157.              
  158.             //OLogingFrm cant access the Ologin Frm
  159.  
  160.         }
  161.     }
  162. }
  163.  
  164.  
  165.  
  166.  
  167.  
  168. using System;
  169. using System.Collections.Generic;
  170. using System.ComponentModel;
  171. using System.Data;
  172. using System.Drawing;
  173. using System.Text;
  174. using System.Windows.Forms;
  175. using Telerik.WinControls;
  176. using System.Linq;
  177. using BTLibrary;
  178. namespace BTLibrary
  179. {
  180.     public partial class AddBookFrm : Telerik.WinControls.UI.RadForm
  181.     {
  182.         Models.BTLibraryEntities db = new Models.BTLibraryEntities();
  183.  
  184.        
  185.         public AddBookFrm()
  186.         {
  187.             InitializeComponent();
  188.  
  189.             AddBookGrid.DataSource = (from b in db.Books select b).ToList();
  190.  
  191.  
  192.         }
  193.  
  194.         private void AddBookFrm_Load(object sender, EventArgs e)
  195.         {
  196.  
  197.         }
  198.  
  199.         private void AddBookBtn_Click(object sender, EventArgs e)
  200.         {
  201.             if (BooktitleTxt.Text != null && AuthorTxt.Text != null)
  202.             {
  203.                 Models.Book AddBook = new Models.Book();
  204.                 AddBook.Title = BooktitleTxt.Text;
  205.                 AddBook.Author = AuthorTxt.Text;
  206.                 AddBook.Author2 = ScondAuthorTxt.Text;
  207.                 AddBook.Author3 = ThirdAuthorTxt.Text;
  208.                 AddBook.Translatedby = TranslatorTxt.Text;
  209.                 AddBook.Discripton = DescriptionTxt.Text;
  210.                 AddBook.PublicationYear = PublicationYearDTP.Value;
  211.                 AddBook.FirstPublicationDate = FirstPublicationDateDTP.Value;
  212.                 AddBook.Rack = int.Parse(Racktxt.Text);
  213.                 AddBook.Row = int.Parse(rowTxt.Text);
  214.                 AddBook.Tags = TagsTxt.Text;
  215.                 AddBook.FIPA = FIPATxt.Text;
  216.                 AddBook.ContributedBy = ContributedbyTxt.Text;
  217.                 AddBook.LCC = LCCTxt.Text;
  218.                 AddBook.Price = PriceTxt.Text;
  219.                 AddBook.DDC = DDCTxt.Text;
  220.                 db.Books.Add(AddBook);
  221.                 db.SaveChanges();
  222.                 MessageBox.Show("The Book is Successfully Saved.");
  223.             }
  224.             else
  225.             {
  226.                 MessageBox.Show("please insert title and author.");
  227.             }
  228.  
  229.         }
  230.  
  231.         private void ResetBtn_Click(object sender, EventArgs e)
  232.         {
  233.             BooktitleTxt.Text = null;
  234.            AuthorTxt.Text = null;
  235.             ScondAuthorTxt.Text = null;
  236.             ThirdAuthorTxt.Text = null;
  237.             TranslatorTxt.Text = null;
  238.             DescriptionTxt.Text = null;
  239.             PublicationYearDTP.Value = DateTime.Now;
  240.             FirstPublicationDateDTP.Value = DateTime.Now;
  241.             Racktxt.Text = null;
  242.             rowTxt.Text = null;
  243.             TagsTxt.Text = null;
  244.             FIPATxt.Text = null;
  245.             ContributedbyTxt.Text = null;
  246.             LCCTxt.Text = null;
  247.             PriceTxt.Text = null;
  248.             DDCTxt.Text = null;
  249.         }
  250.  
  251.            
  252.            
  253.            
  254.  
  255.  
  256.         private  void  CloseBtn_Click(object sender, EventArgs e)
  257.         {
  258.             this.Hide();
  259.            
  260.  
  261.         }
  262.  
  263.         private void CloseBtn_Enter(object sender, EventArgs e)
  264.         {
  265.            
  266.         }
  267.  
  268.         private void AddBookFrm_Click(object sender, EventArgs e)
  269.         {
  270.            
  271.         }
  272.     }
  273. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement