/// <summary> /// @author : TrungMT /// @CreateDate:04/04/2008 /// @Description: load data into grid /// </summary> private void BindingGrid() { try { // Get data view and bind to grid DataView dv = mBClip.Retrieves(MakeSearchParam()).Tables[0].DefaultView; this.mdgrClip.AutoGenerateColumns = false; this.mdgrClip.DataSource = dv; dv.Table.Columns.Add("##STT##", System.Type.GetType("System.Int32")); // Load customer data BCustomer bCustomer = new BCustomer(); mdvCustomer = bCustomer.Retrieves().Tables[0].DefaultView; if (mdvCustomer.Table.Rows.Count <= 0) return;// throw new Exception("Không có dữ liệu khách hàng. Bạn phải nhập danh mục khách hàng trước"); if (mdgrClip.Rows.Count > 0) mdgrClip.CurrentCell = mdgrClip.Rows[0].Cells[0]; // Etablish button status SetButtonStatus(); GenSTT(); } catch (Exception exp) { MsgBoxVN.ShowError(exp.Message,Dic.STRING_WARNING); Close(); } }
/// <summary> /// @author : TrungMT /// @CreateDate:04/03/2008 /// @Description: Process add data /// </summary> private bool Add() { // Valid condition for add if (!ValidAdd()) return false; try { // Add data BCustomer bCustomer = new BCustomer(); GetCustomerFromCtrl(); mCustomer.CustomerID = bCustomer.Add(mCustomer); // Update UI of parent form mfrmCustomer.AddCustomerUI(mCustomer); // Reinit component InitComponent(); return true; } catch (Exception exp) { MsgBoxVN.ShowError(exp.Message,Dic.STRING_WARNING); return false; } }
/// <summary> /// @author : TrungMT /// @CreateDate:04/03/2008 /// @Description: Process update data /// </summary> private bool UpdateData() { // Valid condition for update if (!ValidUpdate()) return false; // Ask user is sure about update if (!MsgBoxVN.ShowConfirm(InternalGlobal.UPDATE_QUESTION_MSG, InternalGlobal.UPDATE_QUESTION_CAPTION)) return false; try { // Update on data BCustomer bCustomer = new BCustomer(); GetCustomerFromCtrl(); bCustomer.Update(mCustomer); // Update UI of parent form mfrmCustomer.UpdateCustomerUI(mCustomer); // show success message and close form StoreItem(); MsgBoxVN.ShowInfor(InternalGlobal.UPDATE_SUCCESS_MSG, InternalGlobal.UPDATE_QUESTION_CAPTION); Close(); return true; } catch (Exception exp) { MsgBoxVN.ShowError(exp.Message,Dic.STRING_WARNING); return false; } }
/// <summary> /// @author : TrungMT /// @CreateDate:04/03/2008 /// @Description: init form when load /// </summary> public void Init() { mBCustomer = new BCustomer(); mcboSearch.SelectedIndex = 0; //this.mdgrCustomer.Header }