<pre lang="c#">using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Data; using DevExpress.Web.ASPxEditors; using DevExpress.Web.ASPxGridView; using MsgBox; using System.Diagnostics; using Cutech.Express.Entities; using Cutech.Web.Framework; using System.Globalization; using System.Configuration; using System.IO; using System.Drawing.Imaging; using DevExpress.Web.ASPxUploadControl; namespace cuteExpress { public partial class Item_AddNew : ExpressPluginControlBase { Cutech.Express .Entities.Job Job = new Cutech.Express.Entities.Job (); String ItemKey=string.Empty; String UserName = " "; private string m_EventLogSource = "cuteExpressSource"; private string m_EventLog = "cuteExpressSource"; private System.Diagnostics.EventLogPermission eventLogPerm; EventLog evLog = new EventLog(); protected void Page_Load(object sender, EventArgs e) { try { //Check Event Log Source Exists if (!System.Diagnostics.EventLog.SourceExists(m_EventLogSource)) { System.Diagnostics.EventLog.CreateEventSource(m_EventLogSource, m_EventLog); } evLog.Source = m_EventLogSource; evLog.Log = m_EventLog; } catch { } if (Request.QueryString["Key"] != null) { ItemKey = Request.QueryString["Key"].ToString(); Job.JobKey = ItemKey; } UserName = Context.Profile.UserName; //try //{ // try // { // if (!IsPostBack) // { // cmbCategory.SelectedIndex =0; // cmbUnitOfMeasurement .SelectedIndex =16; // DataSet DSItemDetails =new DataSet (); // DSItemDetails = Job.GetItemDetails(ItemKey); // if (DSItemDetails !=null ) // { // if (DSItemDetails.Tables.Count > 0) // { // if (DSItemDetails.Tables[0].Rows.Count > 0) // { // if (DSItemDetails.Tables[0].Rows[0]["ItemName"] != null) // if (DSItemDetails.Tables[0].Rows[0]["ItemName"].ToString() != "") // txtItemName.Text = DSItemDetails.Tables[0].Rows[0].ToString(); // if (DSItemDetails.Tables[0].Rows[0]["ItemSpecification"] != null) // if (DSItemDetails.Tables[0].Rows[0]["ItemSpecification"].ToString() != "") // txtItemSpecification.Text = DSItemDetails.Tables[0].Rows[0].ToString(); // if (DSItemDetails.Tables[0].Rows[0]["Category"] != null) // if (DSItemDetails.Tables[0].Rows[0]["Category"].ToString() != "") // cmbCategory.SelectedIndex = cmbCategory.Items.IndexOfValue(DSItemDetails.Tables[0].Rows[0]["Category"].ToString()); // String AssetType = rblAssetType.SelectedItem.Value.ToString(); // if (AssetType == "Asset" && AssetType == "StoreAsset") // rblAssetType.SelectedIndex = rblAssetType.Items.IndexOfValue(DSItemDetails.Tables[0].Rows[0]["AssetType"].ToString()); // if (DSItemDetails.Tables[0].Rows[0]["UnitOfMeasurement"] != null) // if (DSItemDetails.Tables[0].Rows[0]["UnitOfMeasurement"].ToString() != "") // cmbUnitOfMeasurement.SelectedIndex = cmbUnitOfMeasurement.Items.IndexOfValue(DSItemDetails.Tables[0].Rows[0]["UnitOfMeasurement"].ToString()); // if (DSItemDetails.Tables[0].Rows[0]["Reorderlevel"] != null) // if (DSItemDetails.Tables[0].Rows[0]["Reorderlevel"].ToString() != "") // txtReorderLevel.Text = DSItemDetails.Tables[0].Rows[0].ToString(); // if (DSItemDetails.Tables[0].Rows[0]["LifeSpan"] != null) // if (DSItemDetails.Tables[0].Rows[0]["LifeSpan"].ToString() != "") // txtLifeSpan.Text = DSItemDetails.Tables[0].Rows[0].ToString(); // if (DSItemDetails.Tables[0].Rows[0]["NeedApproval"] != null) // if (DSItemDetails.Tables[0].Rows[0]["NeedApproval"].ToString() != "") // rblNeedApprovalOrNotdx.SelectedIndex = rblNeedApprovalOrNotdx.Items.IndexOfValue(DSItemDetails.Tables[0].Rows[0]["NeedApproval"].ToString()); // if (DSItemDetails.Tables[0].Rows[0]["Description"] != null) // if (DSItemDetails.Tables[0].Rows[0]["Description"].ToString() != "") // MemoDescription.Text = DSItemDetails.Tables[0].Rows[0].ToString(); // } // } // } // } // } // catch (Exception ex) // { // evLog.WriteEntry("Item_AddNew: (!Assign values to control): " + ex.Message.ToString(), EventLogEntryType.Error); // } } protected void btnSubmitdx_Click(object sender, EventArgs e) { try { //Boolean Validation=true; String ItemName=txtItemName.Text.ToString(); String ItemSpecification=txtItemSpecification.Text.ToString (); String Category=cmbCategory.SelectedIndex .ToString(); String AssetType = rblAssetType.SelectedItem.Value.ToString(); String UnitOfMeasurement=cmbUnitOfMeasurement .SelectedIndex .ToString (); Decimal Reorderlevel = 0; Decimal LifeSpan=0; String NeedApproval=rblNeedApprovalOrNotdx.SelectedItem.Value.ToString(); String Description=MemoDescription.Text.ToString (); //if (Validation && ItemName == "") //{ // Validation = false; // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Key", "BaseMessage('Please Enter the Item Name;Error');", true); //} //if (Validation && ItemSpecification == "") //{ // Validation = false; // ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Key", "BaseMessage('Please Enter the Item Specification');", true); //} //if (Request.QueryString["Key"] != null) //{ // ItemKey = Request.QueryString["Key"].ToString(); //} //else // Validation = false; //if (Validation) { Job.ItemInserOrUpdateNewItem(ItemKey, ItemName, ItemSpecification, Category,AssetType, UnitOfMeasurement, Reorderlevel,LifeSpan, NeedApproval, Description); Job.Assignee = Request.QueryString["Assignee"].ToString(); string URL = "http://" + Request.Url.Authority + Request.ApplicationPath + "/ViewJob.aspx?JobKey="; this.CallCloseControlEvent(); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Key", "BaseMessage('Item Creation ERROR ;Error');", true); evLog.WriteEntry("Item_AddNew: (Submit): " + ex.Message.ToString(), EventLogEntryType.Error); } } protected void uplImage_FileUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FileUploadCompleteEventArgs e) { try { String FileName = e.UploadedFile.FileName; String ItemKey = "0"; String ItemName; if (Session["ItemName"] != null && Session["ItemName"] != null) { ItemName = Session["ItemName"].ToString(); String DocPathToSave = ConfigurationManager.AppSettings.Get("AttachmentsPathForItems"); //Directory Creation DocPathToSave += ItemKey + "\\"; if (!Directory.Exists(DocPathToSave)) { Directory.CreateDirectory(DocPathToSave); } DocPathToSave += ItemKey + "_"; String DocumentPathtoSave = DocPathToSave + FileName; //File Creation if (File.Exists(DocumentPathtoSave)) { String[] FiletoSave = FileName.Split('.'); int i; for (i = 0; i < 100; i++) { DocumentPathtoSave = DocPathToSave + FiletoSave[0] + "_REV_" + i + "." + FiletoSave[1]; if (!File.Exists(DocumentPathtoSave)) break; } FileName = FiletoSave[0] + "_REV_" + i + "." + FiletoSave[1]; } e.UploadedFile.SaveAs(DocumentPathtoSave, true); e.CallbackData = e.UploadedFile.FileName; e.IsValid = true; Cutech.Express.Entities.Job Item = new Cutech.Express.Entities.Job(); Item.InsertItemImages(Convert.ToInt64(ItemKey), ItemName, DocumentPathtoSave, FileName); } } catch (Exception ex) { e.ErrorText = ex.Message.ToString(); string str = ex.Message.ToString(); } } protected void btnCanceldx_Click(object sender, EventArgs e) { base.CallCloseControlEvent(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)