private void InsertData() { EmployeeRepository Repost = new EmployeeRepository(); List <MenuInformation> MenuInfo = Repost.MenuInfo().ToList(); var checkdata = (from s in MenuInfo where s.MenuId >= 1 select s).Count(); byte[] fileb = imgtoarray(PictureBox.Image); if (checkdata >= 1) { using (RestaurantkuContext Context = new RestaurantkuContext()) { var GetLastId = (from s in MenuInfo orderby s.MenuId descending select s).FirstOrDefault(); int GetMenuId = GetLastId.MenuId + 1; Context.spMsMenu_Action(GetMenuId, NamaText.Text, Convert.ToInt32(HargaText.Text), fileb, PathText.Text, "insert"); } } else { using (RestaurantkuContext Context = new RestaurantkuContext()) { int Menuid = 1; Context.spMsMenu_Action(Menuid, NamaText.Text, Convert.ToInt32(HargaText.Text), fileb, PathText.Text, "insert"); } } MessageBox.Show("Data Berhasil di Input"); }
private void InsertMember() { string Name = MemberNameText.Text; string Email = MemberEmailText.Text; string Password = MemberPasswordText.Text; string JoinDates = JoinDateTime.Value.ToString(); string CellNumber = CellNumberText.Text; string Address = AddressText.Text; EmployeeRepository Repost = new EmployeeRepository(); List <MemberInformation> MemberInfo = Repost.MemberInfo().ToList(); DateTime JoinMemberTime = JoinDateTime.Value; //DateTime.Parse(JoinDateTime.Value.ToString("dd/mm/yyyy")) var getMemberId = (from s in MemberInfo where s.MemberId >= 1 select s).Count(); if (getMemberId >= 1) { using (RestaurantkuContext Context = new RestaurantkuContext()) { var GetLastId = (from s in MemberInfo orderby s.MemberId descending select s).FirstOrDefault(); int MemberId = GetLastId.MemberId + 1; Context.spMsMember_Action(MemberId, Name, MemberEmailText.Text, CellNumber, JoinMemberTime, Password, null, null, null, Address, null, "insert"); Context.SaveChanges(); } } else { using (RestaurantkuContext Context = new RestaurantkuContext()) { int MemberId = 1; Context.spMsMember_Action(MemberId, Name, MemberEmailText.Text, CellNumber, JoinMemberTime, Password, null, null, null, Address, null, "insert"); } } }
private void DeleteMember() { using (RestaurantkuContext Context = new RestaurantkuContext()) { Context.spMsMember_Action(Convert.ToInt32(MemberIdTextBox.Text), null, null, null, null, null, null, null, null, null, null, "delete"); Context.SaveChanges(); } }
private void SaveDetail() { using (RestaurantkuContext Context = new RestaurantkuContext()) { for (int i = 0; i < dataGridView2.Rows.Count - 1; i++) { Context.SpDetailOrder_Action(null, Urut, Convert.ToInt32(dataGridView2.Rows[i].Cells[0].Value), Convert.ToInt32(dataGridView2.Rows[i].Cells[2].Value), Convert.ToInt32(dataGridView2.Rows[i].Cells[4].Value), "Prepare", "insert"); } } }
private void SaveHeader() { EmployeeRepository Repost = new EmployeeRepository(); List <HeaderOrderInformation> HoInfo = Repost.HeaderInfo().ToList(); using (RestaurantkuContext Context = new RestaurantkuContext()) { Context.spMsHeadOrder_Action(Urut, RestaurantKuLoginForm.getid(), DialogPembeli.getid(), Convert.ToDateTime(DateTime.Now.ToString("yyyyMMdd")), "null", "null", "insert"); } }
private void InsertCashierData() { string EmployeeName = EmployeeNameTextBox.Text; string EmployeeEmail = EmployeeEmailTextBox.Text.ToLower(); string EmployeePassword = EmployeePasswordTextBox.Text; string EmployeeHandphone = EmployeeHandphoneTextBox.Text; string EmployeePosition = EmployeePositionValue.Text.ToLower(); EmployeeRepository EmpRepost = new EmployeeRepository(); List <EmployeeInformation> EmployeeInformation = EmpRepost.GetEmpData(); var CheckId = (from s in EmployeeInformation where s.EmployeePosition == "cashier" select s).Count(); using (RestaurantkuContext Context = new RestaurantkuContext()) { if (CheckId == 0) { #region Inserting Cashier Id if Cashier Data never created before int CashierId = 1; string GetCashierId = "CA0" + CashierId; Context.spMsEmployee_Action( GetCashierId, EmployeeName, EmployeeEmail, EmployeePassword, EmployeeHandphone, EmployeePosition, "insert"); Context.SaveChanges(); #endregion } else { #region Inserting Cashier Id if Cashier Data has been created Before var GetData = (from s in EmployeeInformation where s.EmployeePosition == "cashier" orderby s.EmployeeId descending select s).First(); string GetId = GetData.EmployeeId; string SubstringId = GetId.Substring(2, 2); int ConvertId = Convert.ToInt32(SubstringId); int aic = ConvertId++; string ConvertToString = ConvertId.ToString(); string FinalId = "CA0" + ConvertToString; Context.spMsEmployee_Action(FinalId, EmployeeName, EmployeeEmail, EmployeePassword, EmployeeHandphone, EmployeePosition, "insert"); Context.SaveChanges(); #endregion } } }
private void DeleteDataButton_Click(object sender, EventArgs e) { try { using (RestaurantkuContext Context = new RestaurantkuContext()) { Context.spMsEmployee_Action(EmployeeIdTextBox.Text, null, null, null, null, null, "delete"); } MessageBox.Show("Data sukses Di Hapus"); LoadDataGrid(); } catch { MessageBox.Show("Id Tidak Dapat Di temukan"); } }
private void LoginButton_Click(object sender, EventArgs e) { using (RestaurantkuContext Context = new RestaurantkuContext()) { EmployeeRepository Repost = new EmployeeRepository(); List <EmployeeInformation> EmpInformation = Repost.GetEmpData(); try { var GetEmp = (from a in EmpInformation where a.EmployeeEmail == EmailTextBoxValue.Text select a).First(); string Name = GetEmp.EmployeeName; string EmailText = EmailTextBoxValue.Text; string PasswordText = PasswordTextBoxValue.Text; string EmpEmail = GetEmp.EmployeeEmail; string EmpPassword = GetEmp.EmployeePassword; id = GetEmp.EmployeeId; if (EmpEmail == EmailText) { // Membuat Huruf pertama Menjadi Kapital Name = Name[0].ToString().ToUpper() + Name.Substring(1, Name.Length - 1); var verif = (from a in EmpInformation where a.EmployeeEmail == EmailText select a).First(); string EmpPost = verif.EmployeePosition; if (EmpPost == "cashier" && EmpPassword == PasswordText) { CashierNavigationForm Cashier = new CashierNavigationForm(); Cashier.CashierName = Name; Cashier.Show(); this.Hide(); } if (EmpPost == "admin" && EmpPassword == PasswordText) { AdminNavigationForm Admin = new AdminNavigationForm(); Admin.AdminName = Name; Admin.Show(); this.Hide(); } if (EmpPost == "chef" && EmpPassword == PasswordText) { ChefNavigationForm chef = new ChefNavigationForm(); chef.ChefName = Name; chef.Show(); this.Hide(); } MessageBox.Show("Login Berhasil"); } else { MessageBox.Show("Periksa Kembali Email atau Password anda "); } } catch { MessageBox.Show("Data Salah, Mohon Periksa Kembali"); } } }
private void UpdateEmpData() { using (RestaurantkuContext Context = new RestaurantkuContext()) { string EmployeeId = EmployeeIdTextBox.Text.Trim(); string EmployeeName = EmployeeNameTextBox.Text; string EmployeeEmail = EmployeeEmailTextBox.Text.ToLower(); string EmployeePassword = EmployeePasswordTextBox.Text; string EmployeeHandphone = EmployeeHandphoneTextBox.Text; string EmployeePosition = EmployeePositionValue.Text.ToLower(); Context.spMsEmployee_Action(EmployeeId, EmployeeName, EmployeeEmail, EmployeePassword, EmployeeHandphone, EmployeePosition, "update"); Context.SaveChanges(); } }
private void InsertChefData() { string EmployeeName = EmployeeNameTextBox.Text; string EmployeeEmail = EmployeeEmailTextBox.Text.ToLower(); string EmployeePassword = EmployeePasswordTextBox.Text; string EmployeeHandphone = EmployeeHandphoneTextBox.Text; string EmployeePosition = EmployeePositionValue.Text.ToLower(); EmployeeRepository empRepost = new EmployeeRepository(); List <EmployeeInformation> GetEmpData = empRepost.GetEmpData(); var getDataifNull = (from s in GetEmpData where s.EmployeePosition == "chef" select s).Count(); #region Create Chef Data if chef data never created before if (getDataifNull == 0) { using (RestaurantkuContext context = new RestaurantkuContext()) { int ChefId = 0 + 1; string GetChefId = "CH0" + ChefId++; string EmployeeId = GetChefId; context.spMsEmployee_Action(EmployeeId, EmployeeName, EmployeeEmail, EmployeePassword, EmployeeHandphone, EmployeePosition, "insert"); context.SaveChanges(); } } #endregion #region Create chef data if chef data has been created before else { using (RestaurantkuContext Context = new RestaurantkuContext()) { var getData = (from s in GetEmpData where s.EmployeePosition == "chef" orderby s.EmployeeId descending select s).FirstOrDefault(); string GetIdFromContext = getData.EmployeeId; string SubstringGetId = GetIdFromContext.Substring(2, 2); // Substring dari index 2 untuk 2 kekanan int ConvertSubstring = Convert.ToInt32(SubstringGetId); int AutoIncId = ConvertSubstring++; //AutoIncId = Auto Increment Untuk Id nya string ConvertString = ConvertSubstring.ToString(); string FinalId = "CH0" + ConvertString; //Id ynag sudah di auto incrementkan atau Id Jadinya string EmployeeId = FinalId; Context.spMsEmployee_Action(EmployeeId, EmployeeName, EmployeeEmail, EmployeePassword, EmployeeHandphone, EmployeePosition, "insert"); Context.SaveChanges(); } } #endregion }
private void AutoId() { using (RestaurantkuContext Context = new RestaurantkuContext()) { long hitung; EmployeeRepository repost = new EmployeeRepository(); List <HeaderOrderInformation> Info = repost.HeaderInfo().ToList(); var CheckData = (from s in Info where s.orderid != null select s).Count(); Info = Info.OrderByDescending(x => x.orderid).ToList(); if (CheckData >= 1) { hitung = Convert.ToInt64(Info.Max(s => s.orderid).ToString()) + 1; string autostr = "0000" + hitung; Urut = DateTime.Now.ToString("yyyyMMdd") + autostr; } else { Urut = DateTime.Now.ToString("yyyyMMdd") + "0001"; } } }
private void UpdateMember() { DateTime JoinMemberTime = JoinDateTime.Value; using (RestaurantkuContext Context = new RestaurantkuContext()) { int Memberid = Convert.ToInt32(MemberIdTextBox.Text); Context.spMsMember_Action( Convert.ToInt32(MemberIdTextBox.Text), Name, MemberEmailText.Text, CellNumberText.Text, JoinMemberTime, MemberPasswordText.Text, null, null, null, AddressText.Text, null, "insert"); Context.SaveChanges(); } MessageBox.Show("Data Berhasil Di Perbaharui"); LoadData(); }