private void btnAdd_Click(object sender, EventArgs e) { // 呼叫新增畫面 Forms.AddABCardSubjectNameForm asnf = new AddABCardSubjectNameForm(_ABCardTemplateTransfer.GetAllSubjectNameList()); if (asnf.ShowDialog() == System.Windows.Forms.DialogResult.Yes) { string SubjectName = asnf.GetAddSubjectName(); if (!string.IsNullOrEmpty(SubjectName)) { XElement elm = new XElement("Subject"); elm.SetAttributeValue("label", SubjectName); DAO.UDT_ABCardTemplateDefinitionDef abtdf = new DAO.UDT_ABCardTemplateDefinitionDef(); abtdf.SubjectName = SubjectName; abtdf.Content = elm.ToString(); // 呼叫UDT 新增資料 List<DAO.UDT_ABCardTemplateDefinitionDef> addList = new List<DAO.UDT_ABCardTemplateDefinitionDef>(); addList.Add(abtdf); DAO.UDTTransfer.InsertABCardTemplate(addList); // 畫面重新載入 _BGRun(); } } }
private void btnDel_Click(object sender, EventArgs e) { // 檢查畫面是否有選 if (itmPnlSubjectName.SelectedItems.Count == 1) { ButtonItem selItem = itmPnlSubjectName.SelectedItems[0] as ButtonItem; if (selItem != null) { // 提示是否刪除 if (FISCA.Presentation.Controls.MsgBox.Show("請問確認刪除[" + selItem.Name + "]?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { // 收集刪除資料 List <DAO.UDT_ABCardTemplateDefinitionDef> delList = new List <DAO.UDT_ABCardTemplateDefinitionDef> (); DAO.UDT_ABCardTemplateDefinitionDef abtd = _ABCardTemplateTransfer.GetUDTTemplateBySubjectLabel(selItem.Name); if (abtd != null) { delList.Add(abtd); } // 執行刪除 DAO.UDTTransfer.DeleteABCardTemplate(delList); // 重新載入畫面 _BGRun(); } } } else { FISCA.Presentation.Controls.MsgBox.Show("請選擇資料"); } }
private void btnAdd_Click(object sender, EventArgs e) { // 呼叫新增畫面 Forms.AddABCardSubjectNameForm asnf = new AddABCardSubjectNameForm(_ABCardTemplateTransfer.GetAllSubjectNameList()); if (asnf.ShowDialog() == System.Windows.Forms.DialogResult.Yes) { string SubjectName = asnf.GetAddSubjectName(); if (!string.IsNullOrEmpty(SubjectName)) { XElement elm = new XElement("Subject"); elm.SetAttributeValue("label", SubjectName); DAO.UDT_ABCardTemplateDefinitionDef abtdf = new DAO.UDT_ABCardTemplateDefinitionDef(); abtdf.SubjectName = SubjectName; abtdf.Content = elm.ToString(); // 呼叫UDT 新增資料 List <DAO.UDT_ABCardTemplateDefinitionDef> addList = new List <DAO.UDT_ABCardTemplateDefinitionDef>(); addList.Add(abtdf); DAO.UDTTransfer.InsertABCardTemplate(addList); // 畫面重新載入 _BGRun(); } } }
/// <summary> /// 透過 SubjectLabel 取得 UDT 內資料(Cache) /// </summary> /// <param name="SubjectLabel"></param> /// <returns></returns> public DAO.UDT_ABCardTemplateDefinitionDef GetUDTTemplateBySubjectLabel(string SubjectLabel) { DAO.UDT_ABCardTemplateDefinitionDef retVal = null; foreach (DAO.UDT_ABCardTemplateDefinitionDef data in _ABCardTemplate) { if (data.SubjectName == SubjectLabel) { retVal = data; } } return(retVal); }
private void btnSave_Click(object sender, EventArgs e) { List <DAO.UDT_ABCardTemplateDefinitionDef> updateList = new List <DAO.UDT_ABCardTemplateDefinitionDef>(); List <DAO.UDT_ABCardTemplateDefinitionDef> insertrList = new List <DAO.UDT_ABCardTemplateDefinitionDef>(); List <DAO.UDT_ABCardTemplateDefinitionDef> deleteList = new List <DAO.UDT_ABCardTemplateDefinitionDef>(); List <string> UIDList = new List <string>(); foreach (DataGridViewRow dgvr in dgSetTemplate.Rows) { if (dgvr.IsNewRow) { continue; } DAO.UDT_ABCardTemplateDefinitionDef data = dgvr.Tag as DAO.UDT_ABCardTemplateDefinitionDef; if (data != null) { if (dgvr.Cells[colXML.Index].Value != null) { data.Content = dgvr.Cells[colXML.Index].Value.ToString(); } else { data.Content = ""; } if (dgvr.Cells[colName.Index].Value != null) { data.SubjectName = dgvr.Cells[colName.Index].Value.ToString(); } else { data.SubjectName = ""; } if (!string.IsNullOrEmpty(data.UID)) { updateList.Add(data); UIDList.Add(data.UID); } } else { DAO.UDT_ABCardTemplateDefinitionDef dataI = new DAO.UDT_ABCardTemplateDefinitionDef(); if (dgvr.Cells[colXML.Index].Value != null) { dataI.Content = dgvr.Cells[colXML.Index].Value.ToString(); } else { dataI.Content = ""; } if (dgvr.Cells[colName.Index].Value != null) { dataI.SubjectName = dgvr.Cells[colName.Index].Value.ToString(); } else { dataI.SubjectName = ""; } insertrList.Add(dataI); } } // delete foreach (DAO.UDT_ABCardTemplateDefinitionDef data in ABCardTemplate) { if (!UIDList.Contains(data.UID)) { data.Deleted = true; deleteList.Add(data); } } if (deleteList.Count > 0) { DAO.UDTTransfer.DeleteABCardTemplate(deleteList); } if (updateList.Count > 0 || insertrList.Count > 0) { if (updateList.Count > 0) { DAO.UDTTransfer.UpdateABCardTemplate(updateList); } if (insertrList.Count > 0) { DAO.UDTTransfer.InsertABCardTemplate(insertrList); } FISCA.Presentation.Controls.MsgBox.Show("儲存完成."); } btnSave.Enabled = false; }
private void btnSave_Click(object sender, EventArgs e) { List<DAO.UDT_ABCardTemplateDefinitionDef> updateList = new List<DAO.UDT_ABCardTemplateDefinitionDef>(); List<DAO.UDT_ABCardTemplateDefinitionDef> insertrList = new List<DAO.UDT_ABCardTemplateDefinitionDef>(); List<DAO.UDT_ABCardTemplateDefinitionDef> deleteList = new List<DAO.UDT_ABCardTemplateDefinitionDef>(); List<string> UIDList = new List<string>(); foreach (DataGridViewRow dgvr in dgSetTemplate.Rows) { if (dgvr.IsNewRow) continue; DAO.UDT_ABCardTemplateDefinitionDef data = dgvr.Tag as DAO.UDT_ABCardTemplateDefinitionDef; if (data != null) { if (dgvr.Cells[colXML.Index].Value != null) data.Content = dgvr.Cells[colXML.Index].Value.ToString(); else data.Content = ""; if (dgvr.Cells[colName.Index].Value != null) data.SubjectName = dgvr.Cells[colName.Index].Value.ToString(); else data.SubjectName = ""; if (!string.IsNullOrEmpty(data.UID)) { updateList.Add(data); UIDList.Add(data.UID); } } else { DAO.UDT_ABCardTemplateDefinitionDef dataI = new DAO.UDT_ABCardTemplateDefinitionDef(); if (dgvr.Cells[colXML.Index].Value != null) dataI.Content = dgvr.Cells[colXML.Index].Value.ToString(); else dataI.Content = ""; if (dgvr.Cells[colName.Index].Value != null) dataI.SubjectName = dgvr.Cells[colName.Index].Value.ToString(); else dataI.SubjectName = ""; insertrList.Add(dataI); } } // delete foreach (DAO.UDT_ABCardTemplateDefinitionDef data in ABCardTemplate) { if (!UIDList.Contains(data.UID)) { data.Deleted = true; deleteList.Add(data); } } if (deleteList.Count > 0) DAO.UDTTransfer.DeleteABCardTemplate(deleteList); if (updateList.Count > 0 || insertrList.Count >0) { if(updateList.Count >0) DAO.UDTTransfer.UpdateABCardTemplate(updateList); if (insertrList.Count > 0) DAO.UDTTransfer.InsertABCardTemplate(insertrList); FISCA.Presentation.Controls.MsgBox.Show("儲存完成."); } btnSave.Enabled = false; }