//This Method is called when user click on the delete button of the Grid. //Record can be deleted from the Grid through this method. void CtlGrid_btnDeleteClicked(int rowID) { try { //Get the id of the selected row. varID = Convert.ToInt32(objCRMCollection[rowID].ID); //Gets the confirmation from the user for deleting record. MessageBoxResult r = System.Windows.MessageBox.Show("Do You Really Want To Delete This Record ?", "->Delete CRM", MessageBoxButton.YesNo, MessageBoxImage.Question); if (r == MessageBoxResult.Yes) { //Calls the method of ClsCRM class of CRM.Business to delete the record. ClsCRM.Delete(varID); System.Windows.MessageBox.Show("Record Deleted!!", "->CRM Deleted", MessageBoxButton.OK, MessageBoxImage.Information); //Refersh the Grid. funSetGrid(); } } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "CtlGrid_btnDeleteClicked()", "CtlCRM.xaml.cs"); } }
//This method is called when User click on the Save button the tab control. void btnSave_Click(object sender, System.Windows.RoutedEventArgs e) { try { //Create the object of the ClsCRM Class of CRM. ClsCRM d = new ClsCRM(); //Checks wheather textbox containing CRMname is left blank or not. if (txtName.Text.Trim() == "") { System.Windows.MessageBox.Show("CRM Name Can't Be Left Blank", "-> CRM Name", MessageBoxButton.OK, MessageBoxImage.Exclamation); txtName.Focus(); txtName.Text = txtName.Text.Trim(); return; } //Check wheather to edit existing record or add new record. if (varState == 0) { //Add new Record. d.ID = -1; } else { //Edit existing Record. d.ID = varID; } string strZipFile = txtCRMURL.Text; string[] str = strZipFile.Split('\\'); //Set the object of the ClsCRM. d.CRMName = txtName.Text; d.CRMURL = txtCRMURL.Text; d.IsActive = (bool)chkIsActive.IsChecked; //ComboBoxItem l = new ComboBoxItem(); //l = (ComboBoxItem)cmbScriptType.SelectedItem; //d.ScriptTypeID = Convert.ToInt32(l.Tag); d.CreatedBy = VMuktiAPI.VMuktiInfo.CurrentPeer.ID; //Call the save method of ClsCRM class of Vmukti.Business. int gID = d.Save(); //Check wheather record is saved successfully or not. if (gID == 0) { MessageBox.Show("Duplicate Entry For CRM Name Is Not Allowed !!", "-> CRM ", MessageBoxButton.OK, MessageBoxImage.Information); } else { System.Windows.MessageBox.Show("Record Saved Successfully!!"); funSetGrid(); varState = 0; FncClearAll(); } //FncCreateVirtualDirectory(); ////FncCreateFolders(); //#region UploadFile //Uri u = new Uri("ftp://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + "/vmukti/CRMs/"); //WebClient wc = new WebClient(); //wc.UseDefaultCredentials = false; //wc.Credentials = new NetworkCredential("adiance", "adiance"); //try //{ // wc.UploadFile("ftp://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + "/vmukti/CRMs/" + str[str.Length - 1], strZipFile); //} //catch (Exception exp) //{ // MessageBox.Show(exp.Message); //} //#endregion } catch (Exception ex) { VMuktiHelper.ExceptionHandler(ex, "btnSave_Click()", "CtlCRM.xaml.cs"); } }