Esempio n. 1
0
    public void SentMailToSDM(int siteid, int incidentid, int requesterid)
    {
        string strYourSinscerely = Resources.MessageResource.strYourSinscerely.ToString();
        string strContactNumber  = Resources.MessageResource.strContactNumber.ToString();
        int    FlagUser;
        string varRole = Resources.MessageResource.strSDMRole.ToString();
        int    roleid;

        roleid  = objRole.Get_By_RoleName(varRole);
        colUser = objUser.Get_All_By_Role(roleid);
        foreach (UserLogin_mst objusr in colUser)
        {
            FlagUser = objUserToSiteMapping.Get_By_Id(objusr.Userid, siteid);
            if (FlagUser != 0)
            {
                objIncident       = objIncident.Get_By_id(incidentid);
                objSite           = objSite.Get_By_id(objIncident.Siteid);
                objIncidentStates = objIncidentStates.Get_By_id(incidentid);
                objPriority       = objPriority.Get_By_id(objIncidentStates.Priorityid);

                UserLogin_mst obju   = new UserLogin_mst();
                UserLogin_mst objReq = new UserLogin_mst();
                obju      = obju.Get_By_id(objUserToSiteMapping.Userid);
                objC_info = objC_info.Get_By_id(objusr.Userid);
                objReq    = objReq.Get_By_id(requesterid);
                ContactInfo_mst objReqContInfo = new ContactInfo_mst();
                objReqContInfo = objReqContInfo.Get_By_id(objReq.Userid);

                obj.From       = Resources.MessageResource.strAdminEmail.ToString();
                obj.To         = objC_info.Emailid;
                obj.Subject    = "High Priority Call. Ticket Id: " + incidentid;
                obj.Body       = "Dear Sir/Madam,<br/>High Priority Call has been logged, please find below the Complaint  details .<br/><br/><b>Complaints Details : </b> <br/><br/><b>Ticket Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + incidentid + "<br/><b>Title of Call&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objIncident.Title + " <br/><b>Site&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objSite.Sitename + "<br/><b>Logged Date & Time&nbsp;&nbsp&nbsp;&nbsp;&nbsp;:</b>" + objIncident.Createdatetime + "<br/><b>Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objIncident.Description + "<br/><b>Priority&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> " + objPriority.Name + "<br/><b>UserName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objReq.Username + "<br/><b>Mail Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objReqContInfo.Emailid + "<br/><br/> <b>This is an auto generated mail. Please do not reply.</b><br/><br/><b>Yours sincerely,</b><br/> <b>" + strYourSinscerely + "</b>";
                obj.SmtpServer = Resources.MessageResource.strSMTPServer.ToString();
                obj.SentMail();
            }
        }
    }
Esempio n. 2
0
    protected void btnRoleadd_Click(object sender, EventArgs e)
    {
        int rolename;

        rolename = RoleObj.Get_By_RoleName(txtRoleName.Text.ToString());
        if (rolename == 0)
        {
            RoleObj.Rolename    = txtRoleName.Text.ToString();
            RoleObj.Description = txtRoleDesc.Text.ToString();
            RoleObj.Insert();
            BindGrid();
            lblerrmsg.Text = Resources.MessageResource.erradd.ToString();
        }
        else
        {
            lblerrmsg.Text = Resources.MessageResource.errRoleExist;
        }

        Dispose();
    }
