private void btnSave_Click(object sender, EventArgs e) { #region Validating if (string.IsNullOrEmpty(txtFileName.Text)) { MessageBox.Show(string.Format("Файл сонгогдоогүй байна!")); return; } #endregion int attachtype = ISM.Lib.Static.ToInt(radType.EditValue); _result = AttachUtility.SaveFromFile(_remote, _privupdate, 0, attachtype, txtFileName.Text, txtDesc.Text, _typecode, _typeid); this.DialogResult = System.Windows.Forms.DialogResult.OK; }
public Result ListSave() { Result res = null; List <DynamicParameterItem> items = ucParameterPanel1.ItemGetList(); try { #region Additional Data мэдээллийг хадгалах ArrayList rows = new ArrayList(items.Count); foreach (DynamicParameterItem item in items) { rows.Add(new object[] { Static.ToLong(item.Id), (int)item.ValueType, Static.ToStr(item.Value), item.AttachId }); //switch (item.ValueType) //{ // case DynamicParameterType.Picture: // case DynamicParameterType.File: // break; // default: // rows.Add(new object[] { Static.ToLong(item.Id), (int)item.ValueType, Static.ToStr(item.Value), item.AttachId }); // break; //} } object[] param = new object[] { _tableprefix, _tablerowkey, rows.ToArray() }; res = _remote.Connection.Call(_remote.User.UserNo , CONST_FILEID , 104002 , _tableprivupdate , param); if (res.ResultNo != 0) { goto OnExit; } #endregion #region AttachId дугаараар зургийн мэдээллүүдийг тусад нь илгээж хадгалах rows.Clear(); foreach (DynamicParameterItem item in items) { if (item.Editing) { if (item.ValueType == DynamicParameterType.Picture) { #region Saving Attach Blob res = AttachUtility.SaveImage(_remote, _tableprivupdate, item.AttachId, Static.ToStr(item.Value), item.AttachData, _linktypecode, _linkid); if (res.ResultNo != 0) { goto OnExit; } #endregion #region Collecting New Dynamic record of blob if (item.AttachId == 0) { item.AttachId = (ulong)Static.ToLong(res.Param[0]); rows.Add(new object[] { Static.ToLong(item.Id), (int)item.ValueType, item.Value, item.AttachId }); } #endregion } if (item.ValueType == DynamicParameterType.File) { #region Saving Attach Blob res = AttachUtility.SaveFromFile(_remote, _tableprivupdate, item.AttachId, 1, Static.ToStr(item.Value), _linktypecode, _linkid); if (res.ResultNo != 0) { goto OnExit; } #endregion #region Collecting New Dynamic record of blob if (item.AttachId == 0) { item.AttachId = (ulong)Static.ToLong(res.Param[0]); rows.Add(new object[] { Static.ToLong(item.Id), (int)item.ValueType, item.Value, item.AttachId }); } #endregion } item.Editing = false; } } if (rows.Count > 0) { param = new object[] { _tableprefix, _tablerowkey, rows.ToArray() }; res = _remote.Connection.Call(_remote.User.UserNo , CONST_FILEID , 104002 , _tableprivupdate , param); } #endregion } catch (Exception ex) { res = new Result(9, ex.ToString()); } OnExit: if (res != null && res.ResultNo == 0) { ucParameterPanel1.ItemListSetSaved(); } return(res); }