protected void btnSaveSupplierMenuPic_Click(object sender, EventArgs e) { try { ViewModel.tblLegalUser UpdateLegalUser = new ViewModel.tblLegalUser(); //tblSupplier UpdateLegalUser.IDUser = hfIDLegalUser.Value.StringToGuid(); UpdateLegalUser.MenuPicUrl = FileUploadMenuPicUrl.MoveFile(@"..\Picture\Company"); bool result = BisLegalUser.UpdateSupplier(UpdateLegalUser); if (result) { ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "myscr", "$('#ModalSupplierDependency').modal('hide');", true); } else { try { File.Delete(Server.MapPath(@"\" + UpdateLegalUser.MenuPicUrl)); } catch { } 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 { } }
protected void btnDelOldSupplierMenuPic_Click(object sender, EventArgs e) { try { ViewModel.tblLegalUser UpdateLegalUser = new ViewModel.tblLegalUser(); //tblSupplier UpdateLegalUser.IDUser = hfIDLegalUser.Value.StringToGuid(); UpdateLegalUser.MenuPicUrl = ""; bool result = BisLegalUser.UpdateSupplier(UpdateLegalUser); if (result) { try { File.Delete(Server.MapPath(@"\" + imgOldSupplierMenuPic.ImageUrl)); imgOldSupplierMenuPic.Visible = false; } catch { } } 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 { } }
protected void btnAdd_Click(object sender, EventArgs e) { ViewModel.tblLegalUser newLegalUser = new ViewModel.tblLegalUser(); //tblUser newLegalUser.IDCity = CasscadDropDownCountryLegalSupplier.IDCity.StringToGuid(); newLegalUser.UserName = ""; newLegalUser.Password = ""; newLegalUser.Address = ""; newLegalUser.WebSite = txtWebSite.Text.FixFarsi(); newLegalUser.SupplierType = true; newLegalUser.Active = chkActive.Checked; //tblLegalUser newLegalUser.Name_Fa = txtName.Text.FixFarsi(); newLegalUser.Name_En = txtName_En.Text.FixFarsi(); newLegalUser.Description_Fa = txtDescription.Text.FixFarsi(); newLegalUser.Description_En = txtDescription_En.Text.FixFarsi(); newLegalUser.PostalCode = txtPostalCode.Text.FixFarsi(); newLegalUser.RegistrationCode = txtRegistrationCode.Text.FixFarsi(); newLegalUser.NationalCode = txtNationalCode.Text.FixFarsi(); newLegalUser.RegistrationNumber = txtRegistrationNumber.Text.StringToInt(); newLegalUser.IDParentCompany = hfParentCompany.Value.StringToGuid(); newLegalUser.MetaTag = txtMetaTag.Text.FixFarsi(); newLegalUser.Status = 1; switch (hfMode.Value) { case "New": try { if (fulPicUrl.FileName != "") { string url = UploadFile(Server.MapPath("../Picture/Company/"), "Picture/Company/", fulPicUrl); if (url != "") { newLegalUser.PicUrl = url; } else { return; } } else { newLegalUser.PicUrl = ""; } Guid IDUser = Guid.NewGuid(); newLegalUser.IDUser = IDUser; if (checkNameOfCompany(txtName.Text.FixFarsi(), "")) { bool ret = BisLegalUser.AddSupplier(newLegalUser); if (ret) { newFields(); hfMode.Value = "New"; hfIDLegalUser.Value = newLegalUser.IDUser.ToString(); ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اطلاعات ثبت شد - ثبت اطلاعات تماس و پرسنل فراموش نشود!');", true); // -- popupe tel baz mishavad ViewModel.Search LegalUserSearch = new ViewModel.Search(); LegalUserSearch.Filter = " and tblLegalUser.IDUser ='******'"; DataSet ds = BisLegalUser.GetSupplierData(LegalUserSearch); fillGrdLegalUser(); hfIDLegalUser.Value = IDUser.ToString(); hfParentCompany.Value = ""; divTable.Visible = true; divInfo.Visible = false; //-- } else { ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در ثبت اطلاعات!');", true); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('کمپانی با این نام قبلا ثبت شده است!');", true); } } catch { ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در برقراری ارتباط با دیتابیس!');", true); } break; case "Edit": try { if (fulPicUrl.FileName != "") { string url = UploadFile(Server.MapPath("../Picture/Company/"), "Picture/Company/", fulPicUrl); if (url != "") { newLegalUser.PicUrl = url; } else { return; } } else { newLegalUser.PicUrl = Session["OldUrlSupplier"].ToString(); } newLegalUser.IDUser = hfIDLegalUser.Value.StringToGuid(); if (checkNameOfCompany(txtName.Text.FixFarsi(), hfIDLegalUser.Value)) { bool result = BisLegalUser.UpdateSupplier(newLegalUser); if (result) { if (Session["OldUrlSupplier"] != "" && fulPicUrl.FileName != "") { File.Delete(Server.MapPath("../" + Session["OldUrlSupplier"].ToString())); } Session.Remove("OldUrlSupplier"); newFields(); hfParentCompany.Value = ""; hfMode.Value = "New"; ScriptManager.RegisterStartupScript(this, GetType(), "OkMessage", "alert('اطلاعات ویرایش شد!');", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در ویرایش اطلاعات!');", true); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('کمپانی با این نام قبلا ثبت شده است!');", true); } } catch { ScriptManager.RegisterStartupScript(this, GetType(), "ErrorMessage", "alert('اشکال در برقراری ارتباط با دیتابیس!');", true); } break; } }