private void DuplicatePart_function(object sender, EventArgs e) { //PartData temPartdata = new PartData ((PartData)LKManager.PartListImport.BindingSourcePart.Current); //LKManager.PartListImport.BindingSourcePart.Add(temPartdata); //LKManager.PartListImport.BindingSourcePart.ResetBindings(true); LKManager.Duplicate_Part_Data(); }
private void button1_Click(object sender, EventArgs e) { using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "TXT|*.txt|CSV|*.csv", ValidateNames = true }) { if (sfd.ShowDialog() == DialogResult.OK) { try { #region Get Extension file // https://stackoverflow.com/questions/4990910/how-to-get-file-extension-from-save-file-dialog var extension = Path.GetExtension(sfd.FileName); string currentNameFile = Path.GetFileNameWithoutExtension(sfd.FileName); switch (extension.ToLower()) { case ".txt": MessageBox.Show(string.Format("txt: {0}", extension.ToLower())); LKManager.WriteLinhKienItemToTxt(LKManager.LKListImport, sfd.FileName); string newPath = sfd.FileName.Replace(currentNameFile, string.Format("{0}_KEYWORD", currentNameFile)); LKManager.WriteKeyWordLinhKienItemToTxt(LKManager.LKListImport, newPath); break; case ".csv": // ToDo: Save as PNG //MessageBox.Show(string.Format("csv: {0}", extension.ToLower())); LKManager.WriteLinhKienItemToCsv(LKManager.LKListImport, sfd.FileName); break; default: throw new ArgumentOutOfRangeException(extension); } #endregion #region Save to TXT //LKManager.WriteLinhKienItemToTxt(LKManager.LKListImport, sfd.FileName); #endregion } catch (Exception e44) { Console.WriteLine("Exception: " + e44.Message); } finally { Console.WriteLine("Executing finally block."); } } MessageBox.Show("Đã lưu Data", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btn_ReadPartCsv_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog() { Filter = "CSV file|*.csv" }) { if (ofd.ShowDialog() == DialogResult.OK) { //dataGridView2.DataSource = ReadCsvFile(ofd.FileName); LKManager.ReadCsvFileToPart(ofd.FileName); } } }
private void button2_Click(object sender, EventArgs e) { #region Btn Read CSV to DataGrid //using (OpenFileDialog ofd = new OpenFileDialog() { Filter = "CSV|*.csv", ValidateNames = true }) //{ // if (ofd.ShowDialog() == DialogResult.OK) // { // StreamReader sr = new StreamReader(ofd.FileName); // string[] headers = sr.ReadLine().Split(','); // DataTable dt = new DataTable(); // foreach (string header in headers) // { // //dt.Columns.Add(header); // dataGridView1.Columns.Add("abc1", header); // } // while (!sr.EndOfStream) // { // string[] rows = Regex.Split(sr.ReadLine(), ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"); // int indexRow = dataGridView1.Rows.Add(); // for (int i = 0; i < headers.Length; i++) // { // //https://www.youtube.com/watch?v=WVLL1xa6Ryo // dataGridView1.Rows[indexRow].Cells[i].Value = rows[i]; // } // } // } //} #endregion #region Read CSV LinhKien using (OpenFileDialog ofd = new OpenFileDialog() { Filter = "CSV|*.csv", ValidateNames = true }) { if (ofd.ShowDialog() == DialogResult.OK) { //LinhKienDataViewAndAdvancedSort(LKManager.ReadCsvFileToLinhKien(ofd.FileName)); LKManager.ReadCsvFileToLinhKien(ofd.FileName); } } #endregion }
private void btn_writeCsvPart_Click(object sender, EventArgs e) { using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "CSV|*.csv", ValidateNames = true }) { if (sfd.ShowDialog() == DialogResult.OK) { //CreateCSVFile((DataTable)dataGridView2.DataSource, sfd.FileName); //CreateCSVFile((DataTable)dataGridView2.DataSource, "I://ConvertedFile.csv"); //CreateCSVFile2(dataGridView2, sfd.FileName); LKManager.WritePartItemToCsv(LKManager.PartListImport, sfd.FileName); MessageBox.Show("Đã lưu Csv 2", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btn_UpdatePanelLine_Click(object sender, EventArgs e) { LKManager.ExportLinhKienToPanelLine_2(LKManager.LKListImport, (float)nud_LongX.Value, (float)nud_LongY.Value, (int)nud_NumX.Value, (int)nud_NumY.Value); //string msBoxString = LKManager.ExportLinhKienToKeyWord(LKManager.LKListExport); //MessageBox.Show(msBoxString); }
private void btnUpdatePart_Click(object sender, EventArgs e) { LKManager.EditPart(); }
private void btn_Edit_LK_Click(object sender, EventArgs e) { LKManager.EditLinhKien(); }
private void btnContext_Edit_LK_Click(object sender, EventArgs e) { cb_Part.SelectedIndex = ComBobox_partName.SelectedIndex; LKManager.EditLinhKien(); }
private void SetMarkPoint(object sender, EventArgs e) { LKManager.setMarkPoint_LKdata(); }