Esempio n. 3
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        try
        {
            string varObjDomainName;
            string Username = "";
            string Password = "";
            Username = txtUserName.Text;
            Password = txtPassword.Text;
            //Assign domain name to variable varDomainName and varObjDomainName
            varObjDomainName = txtDomainName.Text.ToString().Trim();
            //Create object de of Directory Entry Class
            //DirectoryEntry myDirectoryEntry = new DirectoryEntry(String.Format("LDAP://{0}/ou=Mahim;dc=HTmedia;dc=net", varObjDomainName));
            //DirectoryEntry myDirectoryEntry = new DirectoryEntry(String.Format("LDAP://{0}/ou='"+TxtOU1.Text+"'/ou='"+TxtOU2.Text+"';dc=HTmedia;dc=net", varObjDomainName));
            //DirectoryEntry myDirectoryEntry = new DirectoryEntry("LDAP://" + varObjDomainName);
            DirectoryEntry myDirectoryEntry = new DirectoryEntry(String.Format("LDAP://{0}", varObjDomainName));
            myDirectoryEntry.Username = Username;
            myDirectoryEntry.Password = Password;
            //  DirectoryEntry myDirectoryEntry = new DirectoryEntry(String.Format("LDAP://{0}/ou=Sur;ou=apc;dc=Terex;dc=local",varObjDomainName));
            // Create object mySearcher of DirectorySearcher Class
            DirectorySearcher mySearcher = new DirectorySearcher(myDirectoryEntry);
            mySearcher.SearchScope = SearchScope.Subtree;
            //mySearcher.Filter = "(&(objectClass=user)(objectCategory=person))";
            mySearcher.Filter = ("(objectCategory=person)");
            // mySearcher.Filter = "(objectClass=person)";
            // Create Local Variable OrganizationId to get organization id
            int OrganizationId;
            // Call Function Get_Organization() to get the object of Organization_mst
            objOrg = objOrg.Get_Organization();
            // Assign Organization id to variable OrganizationId
            OrganizationId = objOrg.Orgid;
            //  Create Localvariable varRoleName get role form Gloabl Resource File MessageResource and later assign to user when user import to database
            string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
            //  Assign roleid to local variable varRoleid by calling function Get_By_RoleName
            int varRoleid = objRoleInfo.Get_By_RoleName(varRoleName);
            //  Create Local Variable  FlagSave and FlagUserExist to check status of save and user Exist
            int FlagSave      = 0;
            int FlagUserExist = 0;
            int count         = 0;
            int count1        = 0;
            foreach (SearchResult result in mySearcher.FindAll())
            {
                count++;
                count1 = result.Properties.Count;
                try
                {
                    //if (!String.IsNullOrEmpty(result.Properties["Mail"][0].ToString())
                    //    && System.Text.RegularExpressions.Regex.IsMatch(result.Properties["DisplayName"][0].ToString(), " |admin|test|service|system|[$]", System.Text.RegularExpressions.RegexOptions.IgnoreCase)                                         )
                    //{
                    string SAMAccountName = Convert.ToBoolean(result.Properties["sAMAccountName"].Count > 0) ? result.Properties["sAMAccountName"][0].ToString() : "";
                    string DisplayName    = Convert.ToBoolean(result.Properties["displayName"].Count > 0) ? result.Properties["displayName"][0].ToString() : "";
                    string mail           = Convert.ToBoolean(result.Properties["mail"].Count > 0) ? result.Properties["mail"][0].ToString() : "";
                    string company        = Convert.ToBoolean(result.Properties["company"].Count > 0) ? result.Properties["company"][0].ToString() : "";
                    string Site           = Convert.ToBoolean(result.Properties["L"].Count > 0) ? result.Properties["L"][0].ToString() : "";
                    // Create loccal variable FlagStatus,varUsername
                    int    FlagStatus;
                    string varUserName;
                    string varCompany;
                    string varSite;
                    // varCompany = objUserLogin.Company;
                    varCompany = company;
                    //varSite = objUserLogin.Site;
                    varSite = Site;
                    // Assign username to variable varUserName
                    varUserName = SAMAccountName.ToString().Trim();

                    //  Declare local Variable Flag to Check Status User Exist in databse
                    FlagStatus = objUserLogin.Get_By_UserName(varUserName, OrganizationId);
                    // If variable FlagStatus is zero  then User does not exist in database
                    if (FlagStatus == 0)
                    {
                        // Create local variable FlagInsertStatus to check insert status of function
                        int FlagInsertStatus;
                        // Create local variable VarPassword to get passowrd which is generated using function GeneratePassword()
                        string VarPassword = Membership.GeneratePassword(8, 2);
                        objUserLogin.ADEnable       = true;
                        objUserLogin.Createdatetime = DateTime.Now.ToString();
                        objUserLogin.Enable         = true;
                        objUserLogin.Orgid          = OrganizationId;
                        objUserLogin.Password       = VarPassword;
                        objUserLogin.Username       = varUserName;
                        objUserLogin.Roleid         = varRoleid;
                        objUserLogin.DomainName     = varObjDomainName;
                        objUserLogin.Company        = varCompany;
                        objUserLogin.City           = varSite;
                        // Call function objUserLogin.Insert to insert user data to UserLogin_mst table and assign  status in FlagInsertStatus variable

                        FlagInsertStatus = objUserLogin.Insert();

                        // If FlagInsertStatus is 1 then Insert operation is Success
                        if (FlagInsertStatus == 1)
                        {
                            // Create local variable UserId,varFirstName,varLastName,varFullname,arraycount,FlagContactInfo
                            int      UserId;
                            string   varFirstName = "";
                            string   varLastName  = "";
                            string[] varFullName;
                            int      arraycount;
                            int      FlagContactInfo;
                            // Assign Display Name to variable varFullname to get firstname and last name by calling split function
                            varFullName = DisplayName.Split(' ');
                            //Assign  the number of variables in array varFullName to arraycount  ,to check how many elements in varFullName array
                            arraycount   = varFullName.Count();
                            varFirstName = varFullName[0].ToString().Trim();
                            // if arraycount is greater than one,than there is more than one values in array varFullName ie it also contain lastname value
                            if (arraycount > 1)
                            {
                                // lastname assign to variable varLastName
                                varLastName = varFullName[1].ToString().Trim();
                            }
                            // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                            UserId = objUserLogin.Get_By_UserName(varUserName.ToString().Trim(), OrganizationId);
                            objContactInfo.Userid = UserId;
                            // objContactInfo.Deptname = department;
                            objContactInfo.Emailid   = mail;
                            objContactInfo.Firstname = varFirstName;
                            objContactInfo.Lastname  = varLastName;
                            // Local variable FlagContactInfo contain the status of Insert function objContactInfo.Insert()
                            FlagContactInfo = objContactInfo.Insert();
                            // if FlagContactInfo is zero,means error occured and delete the user record by calling objUserLogin.Delete function
                            if (FlagContactInfo == 0)
                            {
                                objUserLogin.Delete(UserId);
                            }
                            else
                            {
                                // Assign variable FlagSave =1 to show record added successfully in database
                                FlagSave = 1;
                                string varEmail;
                                if (mail == "")
                                {
                                    varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                                }
                                else
                                {
                                    varEmail = mail.ToString().Trim();
                                }
                                //FlagSave = 1;
                                //string varCompany;
                                //if (company == "")
                                //{
                                //    varCompany = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                                //}
                                //else { varCompany = company.ToString().Trim(); }

                                //FlagSave = 1;
                                //string varSite;
                                //if (varSite == "")
                                //{
                                //    varSite = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                                //}
                                //else { varSIte = site.ToString().Trim(); }
                                // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                                MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                                // Call Membership.CreateUser function to create Membership user
                                Membership.CreateUser(varUserName.ToString().Trim(), VarPassword.ToString().Trim(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                                // Call Roles.AddUserToRole Function to Add User To Role
                                Roles.AddUserToRole(varUserName.ToString().Trim(), varRoleName);
                            }
                        }
                    }
                    else
                    {
                        //update city and company if user already exist
                        objUserLogin.UpdateCityCompany(varUserName, varCompany, varSite);
                        //end
                        FlagUserExist = 1;
                    }
                }
                //}
                catch
                { }
            }
            if (FlagSave == 1)
            {
                // Show Messages from Resources.MessageResource resouces file located in App_GlobalResource Dir
                lblErrMsg.Text = Resources.MessageResource.errDataSave.ToString();
            }
            else
            {
                if (FlagUserExist == 1)
                {
                    lblErrMsg.Text = Resources.MessageResource.errUserDomainExist.ToString();
                }
                else
                {
                    lblErrMsg.Text = Resources.MessageResource.errOccured.ToString();
                }
            }
        }
        catch (Exception ex)
        {
            // Show Messages from Resources.MessageResource resouces file located in App_GlobalResource Dir
            lblErrMsg.Text = Resources.MessageResource.errDomainName.ToString();
        }
        Dispose();
    }
Esempio n. 4
0
    protected void buttonadd_click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            #region Find Userid of User who is Requesting to log a call

            #region If User Already Exist
            if (ViewState["UserCreate"].ToString() == "Exist")
            {
                objOrganization = objOrganization.Get_Organization();
                ObjUserLogin    = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                if (ObjUserLogin.Userid != 0)
                {
                    requesterid = ObjUserLogin.Userid;
                }
            }
            #endregion
            #region If New User is to be Created
            else if (ViewState["UserCreate"].ToString() == "create")
            {
                string varEmail    = "";
                string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
                if (txtEmail.Text == "")
                {
                    varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                }
                else
                {
                    varEmail = txtEmail.Text;
                }


                int roleid = objRole.Get_By_RoleName(varRoleName);
                int status;
                objOrganization = objOrganization.Get_Organization();

                objuser.Username       = txtUsername.Text.ToString();
                objuser.Password       = Resources.MessageResource.strDefaultPassword.ToString();
                objuser.Roleid         = roleid;
                objuser.Orgid          = objOrganization.Orgid;
                objuser.ADEnable       = false;
                objuser.Enable         = true;
                objuser.Createdatetime = DateTime.Now.ToString();
                status = objuser.Insert();
                if (status == 1)
                {
                    // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                    MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                    // Call Membership.CreateUser function to create Membership user
                    Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                    // Call Roles.AddUserToRole Function to Add User To Role
                    Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName);
                    // Declare Local Variable Userid to fetch userid of newly created user

                    // Create Object objUserLogin of UserLogin_mst()Class
                    objuser = new UserLogin_mst();
                    // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                    requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                    // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured

                    ContactInfo_mst objContactInfo = new ContactInfo_mst();
                    objContactInfo.Userid    = requesterid;
                    objContactInfo.Emailid   = varEmail;
                    objContactInfo.Firstname = txtUsername.Text.ToString();
                    objContactInfo.Lastname  = txtUsername.Text.ToString();
                    objContactInfo.Insert();
                }
            }
            #endregion
            #region If User is Not to be Created
            else if (ViewState["UserCreate"].ToString() == "notcreate")
            {
                // FlagUserStatus = false;
            }
            #endregion

            #endregion
            ObjChange.Active = true;

            ObjChange.Statusid      = Convert.ToInt32(drpStatus.SelectedValue);
            ObjChange.Categoryid    = Convert.ToInt32(drpCategory.SelectedValue);
            ObjChange.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue);
            // ObjChange.Technician =Convert.ToInt32(drpTechnician.SelectedValue);
            ObjChange.Title          = txtTitle.Text;
            ObjChange.Description    = txtDescription.Text;
            ObjChange.Createdtime    = DateTime.Now.ToString();
            ObjChange.Changetype     = Convert.ToInt32(drpchangetype.SelectedValue);
            ObjChange.Approvalstatus = "Send For Approval";
            MembershipUser user     = Membership.GetUser();
            string         username = user.UserName.ToString();
            objOrganization = objOrganization.Get_Organization();
            ObjUserLogin    = ObjUserLogin.Get_UserLogin_By_UserName(username, objOrganization.Orgid);
            int userid = Convert.ToInt32(ObjUserLogin.Userid);
            ObjChange.CreatedByID = userid;
            ObjUserLogin          = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text, objOrganization.Orgid);
            ObjChange.Requestedby = ObjUserLogin.Userid;
            // ObjChange.Priority = Convert.ToInt32(drpPriority.SelectedValue);
            ObjChange.Insert();
            int changeid = ObjChange.Get_Current_Changeid();
            for (int i = ListAsset.Items.Count - 1; i >= 0; i--)
            {
                if (ListAsset.Items[i].Selected == true)
                {
                    Objincludeaasetchange.Assetid  = Convert.ToInt32(ListAsset.Items[i].Value);
                    Objincludeaasetchange.Changeid = changeid;
                    Objincludeaasetchange.Insert();
                }
            }
            ObjChangeHistory.Changeid = changeid;
            // ObjChangeHistory.Description = "create";
            ObjChangeHistory.Operation        = "create";
            ObjChangeHistory.Operationownerid = ObjUserLogin.Userid;
            ObjChangeHistory.Insert();
            int changetype = Convert.ToInt32(drpchangetype.SelectedValue);

            objSentEmailToChange.SentMailToChangeCommittee(changeid, changetype);

            Response.Redirect("~/Change/EditChange.aspx?" + changeid + " ");
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
Esempio n. 5
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {//Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            bool FlagUserStatus = true;
            #region Find Userid of User who is Requesting to log a call

            #region If User Already Exist
            if (ViewState["UserCreate"].ToString() == "Exist")
            {
                objOrganization = objOrganization.Get_Organization();
                ObjUserLogin    = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                if (ObjUserLogin.Userid != 0)
                {
                    requesterid = ObjUserLogin.Userid;
                }
            }
            #endregion
            #region If New User is to be Created
            else if (ViewState["UserCreate"].ToString() == "create")
            {
                string varEmail    = "";
                string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
                if (txtEmail.Text == "")
                {
                    varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                }
                else
                {
                    varEmail = txtEmail.Text;
                }


                int roleid = objRole.Get_By_RoleName(varRoleName);
                int status;
                objOrganization = objOrganization.Get_Organization();

                objuser.Username       = txtUsername.Text.ToString();
                objuser.Password       = Resources.MessageResource.strDefaultPassword.ToString();
                objuser.Roleid         = roleid;
                objuser.Orgid          = objOrganization.Orgid;
                objuser.ADEnable       = false;
                objuser.Enable         = true;
                objuser.Createdatetime = DateTime.Now.ToString();
                status = objuser.Insert();
                if (status == 1)
                {
                    // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                    MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                    // Call Membership.CreateUser function to create Membership user
                    Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                    // Call Roles.AddUserToRole Function to Add User To Role
                    Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName);
                    // Declare Local Variable Userid to fetch userid of newly created user

                    // Create Object objUserLogin of UserLogin_mst()Class
                    objuser = new UserLogin_mst();
                    // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                    requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                    // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured

                    ContactInfo_mst objContactInfo = new ContactInfo_mst();
                    objContactInfo.Userid    = requesterid;
                    objContactInfo.Emailid   = varEmail;
                    objContactInfo.Firstname = txtUsername.Text.ToString();
                    objContactInfo.Lastname  = txtUsername.Text.ToString();
                    objContactInfo.Insert();
                }
            }
            #endregion
            #region If User is Not to be Created
            else if (ViewState["UserCreate"].ToString() == "notcreate")
            {
                FlagUserStatus = false;
            }
            #endregion

            #endregion

            MembershipUser User = Membership.GetUser();
            string         userName;
            userName = User.UserName.ToString();
            if (FlagUserStatus == true)
            {
                objOrganization          = objOrganization.Get_Organization();
                objuser                  = objuser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
                ObjProblem.CreatedByid   = objuser.Userid;
                ObjProblem.Requesterid   = requesterid;
                ObjProblem.Categoryid    = Convert.ToInt32(drpCategory.SelectedValue);
                ObjProblem.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue);

                ObjProblem.Priorityid   = Convert.ToInt32(drpPriority.SelectedValue);
                ObjProblem.Statusid     = Convert.ToInt32(drpStatus.SelectedValue);
                ObjProblem.Technicianid = Convert.ToInt32(drpTechnician.SelectedValue);
                ObjProblem.title        = txtTitle.Text;
                ObjProblem.Description  = txtDescription.Text;
                if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                {
                    ObjProblem.AssginedTime = DateTime.Now.ToString();
                }

                ObjProblem.Insert();
                int problemid = ObjProblem.Get_Current_Problemid();

                ObjProblemHistory.Operationtime    = DateTime.Now.ToString();
                ObjProblemHistory.Problemid        = problemid;
                ObjProblemHistory.Operation        = "create";
                ObjProblemHistory.Operationownerid = objuser.Userid;
                if (Session["IncidentToProblem"] != null)
                {
                    int incidentid = Convert.ToInt32(Session["IncidentToProblem"].ToString());
                    Incident_To_Problem objIncToprob = new Incident_To_Problem();
                    objIncToprob.Incidentid = incidentid;
                    objIncToprob.Problemid  = problemid;
                    objIncToprob.Insert();
                }
                if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                {
                    objSentMailToUser.SentMailToTechnicianForProblemCall(problemid, Convert.ToInt32(drpTechnician.SelectedValue));
                }

                ObjProblemHistory.Insert();
                //ResetControls();

                string myScript;
                myScript = "<script language=javascript>javascript:window.close();</script>";
                Page.RegisterClientScriptBlock("MyScript", myScript);
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
Esempio n. 6
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        #region Declaration of Local Variables
        int    siteid, priorityid;
        int    SLAid       = 0;
        int    createdbyid = 0;
        int    requesterid = 0;
        int    FlagInsert;
        int    requesttypeid;
        string userName;
        bool   FlagUserStatus;
        FlagUserStatus = true;
        FlagInsert     = 0;
        #endregion
        #region Fetch Current User
        MembershipUser User = Membership.GetUser();
        userName = User.UserName.ToString();
        #endregion
        #region Get Current Site and Priority id
        siteid     = Convert.ToInt16(drpSite.SelectedValue);
        priorityid = Convert.ToInt16(drpPriority.SelectedValue);
        #endregion
        #region Get SLAid on the basis of siteid and Priority id

        if (siteid != 0 && priorityid != 0)
        {
            SLAid         = objIncident.Get_By_SLAid(siteid, priorityid);
            requesttypeid = Convert.ToInt16(Resources.MessageResource.strRequestTypeId.ToString());
            if (requesttypeid == Convert.ToInt16(drpRequestType.SelectedValue))
            {
                SLAid = 0;
            }
        }
        #endregion
        if (userName != "")
        {
            #region Find Userid of User who Created this Request
            objOrganization = objOrganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
            if (objUser.Userid != 0)
            {
                createdbyid = objUser.Userid;
            }

            #endregion
            #region Find Userid of User who is Requesting to log a call
            #region If User Already Exist
            if (Session["UserCreate"].ToString() == "Exist")
            {
                objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                if (objUser.Userid != 0)
                {
                    requesterid = objUser.Userid;
                }
            }
            #endregion
            #region If New User is to be Created
            else if (Session["UserCreate"].ToString() == "create")
            {
                string varEmail    = "";
                string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
                if (txtEmail.Text == "")
                {
                    varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                }
                else
                {
                    varEmail = txtEmail.Text;
                }

                int roleid = objRole.Get_By_RoleName(varRoleName);
                int status;
                objOrganization = objOrganization.Get_Organization();
                UserLogin_mst objUserLogin = new UserLogin_mst();
                objUserLogin.Username       = txtUsername.Text.Trim().ToString();
                objUserLogin.Password       = Resources.MessageResource.strDefaultPassword.ToString();
                objUserLogin.Roleid         = roleid;
                objUserLogin.Orgid          = objOrganization.Orgid;
                objUserLogin.ADEnable       = false;
                objUserLogin.Enable         = true;
                objUserLogin.Createdatetime = DateTime.Now.ToString();
                status = objUserLogin.Insert();
                if (status == 1)
                {
                    // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                    MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                    // Call Membership.CreateUser function to create Membership user
                    Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                    // Call Roles.AddUserToRole Function to Add User To Role
                    Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName);
                    // Declare Local Variable Userid to fetch userid of newly created user

                    // Create Object objUserLogin of UserLogin_mst()Class
                    objUserLogin = new UserLogin_mst();
                    // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                    requesterid = objUserLogin.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                    // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured

                    ContactInfo_mst objContactInfo = new ContactInfo_mst();
                    objContactInfo.Userid    = requesterid;
                    objContactInfo.Emailid   = varEmail;
                    objContactInfo.Firstname = txtUsername.Text.ToString();
                    objContactInfo.Lastname  = txtUsername.Text.ToString();
                    objContactInfo.Insert();
                }
            }
            #endregion
            #region If User is Not to be Created
            else if (Session["UserCreate"].ToString() == "notcreate")
            {
                FlagUserStatus = false;
            }
            #endregion

            #endregion
        }

        objIncident.Title = txtTitle.Text.Trim();
        //objIncident.Title = drpTitle.SelectedItem.Text;
        objIncident.Slaid          = SLAid;
        objIncident.Createdbyid    = createdbyid;
        objIncident.Requesterid    = requesterid;
        objIncident.Siteid         = siteid;
        objIncident.Description    = txtDescription.Text.ToString().Trim();
        objIncident.Deptid         = Convert.ToInt16(drpDepartment.SelectedValue);
        objIncident.Createdatetime = DateTime.Now.ToString();
        IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true);
        String          datetime = txtReportedDate.Text.Trim();

        DateTime dt = DateTime.Parse(datetime, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
        //changed by prachi

        //objIncident.Reporteddatetime = dt.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
        DateTime dtNowForTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(drpTimeHours.SelectedItem.Text), Convert.ToInt32(drpTimeMin.SelectedItem.Text), 0);
        //end prachi

        objIncident.Reporteddatetime = dt.ToShortDateString() + " " + dtNowForTime.ToShortTimeString();
        objIncident.Modeid           = Convert.ToInt16(drpMode.SelectedValue);
        //objIncident.ExternalTicketNo = txtExternalTicket.Text.ToString().Trim();
        if (FlagUserStatus == true)
        {
            FlagInsert = objIncident.Insert();
            #region Save Assetid and incident id in incidenttoassetmaaping
            // Get Asset and Incident Id for incidenttoassetmaaping
            objOrganization = objOrganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(txtUsername.Text.Trim().ToString().Trim(), objOrganization.Orgid);
            int userid    = Convert.ToInt16(objUser.Userid);
            int tempuser1 = Convert.ToInt16(Session["tempuser1"]);
            if (tempuser1 == 1)
            {
                assetid = Convert.ToInt16(Session["assetid"]);
            }
            else
            {
                assetid = Convert.ToInt16(objusertoasset.Get_AssetId_By_UserId(userid));
            }
            int incid = Convert.ToInt16(objIncident.Get_TopIncidentId());
            //if (txtassignasset.Text != "")
            {
                //assetid = Convert.ToInt16(txtassignasset.Text);
                if (assetid != 0)
                {
                    objincidenttoasset.Insert(incid, assetid);
                    objusertoasset.Insert(userid, assetid);
                    Session.Abandon();
                }
            }

            #endregion
        }

        if (FlagInsert == 1)
        {
            int FlagIncdStatesInsert;
            int incidentid;
            incidentid = objIncident.Get_Current_Incidentid();
            objIncidentStates.Incidentid    = incidentid;
            objIncidentStates.Priorityid    = Convert.ToInt16(drpPriority.SelectedValue);
            objIncidentStates.Categoryid    = Convert.ToInt16(drpCategory.SelectedValue);
            objIncidentStates.Statusid      = Convert.ToInt16(drpStatus.SelectedValue);
            objIncidentStates.Subcategoryid = Convert.ToInt16(drpSubcategory.SelectedValue);
            objIncidentStates.Technicianid  = Convert.ToInt16(drpTechnician.SelectedValue);
            if (Convert.ToInt16(drpTechnician.SelectedValue) != 0)
            {
                objIncidentStates.AssignedTime = DateTime.Now.ToString();
            }
            objIncidentStates.Requesttypeid = Convert.ToInt16(drpRequestType.SelectedValue);
            FlagIncdStatesInsert            = objIncidentStates.Insert();
            if (FlagIncdStatesInsert == 1)
            {
                objIncidentHistory.Incidentid       = incidentid;
                objIncidentHistory.Operation        = "create";
                objIncidentHistory.Operationownerid = createdbyid;
                objIncidentHistory.Insert();

                objSentmailtoUser.SentmailUser(requesterid, incidentid, "open");
                if (Convert.ToInt16(drpTechnician.SelectedValue) != 0)
                {
                    objSentmailtoUser.SentmailTechnician(Convert.ToInt16(drpTechnician.SelectedValue), incidentid);
                }
                ////////////////////Added by lalit 28nov to /////////////////////////////////////////////////////
                if (Session["id"] != null)
                {
                    int           id = Convert.ToInt32(Session["id"].ToString());
                    SqlConnection con;
                    SqlCommand    cmd;
                    string        connection = ConfigurationManager.ConnectionStrings["CSM_DB"].ConnectionString;
                    con = new SqlConnection(connection);
                    cmd = new SqlCommand();
                    con.Open();
                    cmd.Connection  = con;
                    cmd.CommandText = "update storemail set IsActive=2 where id='" + id + "'";
                    cmd.ExecuteNonQuery();
                }

                Response.Redirect("~/Incident/IncidentRequestUpdate.aspx?" + incidentid + "");
            }
        }
    }
    protected void buttonadd_click(object sender, EventArgs e)
    {
        #region Find Userid of User who is Requesting to log a call

        #region If User Already Exist
        if (ViewState["UserCreate"].ToString() == "Exist")
        {
            objOrganization = objOrganization.Get_Organization();
            ObjUserLogin    = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
            if (ObjUserLogin.Userid != 0)
            {
                requesterid = ObjUserLogin.Userid;
            }
        }
        #endregion
        #region If New User is to be Created
        else if (ViewState["UserCreate"].ToString() == "create")
        {
            string varEmail    = "";
            string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
            if (txtEmail.Text == "")
            {
                varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
            }
            else
            {
                varEmail = txtEmail.Text;
            }


            int roleid = objRole.Get_By_RoleName(varRoleName);
            int status;
            objOrganization = objOrganization.Get_Organization();

            objuser.Username       = txtUsername.Text.ToString();
            objuser.Password       = Resources.MessageResource.strDefaultPassword.ToString();
            objuser.Roleid         = roleid;
            objuser.Orgid          = objOrganization.Orgid;
            objuser.ADEnable       = false;
            objuser.Enable         = true;
            objuser.Createdatetime = DateTime.Now.ToString();
            status = objuser.Insert();
            if (status == 1)
            {
                // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                // Call Membership.CreateUser function to create Membership user
                Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                // Call Roles.AddUserToRole Function to Add User To Role
                Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName);
                // Declare Local Variable Userid to fetch userid of newly created user

                // Create Object objUserLogin of UserLogin_mst()Class
                objuser = new UserLogin_mst();
                // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured

                ContactInfo_mst objContactInfo = new ContactInfo_mst();
                objContactInfo.Userid    = requesterid;
                objContactInfo.Emailid   = varEmail;
                objContactInfo.Firstname = txtUsername.Text.ToString();
                objContactInfo.Lastname  = txtUsername.Text.ToString();
                objContactInfo.Insert();
            }
        }
        #endregion
        #region If User is Not to be Created
        else if (ViewState["UserCreate"].ToString() == "notcreate")
        {
            // FlagUserStatus = false;
        }
        #endregion

        #endregion
        ObjChange.Active = true;

        ObjChange.Statusid       = Convert.ToInt16(drpStatus.SelectedValue);
        ObjChange.Categoryid     = Convert.ToInt16(drpCategory.SelectedValue);
        ObjChange.Subcategoryid  = Convert.ToInt16(drpSubcategory.SelectedValue);
        ObjChange.Technician     = Convert.ToInt16(drpTechnician.SelectedValue);
        ObjChange.Title          = txtTitle.Text;
        ObjChange.Description    = txtDescription.Text;
        ObjChange.Createdtime    = DateTime.Now.ToString();
        ObjChange.Changetype     = Convert.ToInt16(drpchangetype.SelectedValue);
        ObjChange.Approvalstatus = "Send For Approval";
        MembershipUser user     = Membership.GetUser();
        string         username = user.UserName.ToString();
        objOrganization = objOrganization.Get_Organization();
        ObjUserLogin    = ObjUserLogin.Get_UserLogin_By_UserName(username, objOrganization.Orgid);
        int userid = Convert.ToInt16(ObjUserLogin.Userid);
        ObjChange.CreatedByID = userid;
        ObjUserLogin          = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text, objOrganization.Orgid);
        ObjChange.Requestedby = ObjUserLogin.Userid;
        ObjChange.Priority    = Convert.ToInt16(drpPriority.SelectedValue);
        ObjChange.Insert();
        int changeid = ObjChange.Get_Current_Changeid();
        for (int i = ListAsset.Items.Count - 1; i >= 0; i--)
        {
            if (ListAsset.Items[i].Selected == true)
            {
                Objincludeaasetchange.Assetid  = Convert.ToInt16(ListAsset.Items[i].Value);
                Objincludeaasetchange.Changeid = changeid;
                Objincludeaasetchange.Insert();
            }
        }
        ObjProblemToChange.Changeid  = changeid;
        ObjProblemToChange.Problemid = Convert.ToInt16(Session["problemid"]);
        ObjProblemToChange.Insert();
        ScriptManager.RegisterStartupScript(this, this.GetType(), "Close()", "Close();", true);
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            #region Declaration of Local Variables
            int    siteid, priorityid;
            int    SLAid       = 0;
            int    createdbyid = 0;
            int    requesterid = 0;
            int    FlagInsert;
            int    requesttypeid;
            string userName;
            bool   FlagUserStatus;
            FlagUserStatus = true;
            FlagInsert     = 0;
            #endregion

            #region Fetch Current User
            MembershipUser User = Membership.GetUser();
            userName = User.UserName.ToString();
            #endregion
            #region Get Current Site and Priority id
            siteid     = Convert.ToInt32(drpSite.SelectedValue);
            priorityid = Convert.ToInt32(drpPriority.SelectedValue);
            #endregion


            #region Get SLAid on the basis of siteid and Priority id

            if (siteid != 0 && priorityid != 0)
            {
                SLAid         = objIncident.Get_By_SLAid(siteid, priorityid);
                requesttypeid = Convert.ToInt32(Resources.MessageResource.strRequestTypeId.ToString());
                if (requesttypeid == Convert.ToInt32(drpRequestType.SelectedValue))
                {
                    SLAid = 0;
                }
            }
            #endregion
            if (userName != "")
            {
                #region Find Userid of User who Created this Request
                objOrganization = objOrganization.Get_Organization();
                objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
                if (objUser.Userid != 0)
                {
                    createdbyid = objUser.Userid;
                }

                #endregion



                #region Find Userid of User who is Requesting to log a call

                #region If User Already Exist
                if (Session["UserCreate"].ToString() == "Exist")
                {
                    objUser = objUser.Get_UserLogin_By_UserName_Ex(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                    if (objUser.Userid != 0)
                    {
                        requesterid = objUser.Userid;
                    }
                }
                #endregion
                #region If New User is to be Created
                else if (Session["UserCreate"].ToString() == "create")
                {
                    string varEmail    = "";
                    string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
                    if (txtEmail.Text == "")
                    {
                        varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                    }
                    else
                    {
                        varEmail = txtEmail.Text;
                    }


                    int roleid = objRole.Get_By_RoleName(varRoleName);
                    int status;
                    objOrganization = objOrganization.Get_Organization();
                    UserLogin_mst objUserLogin = new UserLogin_mst();
                    objUserLogin.Username       = txtUsername.Text.ToString();
                    objUserLogin.Password       = Resources.MessageResource.strDefaultPassword.ToString();
                    objUserLogin.Roleid         = roleid;
                    objUserLogin.Orgid          = objOrganization.Orgid;
                    objUserLogin.ADEnable       = false;
                    objUserLogin.Enable         = true;
                    objUserLogin.Createdatetime = DateTime.Now.ToString();
                    status = objUserLogin.Insert();
                    if (status == 1)
                    {
                        // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                        MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                        // Call Membership.CreateUser function to create Membership user
                        Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                        // Call Roles.AddUserToRole Function to Add User To Role
                        Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName);
                        // Declare Local Variable Userid to fetch userid of newly created user

                        // Create Object objUserLogin of UserLogin_mst()Class
                        objUserLogin = new UserLogin_mst();
                        // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                        requesterid = objUserLogin.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                        // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured

                        ContactInfo_mst objContactInfo = new ContactInfo_mst();
                        objContactInfo.Userid    = requesterid;
                        objContactInfo.Emailid   = varEmail;
                        objContactInfo.Firstname = txtUsername.Text.ToString();
                        objContactInfo.Lastname  = txtUsername.Text.ToString();
                        objContactInfo.Insert();
                        /// added by vishal 18-05-2012
                        Session["UserCreate"] = "";
                    }
                }
                #endregion
                #region If User is Not to be Created
                else if (Session["UserCreate"].ToString() == "notcreate")
                {
                    FlagUserStatus = false;
                }
                #endregion

                #endregion
            }

            objIncident.Title = txtTitle.Text.Trim();
            //objIncident.Title = drpTitle.SelectedItem.Text;
            // objIncident.Title = txtTitle.Text.Trim() + "-" + Txtextension.Text.Trim();
            //objIncident.Title = txtTitle.Text.Trim();
            if (Txtextension.Text != "")
            {
                string extension = Txtextension.Text;
                Int64  vOut      = Convert.ToInt64(extension);
                //int vOut = Convert.ToInt32(extension);
                objIncident.Extension = vOut;
            }
            //start changed by prachi-19thmarch
            if (drpAMCcall.SelectedItem.Text == "NO")
            {
                objIncident.AMCCall = false;
            }
            else if (drpAMCcall.SelectedItem.Text == "YES")
            {
                objIncident.AMCCall = true;
            }
            //end
            objIncident.Slaid          = SLAid;
            objIncident.Createdbyid    = createdbyid;
            objIncident.Requesterid    = requesterid;
            objIncident.Siteid         = siteid;
            objIncident.Description    = txtDescription.Text.ToString().Trim();
            objIncident.Deptid         = Convert.ToInt32(drpDepartment.SelectedValue);
            objIncident.Createdatetime = DateTime.Now.ToString();
            objIncident.Modeid         = Convert.ToInt32(drpMode.SelectedValue);
            //objIncident.ExternalTicketNo = txtExternalTicket.Text.ToString().Trim();
            if (FlagUserStatus == true)
            {
                FlagInsert = objIncident.Insert();

                #region Save Assetid and incident id in incidenttoassetmaaping

                // Get Asset and Incident Id for incidenttoassetmaaping
                objOrganization = objOrganization.Get_Organization();
                objUser         = objUser.Get_UserLogin_By_UserName_Ex(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                int userid    = Convert.ToInt32(objUser.Userid);
                int tempuser1 = Convert.ToInt32(Session["tempuser1"]);
                if (tempuser1 == 1)
                {
                    assetid = Convert.ToInt32(Session["assetid"]);
                }
                else
                {
                    assetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid));
                }
                int incid = Convert.ToInt32(objIncident.Get_TopIncidentId());
                if (txtassignasset.Text != "")
                {
                    //assetid = Convert.ToInt32(txtassignasset.Text);
                    if (assetid != 0)
                    {
                        objincidenttoasset.Insert(incid, assetid);
                        objusertoasset.Insert(userid, assetid, objUser.City, objUser.Company);
                        Session.Abandon();
                    }
                }

                #endregion
            }

            if (FlagInsert == 1)
            {
                int FlagIncdStatesInsert;
                int incidentid;
                incidentid = objIncident.Get_Current_Incidentid();
                objIncidentStates.Incidentid    = incidentid;
                objIncidentStates.Priorityid    = Convert.ToInt32(drpPriority.SelectedValue);
                objIncidentStates.Categoryid    = Convert.ToInt32(drpCategory.SelectedValue);
                objIncidentStates.Statusid      = Convert.ToInt32(drpStatus.SelectedValue);
                objIncidentStates.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue);
                objIncidentStates.Technicianid  = Convert.ToInt32(drpTechnician.SelectedValue);
                if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                {
                    objIncidentStates.AssignedTime = DateTime.Now.ToString();
                }
                objIncidentStates.Requesttypeid = Convert.ToInt32(drpRequestType.SelectedValue);
                FlagIncdStatesInsert            = objIncidentStates.Insert();
                if (FlagIncdStatesInsert == 1)
                {
                    objIncidentHistory.Incidentid       = incidentid;
                    objIncidentHistory.Operation        = "create";
                    objIncidentHistory.Operationownerid = createdbyid;
                    objIncidentHistory.Insert();



                    objSentmailtoUser.SentmailUser(requesterid, incidentid, "open");
                    // change code/////////////////////////////////////////////////////////////////
                    if (FileUpload1.HasFile)
                    {
                        string   filepath    = Server.MapPath("~/FileAttach/");
                        string[] filenameupd = FileUpload1.FileName.Split(new char[] { '.' });
                        string   filenew     = Convert.ToString(incidentid) + "." + filenameupd[1];
                        FileUpload1.PostedFile.SaveAs(filepath + filenew);
                    }
                    ///////////////////////////////////////////////////////////////////////////////


                    if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                    {
                        objSentmailtoUser.SentmailTechnician(Convert.ToInt32(drpTechnician.SelectedValue), incidentid);
                    }

                    Response.Redirect("~/Incident/IncidentRequestUpdate.aspx?incidentid=" + incidentid + "");
                }
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }