private bool saveData()
        {
            bool   blnResult        = false;
            bool   blnDup           = false;
            string strMessage       = string.Empty;
            string stritem_acc_code = string.Empty,
                   stritem_acc_year = string.Empty,
                   stritem_acc_name = string.Empty,
                   strActive        = string.Empty,
                   strCreatedBy     = string.Empty,
                   strUpdatedBy     = string.Empty;
            string    strScript     = string.Empty;
            cItem_acc oItem_acc     = new cItem_acc();
            DataSet   ds            = new DataSet();

            try
            {
                #region set Data
                stritem_acc_code = txtitem_acc_code.Text.Trim();
                stritem_acc_name = txtitem_acc_name.Text;
                stritem_acc_year = cboYear.SelectedItem.Value;
                if (chkStatus.Checked == true)
                {
                    strActive = "Y";
                }
                else
                {
                    strActive = "N";
                }
                strCreatedBy = Session["username"].ToString();
                strUpdatedBy = Session["username"].ToString();
                #endregion
                if (ViewState["mode"].ToString().ToLower().Equals("edit"))
                {
                    #region edit
                    if (!blnDup)
                    {
                        if (oItem_acc.SP_ITEM_ACC_UPD(hdditem_acc_id.Value.ToString(), stritem_acc_code,
                                                      stritem_acc_year, stritem_acc_name, strActive, strUpdatedBy, ref strMessage))
                        {
                            blnResult = true;
                        }
                        else
                        {
                            lblError.Text = strMessage.ToString();
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "frMainPage", strScript, true);
                    }
                    #endregion
                }
                else
                {
                    #region check dup
                    string strCheckDup = string.Empty;
                    strCheckDup = " and item_acc_name = '" + stritem_acc_name.Trim() + "' and item_acc_year = '" + stritem_acc_year + "' ";
                    if (!oItem_acc.SP_ITEM_ACC_SEL(strCheckDup, ref ds, ref strMessage))
                    {
                        lblError.Text = strMessage;
                    }
                    else
                    {
                        if (ds.Tables[0].Rows.Count > 0)
                        {
                            strScript =
                                "alert(\"ไม่สามารถเพิ่มข้อมูล เนื่องจากข้อมูล " + stritem_acc_name.Trim() + " ปี " + stritem_acc_year.Trim() + "  ซ้ำ\");\n";
                            blnDup = true;
                        }
                    }
                    #endregion
                    #region insert
                    if (!blnDup)
                    {
                        if (oItem_acc.SP_ITEM_ACC_INS(stritem_acc_year, stritem_acc_code, stritem_acc_name, strActive, strCreatedBy, ref strMessage))
                        {
                            string strGetcode = " and item_acc_name = '" + stritem_acc_name.Trim() + "' and item_acc_year = '" + stritem_acc_year + "' ";
                            if (!oItem_acc.SP_ITEM_ACC_SEL(strGetcode, ref ds, ref strMessage))
                            {
                                lblError.Text = strMessage;
                            }
                            if (ds.Tables[0].Rows.Count > 0)
                            {
                                stritem_acc_code = ds.Tables[0].Rows[0]["item_acc_id"].ToString();
                            }
                            ViewState["item_acc_id"] = stritem_acc_code;
                            blnResult = true;
                        }
                        else
                        {
                            lblError.Text = strMessage.ToString();
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "frMainPage", strScript, true);
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oItem_acc.Dispose();
            }
            return(blnResult);
        }