protected void btn_DeleteItemWithoutStock_Click(object sender, System.EventArgs e) { #region try { string strITEM = "", strPERIOD = ""; Int32 i32Item = 0, i32Store = 0; if (dtDisItem != null && dtDisItem.Rows.Count > 0) { for (Int32 i = 0; i <= dtDisItem.Rows.Count - 1; i++) { if (dtDisItem.Rows[i]["ONHD_QTY"].ToString() == "" || dtDisItem.Rows[i]["ONHD_QTY"].ToString() == "0") { #region 刪除配本品項明細 strITEM = dtDisItem.Rows[i]["ITEM"].ToString().Trim(); strPERIOD = dtDisItem.Rows[i]["PERIOD"].ToString().Trim(); dtDisItem.Rows.RemoveAt(i); i32Item++; #endregion #region 刪除門市分配明細 if (dtDisStoreAll != null && dtDisStoreAll.Rows.Count > 0) { for (Int32 j = dtDisStoreAll.Rows.Count - 1; j >= 0; j--) { if (dtDisStoreAll.Rows[j].RowState != DataRowState.Deleted && dtDisStoreAll.Rows[j]["ITEM"].ToString().Trim() == strITEM && dtDisStoreAll.Rows[j]["PERIOD"].ToString().Trim() == strPERIOD) { dtDisStoreAll.Rows.RemoveAt(j); i32Store++; } } } #endregion } } #region 儲存異動 if (i32Item != 0 && i32Store != 0) { ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); bool bResult = BCO.UpdateDisCRMRecord(dtDisMain, dtDisItem, dtDisItemOld, dtDisStoreAll, dtDisStoreAllOld, s_DIS_NO, null); if (bResult) { ResultMsgLabel.Text = string.Format("刪除成功,品項明細 {0} 筆、門市明細 {1} 筆。", i32Item, i32Store); QueryData(); } else ResultMsgLabel.Text = "刪除失敗"; } else { ResultMsgLabel.Text = "無刪除資料"; } #endregion } else { ResultMsgLabel.Text = "無刪除資料"; } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
protected void btn_Save_Click(object sender, EventArgs e) { #region try { ErrorMsgLabel.Text = ""; ResultMsgLabel.Text = ""; bool bResult = false; DateTime ProcessingDateTime = DateTime.Now; string strDisDate = SLP_SLPDate1_DisDate.Text; string strStAcceptDate = SLP_SLPDate2_StAcceptDate.Text; string strChanNo = SLP_StoreChain1.Text; string strPOSourceNo = txt_POSourceNo.Text.Trim(); string strUserId = Session["UID"].ToString(); string vDisNo; SetDisMain(strDisDate, strStAcceptDate, strChanNo, strPOSourceNo, strUserId, ProcessingDateTime); SetDisItem(strUserId, ProcessingDateTime); SetDisStoreAll(strUserId, ProcessingDateTime); if (CurrentPageMode == PageCurrentMode.Insert) { #region if (CheckPOsourceNoIsExisted()) { ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); bResult = BCO.CreateDisCRMRecord(dtDisMain, dtDisItem, dtDisStoreAll, out vDisNo, null); s_DIS_NO = vDisNo; txt_DisNo.Text = s_DIS_NO; if (bResult) { ResultMsgLabel.Text = "新增成功"; CurrentPageMode = PageCurrentMode.Readonly; QueryData(); } else ResultMsgLabel.Text = "新增失敗"; } #endregion } else if (CurrentPageMode == PageCurrentMode.Edit) { #region ALOModel.MaintainDisCRMRecord BCO = new ALOModel.MaintainDisCRMRecord(ConnectionDB); bResult = BCO.UpdateDisCRMRecord(dtDisMain, dtDisItem, dtDisItemOld, dtDisStoreAll, dtDisStoreAllOld, s_DIS_NO, null); if (bResult) { ResultMsgLabel.Text = "更新成功"; CurrentPageMode = PageCurrentMode.Readonly; QueryData(); } else ResultMsgLabel.Text = "更新失敗"; #endregion } } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }