private void FrmMaterialCostPop_Load(object sender, EventArgs e) { //콤보박스 바인딩 BindingComboBox(); cboUseYN.SelectedIndex = 0; txtMDFDate.Text = DateTime.Now.ToShortDateString(); if (InsertOrUpdate == 1) //등록 { txtExPrice.ReadOnly = false; } else //수정 { txtExPrice.ReadOnly = true; //서비스 호출 CostService service = new CostService(); var vo = service.GetMaterialCostInfo(MCCode); cboCompany.SelectedIndex = cboCompany.FindStringExact(vo.COM_NAME); cboItem.SelectedIndex = cboItem.FindStringExact(vo.ITEM_NAME); cboUseYN.SelectedIndex = cboUseYN.FindStringExact(vo.MC_USE_YN); txtNowPrice.Text = vo.MC_UNITPRICE_CUR.ToString(); txtExPrice.Text = vo.MC_UNITPRICE_EX.ToString(); dtpStartDate.Value = Convert.ToDateTime(vo.MC_STARTDATE); txtEndDate.Text = vo.MC_ENDDATE; txtRemark.Text = vo.MC_REMARK; txtCode.Text = vo.MC_Code.ToString(); } }
private void LoadCostList() { //서비스 호출 CostService service = new CostService(); AllList = service.SalesCostList(); dgvCost.DataSource = null; dgvCost.DataSource = AllList; }
/// <summary> /// 저장이벤트 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { //유효성 검사 if (!(txtNowPrice.Text.Trim().Length > 0)) { MessageBox.Show("현재단가는 입력 필수값입니다.", "필수 입력", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!(txtExPrice.Text.Trim().Length > 0)) { MessageBox.Show("이전단가는 입력 필수값입니다.", "필수 입력", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //전달할 VO MaterialCost_VO vo = new MaterialCost_VO(); vo.COM_Code = cboCompany.SelectedValue.ToString(); vo.ITEM_Code = cboItem.SelectedValue.ToString(); vo.MC_UNITPRICE_CUR = int.Parse(txtNowPrice.Text); vo.MC_UNITPRICE_EX = int.Parse(txtExPrice.Text); vo.MC_STARTDATE = dtpStartDate.Value.ToShortDateString(); vo.MC_ENDDATE = Convert.ToDateTime(txtEndDate.Text).ToShortDateString(); vo.MC_USE_YN = cboUseYN.Text; vo.MC_Code = 0; //등록 if (InsertOrUpdate == 2) { vo.MC_Code = int.Parse(txtCode.Text); //수정 } vo.MC_LAST_MDFR = LoginInfo.UserInfo.LI_ID; vo.MC_LAST_MDFY = txtMDFDate.Text; vo.MC_REMARK = txtRemark.Text.Trim(); //서비스호출 CostService service = new CostService(); var msg = service.InsertOrUpdateMaterialCost(vo); if (msg.IsSuccess) { MessageBox.Show(msg.ResultMessage); this.Close(); } else { MessageBox.Show(msg.ResultMessage); return; } }
public void Delete(object sender, EventArgs e) { if (((FrmMAIN)this.MdiParent).ActiveMdiChild == this) { string lists = CheckedList(); if (lists.Length > 0) { if (MessageBox.Show("정말로 삭제하시겠습니까?", "삭제확인", MessageBoxButtons.YesNo) == DialogResult.Yes) { //서비스 호출 CostService service = new CostService(); if (service.DeleteSalesCostList(lists, "@")) { MessageBox.Show("삭제되었습니다.", "삭제 성공", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("삭제 중 오류가 발생하였습니다. 다시 시도하여 주십시오.", "삭제 실패", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } Reset(null, null); } }
/// <summary> /// 엑셀 파일 읽어와서 등록하는 메서드 /// </summary> private void GetExcelFile() { Excel.Application xlApp = null; Excel.Workbook xlWorkBook = null; Excel.Worksheet xlWorkSheet = null; DataTable dt = new DataTable(); try { xlApp = new Excel.Application(); xlWorkBook = xlApp.Workbooks.Open(openFileName); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); Excel.Range range = xlWorkSheet.UsedRange; object[,] data = range.Value; for (int i = 1; i <= range.Columns.Count; i++) { dt.Columns.Add(data[1, i].ToString(), typeof(string)); } for (int r = 2; r <= range.Rows.Count; r++) { DataRow dr = dt.Rows.Add(); for (int c = 1; c <= range.Columns.Count; c++) { dr[c - 1] = data[r, c]; } } xlWorkBook.Close(true); xlApp.Quit(); if (dt.Rows.Count > 0) { //DB에 저장 for (int i = 0; i < dt.Rows.Count; i++) { //전달할 VO SalesCost_VO vo = new SalesCost_VO(); vo.COM_Code = (dt.Rows[i][0] != null) ? dt.Rows[i][0].ToString() : ""; vo.ITEM_Code = (dt.Rows[i][1] != null) ? dt.Rows[i][1].ToString() : ""; vo.SC_UNITPRICE_CUR = (dt.Rows[i][2] != null) ? Convert.ToInt32(dt.Rows[i][2]) : 0; vo.SC_UNITPRICE_EX = 0; vo.SC_STARTDATE = (dt.Rows[i][3] != null) ? DateTime.ParseExact(dt.Rows[i][3].ToString(), "yyyy-MM-dd tt hh:mm:ss", null, System.Globalization.DateTimeStyles.AssumeLocal).ToString("yyyy-MM-dd HH:mm:ss") : ""; vo.SC_ENDDATE = "2099-01-01"; vo.SC_USE_YN = (dt.Rows[i][4] != null) ? dt.Rows[i][4].ToString() : ""; vo.SC_CODE = 0; vo.SC_LAST_MDFR = LoginInfo.UserInfo.LI_ID; vo.SC_LAST_MDFY = DateTime.Now.ToShortDateString(); vo.SC_REMARK = (dt.Rows[i][5] != null) ? dt.Rows[i][5].ToString() : ""; //서비스호출 CostService service = new CostService(); var msg = service.InsertOrUpdateSalesCost(vo); if (msg.IsSuccess) { MessageBox.Show(msg.ResultMessage); this.Close(); } else { MessageBox.Show(msg.ResultMessage); return; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (xlApp != null) { releaseObject(xlWorkSheet); releaseObject(xlWorkBook); releaseObject(xlApp); } this.DialogResult = DialogResult.OK; } }