예제 #1
0
        public void UpdateBFMaster(BillFormatMaster argBFMaster,string m_sArgType)
        {
            SqlConnection conn;
            conn = new SqlConnection();
            conn = BsfGlobal.OpenWPMDB();
            SqlCommand cmd;
            SqlTransaction tran = conn.BeginTransaction();
            string sSql = "";
            //int iQualId = 0;
            try
            {

                if (m_sArgType == "B")
                {

                    //if (argBFMaster.QualifierId != 0)
                    //{
                    //    sSql = "Select QualifierId from BillFormatMaster Where QualifierId=" + argBFMaster.QualifierId;
                    //    cmd = new SqlCommand(sSql, conn, tran);
                    //    iQualId = Convert.ToInt32(CommFun.IsNullCheck(cmd.ExecuteScalar()));
                    //    cmd.Dispose();
                    //    if (iQualId != 0)
                    //    {
                    //        throw new Exception("Already Exist in this Qualifier");
                    //    }
                    //}

                    sSql = "Update BillFormatMaster set TypeName='" + argBFMaster.TypeName + "',Type='" + argBFMaster.Type + "',AddType=" + argBFMaster.Addtype + ",OrderNo=" + argBFMaster.OrderNo + ", " +
                            "HeadingName='" + argBFMaster.Heading + "',Header=" + argBFMaster.Header + ",RefNo='" + argBFMaster.RefNo + "',Bold=" + argBFMaster.Bold + " ,QTypeId=" + argBFMaster.QTypeId + ", QualifierId="+argBFMaster.QualifierId+" " +
                            "Where TypeId=" + argBFMaster.BFTypeId;
                }
                else
                {
                    sSql = "Update LabourFormat set TypeName='" + argBFMaster.TypeName + "',Type='" + argBFMaster.Type + "',AddType=" + argBFMaster.Addtype + ",OrderNo=" + argBFMaster.OrderNo + ", " +
                        "HeadingName='" + argBFMaster.Heading + "',Header=" + argBFMaster.Header + ",RefNo='" + argBFMaster.RefNo + "',Bold=" + argBFMaster.Bold + " " +
                      "Where TypeId=" + argBFMaster.BFTypeId;
                }
                cmd = new SqlCommand(sSql, conn,tran);
                cmd.ExecuteNonQuery();
                cmd.Dispose();

                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                BsfGlobal.CustomException(ex.Message, ex.StackTrace);
            }
            finally
            {
                conn.Close();
            }
        }
예제 #2
0
        public void UpdateBillFormat(BillFormatMaster arfTDSM, string argType)
        {
            SqlConnection conn;
            conn = new SqlConnection();
            conn = BsfGlobal.OpenWPMDB();
            SqlTransaction tran = conn.BeginTransaction();
            SqlCommand cmd;
            string sSql = "";
            string sFType = "B";

            if (arfTDSM.CCId == 0)
            {
                sFType = "A";
            }

            try
            {
                if (argType == "B")
                {
                    sSql = "Update BillFormat Set HeadingName= '" + arfTDSM.Heading + "', " +
                   "Formula = '" + arfTDSM.Formula + "', AccountId = " + arfTDSM.AccountId + ",FormatType='"+sFType+"' " +
                   "Where TypeId= " + arfTDSM.BFTypeId + " and CostCentreId = " + arfTDSM.CCId + "";
                }
                else
                {
                    sSql = "Update LabourFormatTrans Set HeadingName= '" + arfTDSM.Heading + "', " +
                  "Formula = '" + arfTDSM.Formula + "', AccountId = " + arfTDSM.AccountId + " " +
                  "Where TypeId= " + arfTDSM.BFTypeId + " and CostCentreId = " + arfTDSM.CCId + "";
                }
                cmd = new SqlCommand(sSql, conn,tran);
                cmd.ExecuteNonQuery();
                cmd.Dispose();

                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                BsfGlobal.CustomException(ex.Message, ex.StackTrace);
            }
            finally
            {
                conn.Close();
            }
        }
예제 #3
0
        public void InsertBFMaster(BillFormatMaster argBFMaster,string argfrm)
        {
            SqlConnection conn;
            conn = new SqlConnection();
            conn = BsfGlobal.OpenWPMDB();
            SqlTransaction tran = conn.BeginTransaction();
            SqlCommand cmd;
            string sSql = "";
            int iQualId = 0;
            try
            {
                if (argfrm == "B")
                {
                    if (argBFMaster.QualifierId != 0)
                    {
                        sSql = "Select QualifierId from BillFormatMaster Where QualifierId=" + argBFMaster.QualifierId;
                        cmd = new SqlCommand(sSql, conn, tran);
                        iQualId= Convert.ToInt32(CommFun.IsNullCheck(cmd.ExecuteScalar()));
                        cmd.Dispose();
                        if (iQualId != 0)
                        {
                            throw new Exception("Already Exist in this Qualifier");
                        }
                    }

                    sSql = "Insert into BillFormatMaster(TypeID,TypeName,Type,AddType,OrderNo,HeadingName,Header,RefNo,Bold,QTypeId,QualifierId) " +
                        "values(" + argBFMaster.BFTypeId + ",'" + argBFMaster.TypeName + "','" + argBFMaster.Type + "'," + argBFMaster.Addtype + ", " +
                        " " + argBFMaster.OrderNo + ",'" + argBFMaster.Heading + "'," + argBFMaster.Header + ",'" + argBFMaster.RefNo + "'," + argBFMaster.Bold + ", " +
                        " " + argBFMaster.QTypeId + "," + argBFMaster.QualifierId + ") SELECT SCOPE_IDENTITY();";
                }
                else
                {
                    sSql = "Insert into LabourFormat(TypeID,TypeName,Type,AddType,OrderNo,HeadingName,Header,RefNo,Bold) " +
                       "values(" + argBFMaster.BFTypeId + ",'" + argBFMaster.TypeName + "','" + argBFMaster.Type + "'," + argBFMaster.Addtype + "," + argBFMaster.OrderNo + ",'" + argBFMaster.Heading + "'," + argBFMaster.Header + ",'" + argBFMaster.RefNo + "'," + argBFMaster.Bold + ") SELECT SCOPE_IDENTITY();";
                }

                cmd = new SqlCommand(sSql, conn,tran);
                cmd.ExecuteNonQuery();
                cmd.Dispose();

                tran.Commit();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                BsfGlobal.CustomException(ex.Message, ex.StackTrace);
            }
            finally
            {
                conn.Close();
            }
        }