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; }
private Result ReadBlob(ref byte[] newattachdata) { Result res = new Result(); #region Зураг Browse хийгдэх үед AttachId дугаартай зураг татагдаагүй бол татах DynamicParameterItem pi = ucParameterPanel1.SelectedRow; if (pi.AttachId != 0 && pi.AttachData == null) { res = AttachUtility.GetBytes(_remote, _tableprivselect, pi.AttachId, ref newattachdata); } #endregion return(res); }
void riFileEdit_ButtonClick(object sender, ButtonPressedEventArgs e) { DevExpress.XtraEditors.ButtonEdit edit = sender as DevExpress.XtraEditors.ButtonEdit; DynamicParameterItem pi = _row; if (pi != null) { switch (e.Button.Index) { case 0: string newvalue = null; DialogResult dlg = ShowFileForm((string)pi.Value, ref newvalue); if (dlg == DialogResult.OK) { pi.Editing = true; if (pi.Row != null) { //pi.Row.Properties.Value = newvalue; edit.EditValue = newvalue; pi.Value = newvalue; } AttachUtility.FileRead(newvalue, ref pi.AttachData); } break; case 1: if (pi != null) { string filename = Static.ToStr(pi.Value); GetAttachData(pi); if (!string.IsNullOrEmpty(filename)) { Globals.ShellOpenFile(filename, pi.AttachData); } } break; } } }
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); }