void setModify(DataSet1.GOODSRow data) { b = data.GDS_IMG; if (b != null) { pb_img.Image = new Bitmap(new MemoryStream(b)); } string gds_id = data.GDS_ID.ToString(); string gds_name = data.GDS_NAME; string gds_qty = data.GDS_QTY.ToString(); string slvs_no = data.SLVS_NO; string gdstype_no = data.GDSTYPE_NO; string gdsgrade_no = data.GDSGRADE_NO; string gdsunit_id = data.GDSUNIT_ID; string gds_price = data.GDS_PRICE.ToString(); string gds_model = data.GDS_MODEL.ToString(); buyinggoodsTableAdapter1.Fill(dataSet1.BUYINGGOODS); goodsunitTableAdapter1.Fill(dataSet1.GOODSUNIT); goodsgradeTableAdapter1.Fill(dataSet1.GOODSGRADE); shelvesTableAdapter1.Fill(dataSet1.SHELVES); goodsstoreTableAdapter1.Fill(dataSet1.GOODSSTORE); goodstypeTableAdapter1.Fill(dataSet1.GOODSTYPE); DataSet1.BUYINGGOODSDataTable table = buyinggoodsTableAdapter1.GetData(); DataRow[] rows = table.Select("gds_id = " + gds_id); DataRow row = rows[0]; tb_name.Text = gds_name; tb_price.Text = gds_price; tb_qty.Text = gds_qty; tb_model.Text = gds_model; drbtn_unit.Text = goodsunitTableAdapter1.GetData().Select("gdsunit_id = " + gdsunit_id)[0]["gdsunit_desc"] as string; drbtn_grade.Text = goodsgradeTableAdapter1.GetData().Select("gdsgrade_no = " + gdsgrade_no)[0]["gdsgrade_desc"] as string; drbtn_slvs.Text = shelvesTableAdapter1.GetData().Select("slvs_no = " + slvs_no)[0]["slvs_desc"] as string; drbtn_store.Text = goodsstoreTableAdapter1.GetData().Select("str_id = " + row["str_id"])[0]["str_name"] as string; drbtn_vendor.Text = goodstypeTableAdapter1.GetData().Select("gdstype_no = " + gdsgrade_no)[0]["gdstype_desc"] as string; }
private void Buy() { int ret; try { if (b.Length * tb_name.TextLength * tb_model.TextLength * tb_qty.TextLength * tb_price.TextLength * drbtn_unit.Text.Length * drbtn_grade.Text.Length * drbtn_slvs.Text.Length * drbtn_store.Text.Length * drbtn_vendor.Text.Length == 0) { return; } if (drbtn_unit.Text.Equals("단위")) { return; } goodsTableAdapter1.Fill(dataSet1.GOODS); goodsgradeTableAdapter1.Fill(dataSet1.GOODSGRADE); goodstypeTableAdapter1.Fill(dataSet1.GOODSTYPE); goodsunitTableAdapter1.Fill(dataSet1.GOODSUNIT); DataSet1.GOODSGRADEDataTable goodsgradeDataTable = goodsgradeTableAdapter1.GetData(); DataSet1.GOODSTYPEDataTable goodstypeDataTable = goodstypeTableAdapter1.GetData(); DataSet1.GOODSUNITDataTable goodsunitDataTable = goodsunitTableAdapter1.GetData(); string gdsgrade_no; // DataRow[] gradeData = goodsgradeDataTable.Select("gdsgrade_desc = " + drbtn_grade.Text); // gdsgrade_no = gradeData[0]["gdsgrade_no"] as string; gdsgrade_no = goodsgradeTableAdapter1.GetDataByDesc(drbtn_grade.Text)[0].GDSGRADE_NO; string gdstype_no; // DataRow[] typeData = goodstypeDataTable.Select("gdstype_desc = " + drbtn_vendor.Text); // gdstype_no = typeData[0]["gdstype_no"] as string; gdstype_no = goodstypeTableAdapter1.GetDataByDesc(drbtn_vendor.Text)[0].GDSTYPE_NO; string gdsunit_id; // DataRow[] unitData = goodsunitDataTable.Select("gdsunit_desc = " + drbtn_unit.Text); // gdsunit_id = unitData[0]["gdsunit_id"] as string; gdsunit_id = goodsunitTableAdapter1.GetDataByDesc(drbtn_unit.Text)[0].GDSUNIT_ID; string slvs_no; slvs_no = shelvesTableAdapter1.GetDataByDesc(drbtn_slvs.Text)[0].SLVS_NO; DataSet1.GOODSDataTable goodsDataTable = goodsTableAdapter1.GetData(); DataSet1.GOODSRow goodsRow = goodsDataTable.NewGOODSRow(); goodsRow.GDS_IMG = b; goodsRow.GDS_NAME = tb_name.Text; goodsRow.GDSGRADE_NO = gdsgrade_no; goodsRow.GDSTYPE_NO = gdstype_no; goodsRow.GDSUNIT_ID = gdsunit_id; goodsRow.SLVS_NO = slvs_no; goodsRow.GDS_PRICE = int.Parse(tb_price.Text); goodsRow.GDS_QTY = int.Parse(tb_qty.Text); goodsRow.GDS_MODEL = tb_model.Text; goodsDataTable.Rows.Add(goodsRow); ret = goodsTableAdapter1.Update(goodsDataTable); if (ret < 1) { throw new Exception("상품등록 실패"); } goodsstoreTableAdapter1.Fill(dataSet1.GOODSSTORE); buyinggoodsTableAdapter1.Fill(dataSet1.BUYINGGOODS); DataSet1.GOODSSTOREDataTable goodsstoreDataTable = goodsstoreTableAdapter1.GetData(); DataSet1.BUYINGGOODSDataTable buyinggoodsDataTable = buyinggoodsTableAdapter1.GetData(); goodsDataTable = goodsTableAdapter1.GetData(); int gds_id = int.Parse(goodsRow.GDS_ID.ToString()); int str_id; //DataRow[] storeData = goodsstoreDataTable.Select("str_name = " + drbtn_store.Text); // str_id = int.Parse(storeData[0]["str_id"] as string); str_id = int.Parse(goodsstoreTableAdapter1.GetDataByName(drbtn_store.Text)[0].STR_ID.ToString()); DataSet1.BUYINGGOODSRow buyinggoodsRow = buyinggoodsDataTable.NewBUYINGGOODSRow(); buyinggoodsRow.BUYING_DATE = getDateServerTime(); buyinggoodsRow.GDS_ID = gds_id; buyinggoodsRow.STR_ID = str_id; buyinggoodsRow.MNG_ID = Form1.account; buyinggoodsDataTable.Rows.Add(buyinggoodsRow); ret = buyinggoodsTableAdapter1.Update(buyinggoodsDataTable); if (ret < 1) { throw new Exception("구매정보 등록 실패"); } MessageBox.Show("업데이트 성공"); this.Close(); } catch (Exception e) { MessageBox.Show(e.Message, "실패"); } }