private void InitControls() { TxtIdx.Text = TxtAuthor.Text = string.Empty; TxtIdx.Focus(); DtpReleaseDate.CustomFormat = "yyyy-MM-dd"; DtpReleaseDate.Format = DateTimePickerFormat.Custom; MyMode = BaseMode.NONE; /* * Dictionary<string, string> dic = new Dictionary<string, string>(); * dic.Add("선택", "00"); * dic.Add("서울특별시", "11"); * dic.Add("부산광역시", "21"); * dic.Add("대구광역시", "22"); * dic.Add("인천광역시", "23"); * dic.Add("광주광역시", "24"); * dic.Add("대전광역시", "25"); * dic.Add("울산광역시", "26"); * * CboDivision.DataSource = new BindingSource(dic, null); * CboDivision.DisplayMember = "Key"; * CboDivision.ValueMember = "Value"; */ }
private void btnNew_Click(object sender, EventArgs e) { InitControls(); myMode = BaseMode.INSERT; TxtIdx.Focus(); }
private void InitControls() { TxtIdx.Clear(); TxtNames.Clear(); TxtAddr.Clear(); TxtMobile.Clear(); TxtEmail.Clear(); CboLevels.SelectedIndex = 0; TxtIdx.Focus(); baseMode = BaseMode.NONE; #region comboBox Dictionary /*Dictionary<string, string> dic = new Dictionary<string, string> * { * { "선택", "00" }, * { "서울특별시", "11" }, * { "부산광역시", "21" }, * { "대구광역시", "22" }, * { "인천광역시", "23" }, * { "광주광역시", "24" }, * { "대전광역시", "25" } * }; * * CboDivision.DataSource = new BindingSource(dic, null); * CboDivision.DisplayMember = "Key"; * CboDivision.ValueMember = "Value";*/ #endregion }
private void InitControls() //초기화하는 구문 { TxtIdx.Text = TxtNames.Text = string.Empty; TxtEmail.Text = TxtAddr.Text = TxtMobile.Text = string.Empty; CboLevels.SelectedIndex = 0; //save하고나서 인덱스0으로바뀜 TxtIdx.Focus(); TxtIdx.ReadOnly = true; myMode = BaseMode.NONE; //아무것도 아닌상태 #region 콤보박스 데이터바인딩 ////콤보 박스 데이터 바인딩 //Dictionary<string, string> dic = new Dictionary<string, string>(); //dic.Add("선택", "00"); //dic.Add("서울특별시", "11");//key value //dic.Add("부산광역시", "21"); //dic.Add("대구광역시", "22"); //dic.Add("인천광역시", "23"); //dic.Add("광주광역시", "24"); //dic.Add("대전광역시", "25"); //CboDivision.DataSource = new BindingSource(dic,null); //폼의 데이터 소스 캡슐화 //CboDivision.DisplayMember = "key"; //CboDivision.ValueMember = "Value"; #endregion }
private void InitControls() //초기화 { TxtIdx.Text = TxtAuthor.Text = string.Empty; TxtISBN.Text = TxtNames.Text = TxtPrice.Text = string.Empty; CboDivision.SelectedIndex = 0; // 선택 TxtIdx.Focus(); TxtIdx.ReadOnly = true; DtpReleaseDate.CustomFormat = "yyyy-MM-dd"; DtpReleaseDate.Format = DateTimePickerFormat.Custom; //형식쓰겠다고 지정 DtpReleaseDate.Value = DateTime.Now; // 현재 날짜로 초기화 mymode = BaseMode.NONE; #region 콤보박스 데이터 바인딩(코드로 가져오기) /* * Dictionary<string, string> dic = new Dictionary<string, string>(); * dic.Add("선택", "00");//선택에대한값 00 * dic.Add("서울특별시", "11"); * dic.Add("부산광역시", "21"); * dic.Add("대구광역시", "22"); * dic.Add("인천광역시", "23"); * dic.Add("광주광역시", "24"); * dic.Add("대전광역시", "25"); * * CboDivision.DataSource = new BindingSource(dic, null);//콤보박스에 데이터 넣기,(dic,데이터멤버) * CboDivision.DisplayMember = "Key"; //화면에 나오는값은 서울특별시 but 소스상에서 넘어가는 데이터는 11 * CboDivision.ValueMember = "Value"; //값 */ #endregion }
private void ClearTextControls() { TxtIdx.Text = TxtAuthor.Text = ""; TxtIdx.ReadOnly = false; TxtIdx.BackColor = Color.White; TxtIdx.Focus(); }
private void GrdDivtbl_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { DataGridViewRow data = GrdBookstbl.Rows[e.RowIndex]; // To Do : 클릭 시 입력컨트롤에 데이터 할당 TxtIdx.Text = data.Cells[0].Value.ToString(); TxtAuthor.Text = data.Cells[1].Value.ToString(); // 로맨스, 추리 등 디스플레이되는 글자로 인덱스 찾기 //CboDivision.SelectedIndex = CboDivision.FindString(data.Cells[3].Value.ToString()); //코드 값을 그대로 할당 B001, B002 CboDivision.SelectedValue = data.Cells[2].Value; TxtNames.Text = data.Cells[4].Value.ToString(); // 출간일 날짜픽커 Cells[5] DtpReleaseDate.CustomFormat = "yyyy-MM-dd"; DtpReleaseDate.Format = DateTimePickerFormat.Custom; DtpReleaseDate.Value = DateTime.Parse(data.Cells[5].Value.ToString()); TxtISBN.Text = data.Cells[6].Value.ToString(); TxtPrice.Text = data.Cells[7].Value.ToString(); TxtIdx.ReadOnly = true; //pk는 바꾸면 난리나니까 바꾸지 못하게 설정 TxtIdx.Focus(); myMode = BaseMode.UPDATE; // 수정 모드 변경 } }
private void InitControls() { TxtIdx.Text = TxtAuthor.Text = string.Empty; TxtISBN.Text = TxtNames.Text = TxtPrice.Text = string.Empty; CboDivision.SelectedIndex = 0; TxtIdx.Focus(); TxtIdx.ReadOnly = true; DtpReleaseDate.CustomFormat = "yyyy-MM-dd"; DtpReleaseDate.Format = DateTimePickerFormat.Custom; DtpReleaseDate.Value = DateTime.Now; myMode = BaseMode.NONE; #region 콤보 박스 데이터바인딩 //Dictionary<string, string> dic = new Dictionary<string, string>(); //dic.Add("선택", "00"); //dic.Add("서울특별시", "11"); //dic.Add("부산광역시", "21"); //dic.Add("대구광역시", "22"); //dic.Add("인천광역시", "23"); //dic.Add("광주광역시", "24"); //dic.Add("대전광역시", "25"); //CboDivision.DataSource = new BindingSource(dic, null); //CboDivision.DisplayMember = "Key"; //CboDivision.ValueMember = "Value"; #endregion }
/* * private void DeleteProcess() * { * try * { * using (MySqlConnection conn = new MySqlConnection(Commons.CONNSTR)) * { * conn.Open();//커넥션오픈,using쓰면 자동으로 conn.close();해줌 * MySqlCommand cmd = new MySqlCommand(); * cmd.Connection = conn; * cmd.CommandText = "DELETE FROM divtbl " + * " WHERE Division = @Division "; * * MySqlParameter paramDivision = new MySqlParameter("@Division", MySqlDbType.VarChar); * paramDivision.Value = TxtDivision.Text; * cmd.Parameters.Add(paramDivision); * * var result = cmd.ExecuteNonQuery(); * * MetroMessageBox.Show(this, $"{result}건이 삭제되었습니다.", "삭제"); * } * } * catch (Exception ex) * { * MetroMessageBox.Show(this, $"에러발생{ex.Message}", "에러", MessageBoxButtons.OK, MessageBoxIcon.Error); * throw; * } * finally * { * * } * } */ #endregion private void BtnNew_Click(object sender, EventArgs e) { InitControls(); mymode = BaseMode.INSERT;//신규입력모드 TxtIdx.Focus(); }
private void ClearTextControls() { TxtIdx.Text = TxtNames.Text = TxtAddr.Text = TxtMobile.Text = TxtEmail.Text = ""; CboLevels.SelectedIndex = -1; TxtIdx.ReadOnly = true; TxtIdx.BackColor = Color.White; TxtIdx.Focus(); }
//컨트롤 초기화 private void InitControls() { TxtIdx.Text = TxtNames.Text = TxtAddr.Text = TxtEmail.Text = TxtMobile.Text = string.Empty; TxtIdx.Focus(); CboLevels.SelectedIndex = 0; MyMode = BaseMode.NONE; }
// 버튼을 클릭했을때 빈칸으로 만들어주는 메서드 private void ClearTextControls() // 중복된 코드를 메서드로 묶어주기 { TxtIdx.Text = TxtNames.Text = TxtAddr.Text = TxtEmail.Text = TxtMobile.Text = ""; CboLevels.SelectedIndex = -1; // 콤보박스를 빈칸으로 해줌(초기화) TxtIdx.ReadOnly = true; TxtIdx.BackColor = Color.Beige; TxtIdx.Focus(); }
private void IninControls() { TxtIdx.Text = TxtNames.Text = ""; TxtAddr.Text = TxtMobile.Text = TxtEmail.Text = string.Empty; CboLevel.SelectedIndex = 0; TxtIdx.ReadOnly = true; TxtIdx.Focus(); myMode = BaseMode.NONE; }
private void InitControls() { TxtIdx.Text = TxtName.Text = string.Empty; TxtAdr.Text = TxtPhone.Text = TxtEmail.Text = string.Empty; CboGrade.SelectedIndex = 0; TxtIdx.Focus(); TxtIdx.ReadOnly = true; MyMode = BaseMode.NONE; }
//private void DeleteProcess() //{ // try // { // using (MySqlConnection conn = new MySqlConnection(Commons.CONNSTR)) // { // //conn 만들면 무조건 open,close // //using으로 쓰면 자동으로 해줌 // conn.Open(); // MySqlCommand cmd = new MySqlCommand(); // cmd.Connection = conn; // cmd.CommandText = "DELETE FROM divtbl " + // " WHERE Division = @Division "; // MySqlParameter paramDivision = new MySqlParameter("@Division", MySqlDbType.VarChar); // paramDivision.Value = TxtDivision.Text; // cmd.Parameters.Add(paramDivision); // var result = cmd.ExecuteNonQuery(); // MetroMessageBox.Show(this, $"{result}건이 삭제되었습니다.", "삭제"); // } // } // catch (Exception ex) // { // MetroMessageBox.Show(this, $"에러발생 {ex.Message}", "에러", // MessageBoxButtons.OK, MessageBoxIcon.Error); // } // finally // { // UpdateData(); // } //} #endregion private void BtnNew_Click(object sender, EventArgs e) { //text박스 비워주기 TxtIdx.Text = TxtAuthor.Text = string.Empty; TxtIdx.ReadOnly = true; TxtIdx.Focus(); //신규는 INSERT myMode = BaseMode.INSERT; //신규 입력모드 }
private void ClearTextControls() { TxtIdx.Text = TxtAuthor.Text = TxtTitle.Text = TxtISBN.Text = TxtPrice.Text = string.Empty; TxtIdx.ReadOnly = true; CboDivision.SelectedIndex = -1; DtpReleaseDate.CustomFormat = " "; DtpReleaseDate.Format = DateTimePickerFormat.Custom; TxtIdx.Focus(); }
private void ClearTextControls() { TxtIdx.Text = ""; TxtIdx.ReadOnly = true; TxtIdx.BackColor = Color.Beige; CboMemberIdx.SelectedIndex = CboBookIdx.SelectedIndex = -1; DtpRental.CustomFormat = DtpReturn.CustomFormat = " "; DtpRental.Format = DtpReturn.Format = DateTimePickerFormat.Custom; TxtIdx.Focus(); }
private void btnNew_Click(object sender, EventArgs e) { TxtIdx.Text = string.Empty; TxtAuthor.Text = TxtIsbn.Text = TxtNames.Text = TxtPrice.Text = string.Empty; CboDivision.SelectedIndex = 0; DtpReleaseDate.Value = DateTime.Now; TxtIdx.ReadOnly = true; TxtIdx.Focus(); myMode = BaseMode.INSERT; }
private void ClearTextControls() { TxtIdx.Text = TxtAuthor.Text = TxtNames.Text = TxtISBN.Text = ""; TxtPrice.Text = ""; CboDivision.SelectedIndex = -1; TxtIdx.ReadOnly = true; TxtIdx.BackColor = Color.Beige; DtpReleaseDate.CustomFormat = " "; DtpReleaseDate.Format = DateTimePickerFormat.Custom; TxtIdx.Focus(); }
private void InitControls() { TxtIdx.Text = String.Empty; TxtIdx.Focus(); TxtIdx.ReadOnly = true; CboMember.SelectedIndex = CboBook.SelectedIndex = 0; DtpRentalDate.CustomFormat = "yyyy-MM-dd"; DtpRentalDate.Format = DateTimePickerFormat.Custom; DtpRentalDate.Value = DateTime.Now; DtpReturnDate.CustomFormat = ""; DtpReturnDate.Format = DateTimePickerFormat.Custom; MyMode = BaseMode.NONE; }
// 초기화 함수 private void InitControls() { TxtIdx.Text = string.Empty; TxtIdx.Focus(); CboMember.SelectedIndex = 0; CboBookNames.SelectedIndex = 0; DtirentalDate.CustomFormat = "yyyy-MM-dd"; DtirentalDate.Format = DateTimePickerFormat.Custom; DtirentalDate.Value = DateTime.Now; // 현재 날짜로 초기화 DtireturnDate.CustomFormat = " "; DtireturnDate.Format = DateTimePickerFormat.Custom; TxtIdx.ReadOnly = true; myMode = BaseMode.NONE; }
private void InitControls() { //TxtIdx.Text = TxtNames.Text = string.Empty; //TxtAddr.Text = TxtEmail.Text = TxtMobile.Text = string.Empty; //CboBook.SelectedIndex = 0; TxtIdx.Text = String.Empty; //string : C# class, String : .NET class TxtIdx.Focus(); TxtIdx.ReadOnly = true; CboMember.SelectedIndex = CboBook.SelectedIndex = 0; DtpRentalDate.CustomFormat = "yyyy-MM-dd"; DtpRentalDate.Format = DateTimePickerFormat.Custom; DtpRentalDate.Value = DateTime.Now; DtpReturnDate.CustomFormat = " "; //반납일.빈값넣기 DtpReturnDate.Format = DateTimePickerFormat.Custom; mymode = BaseMode.NONE; }
private void InitControls() { //text박스 비워주기 TxtIdx.Text = string.Empty; TxtIdx.Focus(); TxtIdx.ReadOnly = true; CboMember.SelectedIndex = CboBook.SelectedIndex = 0; DtpRentalDate.CustomFormat = "yyyy-MM-dd"; DtpRentalDate.Format = DateTimePickerFormat.Custom; DtpRentalDate.Value = DateTime.Now; //빈값을 넣으려면 비워주기 (반납일) DtpReturnDate.CustomFormat = " "; DtpReturnDate.Format = DateTimePickerFormat.Custom; TxtIdx.ReadOnly = true; myMode = BaseMode.NONE; #region 콤보박스 ////콤보박스 데이터바인딩 //Dictionary<string, string> dic = new Dictionary<string, string>(); //dic.Add("선택", "00"); //dic.Add("서울 특별시","11"); //dic.Add("부산 광역시", "21"); //dic.Add("대구 광역시", "22"); //dic.Add("인천 광역시", "23"); //dic.Add("광주 광역시", "24"); //dic.Add("대전 광역시", "25"); //CboDivision.DataSource = new BindingSource(dic, null); //CboDivision.DisplayMember = "Key"; //CboDivision.ValueMember = "Value"; #endregion }
public FrmMain() { InitializeComponent(); TxtIdx.Focus(); }