protected void BtnSave_Click(object sender, EventArgs e)
    {
        int  InsertRow = 0, DeleteRow = 0;
        bool Flag = false;

        if (ddlProject.Items.Count == 0)
        {
            Obj_Comm.ShowPopUpMsg("Please Select Minimum One Project", this.Page);
            ddlProject.Focus();
            return;
        }
        else
        {
            for (int i = 0; i < ddlProject.Items.Count; i++)
            {
                if (ddlProject.Items[i].Selected)
                {
                    Flag = true;
                }
            }
            if (!Flag)
            {
                Obj_Comm.ShowPopUpMsg("Please Select Minimum One Project", this.Page);
                ddlProject.Focus();
                return;
            }
        }
        if (ViewState["Details"] != null)
        {
            DataTable Dt = (DataTable)ViewState["Details"];
            if (Dt.Rows.Count > 0)
            {
                DeleteRow = Obj_Call.DeleteRecord();
            }
        }
        foreach (System.Web.UI.WebControls.ListItem item in ddlProject.Items)
        {
            if (item.Selected)
            {
                Entity_Call.PCId      = Convert.ToInt32(item.Value);
                Entity_Call.UserId    = Convert.ToInt32(Session["UserId"]);
                Entity_Call.LoginDate = DateTime.Now;

                InsertRow = Obj_Call.InsertRecord(ref Entity_Call, out StrError);
            }
        }
        if (InsertRow > 0)
        {
            Obj_Comm.ShowPopUpMsg("Record Saved Successfully", this.Page);
            MakeEmptyForm();
            Entity_Call = null;
            Obj_Comm    = null;
        }
    }
Beispiel #2
0
        public int InsertRecord(ref FlatLayout Entity_Call, out string StrError)
        {
            int iInsert = 0;

            StrError = string.Empty;
            try
            {
                SqlParameter pAction = new SqlParameter(FlatLayout._Action, SqlDbType.BigInt);
                SqlParameter pPCId   = new SqlParameter(FlatLayout._PCId, SqlDbType.BigInt);

                SqlParameter pCreatedBy   = new SqlParameter(FlatLayout._UserId, SqlDbType.BigInt);
                SqlParameter pCreatedDate = new SqlParameter(FlatLayout._LoginDate, SqlDbType.DateTime);

                pAction.Value = 1;
                pPCId.Value   = Entity_Call.PCId;

                pCreatedBy.Value   = Entity_Call.UserId;
                pCreatedDate.Value = Entity_Call.LoginDate;

                SqlParameter[] param = new SqlParameter[] { pAction, pPCId, pCreatedBy, pCreatedDate };

                Open(CONNECTION_STRING);
                BeginTransaction();
                iInsert = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, "SP_DashBoardMaster", param);
                if (iInsert > 0)
                {
                    CommitTransaction();
                }
                else
                {
                    RollBackTransaction();
                }
            }
            catch (Exception ex)
            {
                RollBackTransaction();
                StrError = ex.Message;
            }
            finally
            {
                Close();
            }
            return(iInsert);
        }