protected void grdSupplierCatalog_RowCommand(object sender, GridViewCommandEventArgs e) { Guid IDCatalog = e.CommandArgument.ToString().StringToGuid(); switch (e.CommandName) { case "Delete": try { bool retDel = true; ViewModel.Search SearchCatalog = new ViewModel.Search(); SearchCatalog.Filter = " AND tblCatalog.IDCatalog = '" + IDCatalog + "'"; DataSet dsCatalog = BisCatalog.GetCatalogData(SearchCatalog); try { File.Delete(Server.MapPath("/" + dsCatalog.ReturnDataSetField("PDFUrl"))); } catch { retDel = false; } try { File.Delete(Server.MapPath("/" + dsCatalog.ReturnDataSetField("PicUrl"))); } catch { retDel = false; } if (retDel) { ViewModel.tblCatalog Delete = new ViewModel.tblCatalog(); Delete.IDCatalog = IDCatalog; retDel = BisCatalog.DeleteCatalog(Delete); if (retDel) { FillGrdSupplierCatalog(hfIDLegalUser.Value.StringToGuid()); ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('حذف اطلاعات با موفقیت انجام شد!');", true); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در حذف اطلاعات!');", true); } } catch { ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در برقراری ارتباط با دیتابیس!');", true); } break; } }
protected void btnSaveCatalog_Click(object sender, EventArgs e) { try { if (lblAttachCatalogFileName.Text == "" || lblCatalogPicName.Text == "") { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Error", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> لطفا هم فایل pdf و هم فایل عکس را آپلود کنید!</p>\",title: \"<p style='text-align:right;direction:rtl'>خطا</p>\"});", true); return; } if (txtCatalougeName.Text != "") { ViewModel.tblCatalog NewCatalog = new ViewModel.tblCatalog(); NewCatalog.IDCatalog = Guid.NewGuid(); NewCatalog.Name_En = txtCatalougeName.Text.FixFarsi(); NewCatalog.IDRet = hfIDLegalUser.Value.StringToGuid(); NewCatalog.IDAttachPic = hfIDCatalogPic.Value.StringToGuid(); NewCatalog.IDAttachPDF = hfIDAttachCatalogFile.Value.StringToGuid(); NewCatalog.Sort = txtCatalogSort.Text.StringToInt(); NewCatalog.Status = 1; bool ret = BisCatalog.AddCatalog(NewCatalog); if (ret) { hfIDAttachCatalogFile.Value = hfIDCatalogPic.Value = ""; btnCatalogPic.ImageUrl = "/Admin/images/DefaultImage.png"; FillGrdSupplierCatalog(hfIDLegalUser.Value.StringToGuid()); txtCatalougeName.Text = txtCatalogSort.Text = ""; ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Error", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> ثبت اطلاعات با موفقیت انجام شد</p>\",title: \"<p style='text-align:right;direction:rtl'>ثبت اطلاعات</p>\"});", true); } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Error", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> اشکال در ثبت اطلاعات!</p>\",title: \"<p style='text-align:right;direction:rtl'>خطا</p>\"});", true); } } else { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "Error", " bootbox.alert({message: \"<p dir='rtl' style='color:#004179;font-size:17px;'> نام کاتالوگ را وارد کنید!</p>\",title: \"<p style='text-align:right;direction:rtl'>خطا</p>\"});", true); } } catch { } }