コード例 #1
0
        /// <summary>
        /// To save details to database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            int         count;
            WorkFlowBLL WorkFlowBLLOBJ = new WorkFlowBLL();

            if (WORKFLOWDEFINITIONIDTextBox.Text != "0")
            {
                string message      = string.Empty;
                string AlertMessage = string.Empty;

                string uID = Session["USER_ID"].ToString();
                string pID = Session["PROJECT_ID"].ToString();

                WorkFlowBO objWorkFlow = new WorkFlowBO();
                objWorkFlow.WorkFlowDefID     = Convert.ToInt32(WORKFLOWDEFINITIONIDTextBox.Text.ToString());
                objWorkFlow.ModuleID          = Convert.ToInt32(ModuleDropDownList.SelectedItem.Value.ToString().Trim());
                objWorkFlow.WorkflowID        = Convert.ToInt32(WorkflowItemDropDownList.SelectedItem.Value.ToString());
                objWorkFlow.HigherAuthorityID = Convert.ToInt32(HightAuthDropDownList.SelectedItem.Value.ToString());
                objWorkFlow.Trigger           = TriggerDropDownList.SelectedItem.Value.ToString();
                objWorkFlow.AfterDays         = Convert.ToInt32(AfterDropDownList.SelectedItem.Value.ToString());
                objWorkFlow.UserID            = Convert.ToInt32(uID);
                objWorkFlow.ProjectID         = Convert.ToInt32(pID);

                WorkFlowBLL WorkFlowBLLobj = new WorkFlowBLL();
                count = WorkFlowBLLobj.EditWorkFlowDef(objWorkFlow);
                if (count == -1)
                {
                    BindGridWorkFlowDefinition();
                    WORKFLOWDEFINITIONIDTextBox.Text = "0";
                    message      = "Data updated successfully.";
                    AlertMessage = "alert('" + message + "');";
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                    clear();
                    SetUpdateMode(false);
                }
                if (count == 1)
                {
                    BindGridWorkFlowDefinition();
                    WORKFLOWDEFINITIONIDTextBox.Text = "0";
                    message      = "Workflow Item Already Exist";
                    AlertMessage = "alert('" + message + "');";
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                    clear();
                    SetUpdateMode(false);
                }
            }
            else
            {
                try
                {
                    string message      = string.Empty;
                    string AlertMessage = string.Empty;

                    string uID = Session["USER_ID"].ToString();
                    string pID = Session["PROJECT_ID"].ToString();

                    WorkFlowBO objWorkFlow = new WorkFlowBO();
                    objWorkFlow.ModuleID          = Convert.ToInt32(ModuleDropDownList.SelectedItem.Value.ToString().Trim());
                    objWorkFlow.WorkflowID        = Convert.ToInt32(WorkflowItemDropDownList.SelectedItem.Value.ToString());
                    objWorkFlow.HigherAuthorityID = Convert.ToInt32(HightAuthDropDownList.SelectedItem.Value.ToString());
                    objWorkFlow.Trigger           = TriggerDropDownList.SelectedItem.Value.ToString();
                    objWorkFlow.AfterDays         = Convert.ToInt32(AfterDropDownList.SelectedItem.Value.ToString());
                    objWorkFlow.UserID            = Convert.ToInt32(uID);
                    objWorkFlow.ProjectID         = Convert.ToInt32(pID);

                    WorkFlowBLL WorkFlowBLLobj = new WorkFlowBLL();
                    count = WorkFlowBLLobj.InsertWorkFlow(objWorkFlow);

                    if (count == -1)
                    {
                        BindGridWorkFlowDefinition();
                        message      = "Data saved successfully.";
                        AlertMessage = "alert('" + message + "');";
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                        clear();
                    }
                    if (count == 1)
                    {
                        BindGridWorkFlowDefinition();
                        message      = "Workflow Item Already Exist";
                        AlertMessage = "alert('" + message + "');";
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);
                        clear();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                finally
                {
                    WorkFlowBLLOBJ = null;
                }
            }
        }