/// <summary> /// function insert and update and delete category /// </summary> /// <param name="ctgr"></param> model category /// <param name="action_status"></param> status: (add; edit; insert) /// <returns></returns> public bool Add_and_Edit_Category(category ctgr, int action_status) { bool check = false; try { if (Util.Cnv_Int(ctgr.id.ToString()) > 0) { category data_edit = new category(); data_edit = Get_Category(ctgr.id); if (action_status == Variable.action_status.is_update) // update data { data_edit.Name = ctgr.Name; data_edit.Note = ctgr.Note; data_edit.UpdatedAt = DateTime.Now; } else if (action_status == Variable.action_status.is_delete) // delete data { data_edit.Status = ctgr.Status; } } else { _db.category.Add(ctgr); // add data } _db.SaveChanges(); check = true; } catch (Exception) { return(check); } return(check); }
public void uc_Detail_Customer_Load(object sender, EventArgs e) { if (Data_Customer.ToString() != "") { List <category> lst_category = new List <category>(); lst_category = DAL_QLCategory.Get_List_Category("category"); ImageComboBoxItem item; foreach (var data in lst_category) { item = new ImageComboBoxItem(data.Name, data.id, data.id); cbb_category.Properties.Items.Add(item); } _ID_CUSTOMER = Util.Cnv_Int(Data_Customer["id"].ToString().Trim()); txt_edit_fullname.Text = Data_Customer["FullName"].ToString().Trim(); txt_edit_note.Text = Data_Customer["Note"].ToString().Trim(); txt_edit_familyphone.Text = Data_Customer["FamilyPhone"].ToString().Trim(); txt_edit_idcard.Text = Data_Customer["IdCard"].ToString().Trim(); txt_money.Text = Util.formatMoney(Convert.ToInt32(Data_Customer["Money"].ToString().Trim())); txt_cycle.Value = Convert.ToInt32(Data_Customer["Cycle"].ToString().Trim()); txt_edit_phone.Text = Data_Customer["PhoneNumber"].ToString().Trim(); radio_edit_sex.EditValue = (bool)Data_Customer["Sex"]; txt_edit_address.Text = Data_Customer["Address"].ToString().Trim(); cbb_category.EditValue = int.Parse(Data_Customer["IdCategory"].ToString()); birthDay_customer.Text = (DateTime.Parse(Data_Customer["BirthDay"].ToString().Trim())).ToString(Variable.format_date); date_paid.Text = (DateTime.Parse(Data_Customer["CreatedAt"].ToString().Trim())).ToString(Variable.format_date); } }
private void uc_Detail_Category_Load(object sender, EventArgs e) { if (Data_Category.ToString() != "") { _ID_CATEGORY = Util.Cnv_Int(Data_Category["id"].ToString().Trim()); txt_name_category.Text = Data_Category["Name"].ToString().Trim(); txt_Note.Text = Data_Category["Note"].ToString().Trim(); txt_UpdateAt.Text = Data_Category["UpdatedAt"].ToString().Trim(); txt_CreateAt.Text = Data_Category["CreatedAt"].ToString().Trim(); txt_CreateBy.Text = Data_Category["UserCreate"].ToString().Trim(); txt_UpdateBy.Text = Data_Category["UserUpdated"].ToString().Trim(); } }
private void grvKhachHang_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { DataRow row = grvKhachHang.GetDataRow(e.FocusedRowHandle); if (row != null) { //if (flag != "add" && flag != "edit") //{ _ID_CUSTOMER = Util.Cnv_Int(row["id"].ToString().Trim()); Fill_Data_Customer(_ID_CUSTOMER); //} } }
private void grvCategory_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { DataRow row = grvCategory.GetDataRow(e.FocusedRowHandle); if (row != null) { //if (flag != "add" && flag != "edit") //{ _ID_CATEGORY = Util.Cnv_Int(row["id"].ToString().Trim()); Fill_Data_Category(_ID_CATEGORY); //} } }
public bool Add_and_Edit_Customer(customer customer, List <Model.Friend> list_friend, int action_status, user user) { bool check = false; try { if (Util.Cnv_Int(customer.id.ToString()) > -1 && action_status != Variable.action_status.is_add) { customer data_edit = new customer(); data_edit = Get_Customer(customer.id); if (action_status == Variable.action_status.is_update) { // update data data_edit.Address = customer.Address; data_edit.BirthDay = customer.BirthDay; data_edit.FullName = customer.FullName; data_edit.IdCard = customer.IdCard; data_edit.PhoneNumber = customer.PhoneNumber; data_edit.Sex = customer.Sex; data_edit.FamilyPhoneNumber = customer.FamilyPhoneNumber; data_edit.CategoryId = customer.CategoryId; data_edit.Money = customer.Money; data_edit.Note = customer.Note; data_edit.UpdatedAt = DateTime.Now; data_edit.UpdatedBy = user.id; data_edit.cycle = customer.cycle; } else if (action_status == Variable.action_status.is_delete) // delete data { data_edit.Status = false; } } else { _db.customers.Add(customer); // add data } _db.SaveChanges(); int IdCustomer = customer.id; if (action_status == Variable.action_status.is_add && !add_friend(list_friend, user, IdCustomer)) { check = false; } check = true; } catch (Exception) { return(check); } return(check); }
private void uc_Detail_User_Load(object sender, EventArgs e) { if (Data_User.ToString() != "") { _ID_USER = Util.Cnv_Int(Data_User["id"].ToString().Trim()); txt_username.Text = Data_User["UserName"].ToString().Trim(); txt_Note.Text = Data_User["Note"].ToString().Trim(); txt_fullname.Text = Data_User["FullName"].ToString().Trim(); txt_idCard_user.Text = Data_User["CMND"].ToString().Trim(); txt_phone_user.Text = Data_User["PhoneNumber"].ToString().Trim(); txt_address_user.Text = Data_User["Address"].ToString().Trim(); radio_sex_user.EditValue = (bool)Data_User["Sex"]; radio_type_user.EditValue = Data_User["Type"]; birthDay_user.Text = (DateTime.Parse(Data_User["BirthDay"].ToString().Trim())).ToString(Variable.format_date); } }
private void grvUser_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { DataRow row = grvUser.GetDataRow(e.FocusedRowHandle); if (row != null) { //if (flag != "add" && flag != "edit") //{ Form form = new Form(); form.ShowDialog(this); _ID_USER = Util.Cnv_Int(row["id"].ToString().Trim()); Fill_Data_User(_ID_USER); //} } }
public bool Add_and_Edit_User(user ctgr, int action_status) { bool check = false; try { if (Util.Cnv_Int(ctgr.id.ToString()) > 0) { user data_edit = new user(); data_edit = Get_User(ctgr.id); if (action_status == Variable.action_status.is_update) { // update data data_edit.FullName = ctgr.FullName; data_edit.Note = ctgr.Note; data_edit.UpdatedAt = DateTime.Now; data_edit.Sex = ctgr.Sex; data_edit.Type = ctgr.Type; data_edit.PhoneNumber = ctgr.PhoneNumber; data_edit.IdCard = ctgr.IdCard; data_edit.BirthDay = ctgr.BirthDay; data_edit.Address = ctgr.Address; if (ctgr.PassWord != "" && ctgr.PassWord != null) { data_edit.PassWord = ctgr.PassWord; } } else if (action_status == Variable.action_status.is_delete) // delete data { data_edit.Status = ctgr.Status; } } else { _DB.users.Add(ctgr); // add data } _DB.SaveChanges(); check = true; } catch (Exception) { return(check); } return(check); }
/// <summary> /// function insert and update and delete User /// </summary> /// <param name="ctgr"></param> model User /// <param name="action_status"></param> status: (add; edit; insert) /// <returns></returns> public bool Add_and_Edit_Friend(friend ctgr, int action_status) { bool check = false; try { if (Util.Cnv_Int(ctgr.id.ToString()) > 0) { friend data_edit = new friend(); data_edit = Get_Friend(ctgr.id); if (action_status == Variable.action_status.is_update) { // update data data_edit.FullName = ctgr.FullName; data_edit.PhoneNumber = ctgr.PhoneNumber; data_edit.Note = ctgr.Note; data_edit.UpdatedAt = DateTime.Now; data_edit.UpdatedBy = ctgr.UpdatedBy; data_edit.Relationship = ctgr.Relationship; } else if (action_status == Variable.action_status.is_delete) // delete data { data_edit.Status = ctgr.Status; } } else { _db.friends.Add(ctgr); // add data } _db.SaveChanges(); check = true; } catch (Exception) { return(check); } return(check); }