示例#1
0
        public static bool IsValidTransNumber(string sFrmFlag, string sTranFlag, string sTransNo, int iMode, int iCCId, int iCompanyId)
        {
            bool bRetVal = false;

            if (BsfGlobal.g_bAssetDB == true)
            {
                try
                {
                    BsfGlobal.OpenAssetDB();
                    string sSql = "";

                    if (sFrmFlag == "Buyer")
                    {
                        if (sFrmFlag == "Buyer" && (sTranFlag == "  " || sTranFlag == "GE"))
                        {
                            sSql = "Select AllotmentNo From BuyerDetail Where AllotmentNo='" + sTransNo + "' ";
                        }
                        else if (sFrmFlag == "Buyer" && sTranFlag == "CC")
                        {
                            sSql = "Select CCAllotNo From BuyerDetail Where CCAllotNo='" + sTransNo + "' And CostCentreId=" + iCCId + " ";
                        }
                        else if (sFrmFlag == "Buyer" && sTranFlag == "CO")
                        {
                            sSql = "Select COAllotNo From BuyerDetail Where CostCentreId IN (  " +
                                   "Select CostCentreId From [" + BsfGlobal.g_sWorkFlowDBName + "]..OperationalCostCentre Where FACostCentreId IN ( " +
                                   "Select CostCentreId From [" + BsfGlobal.g_sWorkFlowDBName + "]..CostCentre Where CompanyId=" + iCompanyId + ")) And COAllotNo='" + sTransNo + "' ";
                        }
                    }

                    if (sSql != "")
                    {
                        SqlCommand    cmd = new SqlCommand(sSql, BsfGlobal.g_AssetDB);
                        SqlDataReader sdr = cmd.ExecuteReader();
                        DataTable     dt  = new DataTable();
                        dt.Load(sdr);
                        sdr.Close();
                        cmd.Dispose();

                        if (iMode == 0)
                        {
                            if (dt.Rows.Count == 0)
                            {
                                bRetVal = true;
                            }
                            else
                            {
                                bRetVal = false;
                            }
                        }
                        else
                        {
                            if (dt.Rows.Count == 1)
                            {
                                bRetVal = true;
                            }
                            else
                            {
                                bRetVal = false;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    BsfGlobal.CustomException(ex.Message, ex.StackTrace);
                }
                finally
                {
                    BsfGlobal.g_AssetDB.Close();
                }
            }
            return(bRetVal);
        }