예제 #1
0
        bool isUpdate = false;  //默认不需要更新

        public MdiMain()
        {
            InitInfo();

            InitializeComponent();

            isUpdate = CheckNeedUpdate();

            if (isUpdate)
            {
                MessageBox.Show("程序需要更新!", "提示");
                Application.Exit();

                System.Diagnostics.Process.Start(Application.StartupPath + @"\AutoUpdate.exe");

                return;
            }

            m_FormList = new Dictionary <string, Form>();

            if (Login())
            {
                bIsLogined = true;
            }
            else
            {
                bIsLogined = false;
            }

            clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();

            xtraTabbedMdiManager.SelectedPageChanged += new System.EventHandler(this.xtraTabbedMdiManager2_SelectedPageChanged);
        }
예제 #2
0
        public static string s出货周(string sSOCode, string iRow)
        {
            string s = "";

            try
            {
                FrameBaseFunction.ClsDataBase clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
                string sSQL = @"
select a.cSOCode,b.iRowNo,c.*
from @u8.so_somain a inner join @u8.SO_SODetails b on a.ID = b.id
	inner join dbo.外销订单总表 c on c.销售订单号 = a.cSOCode and b.iRowNo = c.行号 and 帐套号 = '222222'
where 1=1	and isnull(c.出货周,'') <> ''
order by a.cSOCode,b.iRowNo,c.年度
";

                sSQL = sSQL.Replace("222222", FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName.Substring(7, 3));
                sSQL = sSQL.Replace("1=1", "1=1 and a.cSOCode = '" + sSOCode + "' and b.iRowNo = '" + iRow + "' ");

                DataTable dt = clsSQLCommond.ExecQuery(sSQL);
                if (dt == null || dt.Rows.Count < 1)
                {
                }
                else
                {
                    s = dt.Rows[0]["出货周"].ToString().Trim();
                }
            }
            catch (Exception ee)
            {
            }
            return(s);
        }
예제 #3
0
        /// <summary>
        /// 权限判断
        /// </summary>
        /// <returns></returns>
        private bool hasRight(string sInfo, string sUid)
        {
            bool b = false;

            try
            {
                clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();

                string sSQL = "SELECT     COUNT(*) AS iCount " +
                              "FROM         dbo._RoleRight INNER JOIN dbo._UserRoleInfo ON _RoleRight.vchrRoleID = dbo._UserRoleInfo.vchrRoleID " +
                              "WHERE   dbo._UserRoleInfo.vchrUserID = '" + sUid + "' and dbo._RoleRight.vchrRoleRight = '" + sInfo + "' ";

                int iCou = Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL));
                if (iCou > 0)
                {
                    b = true;
                }
                else
                {
                    b = false;
                }
            }
            catch
            {
                throw new Exception("判断权限失败!");
            }
            return(b);
        }
예제 #4
0
        public static DateTime GetServerTime()
        {
            FrameBaseFunction.ClsDataBase clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
            string    sql = "select getdate()";
            DataTable dt  = clsSQLCommond.ExecQuery(sql);

            return(DateTime.Parse(dt.Rows[0][0].ToString()));
        }
예제 #5
0
        /// <summary>
        /// 结存换算率
        /// </summary>
        /// <param name="sInvCode"></param>
        /// <returns></returns>
        public static decimal Return换算率(string sInvCode, string sWhCode)
        {
            FrameBaseFunction.ClsDataBase clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
            decimal iRet = -1;

            try
            {
                string sSQL = "select iQuantity/iNum from @u8.CurrentStock where cInvCode = '" + sInvCode + "' and cWhCode = '" + sWhCode + "'";
                iRet = FrameBaseFunction.ClsBaseDataInfo.ReturnDecimal(clsSQLCommond.ExecGetScalar(sSQL));
            }
            catch
            {
            }
            return(iRet);
        }
예제 #6
0
        /// <summary>
        /// 档案换算率
        /// </summary>
        /// <param name="sInvCode"></param>
        /// <returns></returns>
        public static decimal Return换算率(string sInvCode)
        {
            FrameBaseFunction.ClsDataBase clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
            decimal iRet = -1;

            try
            {
                string sSQL = "select c.iChangRate/b.iChangRate " +
                              "from @u8.inventory a inner join @u8.ComputationUnit  b on a.cComUnitCode = b.cComunitCode " +
                              "	inner join @u8.ComputationUnit c on a.cAssComUnitCode = c.cComunitCode " +
                              "where a.cInvCode = '" + sInvCode + "'";
                iRet = FrameBaseFunction.ClsBaseDataInfo.ReturnDecimal(clsSQLCommond.ExecGetScalar(sSQL));
            }
            catch
            {
            }
            return(iRet);
        }
예제 #7
0
        public FrmLogin()
        {
            FrameBaseFunction.ClsBaseDataInfo.sDataBaseType = GetConfigValue(sPathConfig, "DataBaseType");
            InitializeComponent();

            try
            {
                clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
                clsDES        = FrameBaseFunction.ClsDES.Instance();

                InitInfo();

                label1.Visible    = bU8Improt;
                lookUpAcc.Visible = bU8Improt;
            }
            catch
            { }
        }
예제 #8
0
        public static string GetFormNumber(string preFix, string tableName, string filedName, DateTime date, bool isByAddByMonth)
        {
            FrameBaseFunction.ClsDataBase clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
            string result     = "";
            string datePre    = date.ToString("yyyyMMdd");
            string dateSearch = "";

            if (isByAddByMonth)
            {
                dateSearch = date.ToString("yyyyMM");
            }
            else
            {
                dateSearch = date.ToString("yyyyMMdd");
            }

            string sql = string.Format("select max({0}) as MaxNum from {1}  with (nolock) where {2} like '" + preFix + "{3}%'",
                                       filedName, tableName, filedName, dateSearch);

            DataTable dt = clsSQLCommond.ExecQuery(sql);

            if (dt.Rows.Count > 0)
            {
                result = dt.Rows[0]["MaxNum"].ToString();
                if (result == "")
                {
                    result = preFix + datePre + "001";
                }
                else
                {
                    int currentNumber = int.Parse(result.Substring(11, 3)) + 1;

                    result = preFix + datePre + string.Format("{0:000}", currentNumber);
                }
            }
            return(result);
        }
예제 #9
0
 public ClsRoleRight()
 {
     clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
 }
예제 #10
0
        private void toolStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                string sInfo = this.Name + "|" + e.ClickedItem.Name;

                if (e.ClickedItem.Name.ToLower().Trim() == "exit")
                {
                    if (MessageBox.Show("是否关闭当前窗体?\n是:关闭\n否:取消", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                    {
                        this.Close();
                        return;
                    }
                }

                clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
                string sSQL2 = @"select count(*) from dbo._UserRoleInfo where vchrRoleID = 'administrator' and vchrUserID = '" + sUid + "'";

                bool b = false;
                if (sUid == "admin" || sUid == "system")
                {
                    b = true;
                }
                if (Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL2)) != 0)
                {
                    b = true;
                }
                if (!b)
                {
                    if (!hasRight(sInfo, sUid))
                    {
                        e.ClickedItem.Enabled = false;
                        MessageBox.Show("权限不足!");
                        return;
                    }
                }

                BtnClick(e.ClickedItem.Name, e.ClickedItem.Text);

                if (dtBtnInfo != null && dtBtnInfo.Rows.Count > 0)
                {
                    for (int i = 0; i < dtBtnInfo.Rows.Count; i++)
                    {
                        if (dtBtnInfo.Rows[i]["vchrBtnID"].ToString().Trim().ToLower() == e.ClickedItem.Name.ToLower().Trim())
                        {
                            if (Convert.ToInt32(dtBtnInfo.Rows[i]["bEnable"]) == 0)
                            {
                                btnEnable = true;
                                SetBtnEnable(btnEnable);
                            }
                            else if (Convert.ToInt32(dtBtnInfo.Rows[i]["bEnable"]) == 1 || Convert.ToInt32(dtBtnInfo.Rows[i]["bEnable"]) == 2)
                            {
                                SetBtnEnable(btnEnable);
                            }
                            else if (Convert.ToInt32(dtBtnInfo.Rows[i]["bEnable"]) == 3)
                            {
                                SetBtnEnable(true);
                            }
                            else if (Convert.ToInt32(dtBtnInfo.Rows[i]["bEnable"]) == 4)
                            {
                                SetBtnEnable(false);
                            }
                        }
                    }
                }

                Cursor.Current = Cursors.Default;
            }
            catch (Exception ee)
            {
                MsgBox("操作失败", ee.Message);
            }
        }
예제 #11
0
        /// <summary>
        /// 创建窗体按钮
        /// </summary>
        private void CreateBtn(string sFormInfo)
        {
            clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
            string sSQL2 = @"select count(*) from dbo._UserRoleInfo where vchrRoleID = 'administrator' and vchrUserID = '" + sUid + "'";
            string sSQL  = "";

            if (sUid == "admin" || sUid == "system" || Convert.ToInt32(clsSQLCommond.ExecGetScalar(sSQL2)) != 0)
            {
                sSQL = "SELECT TOP 100 PERCENT fchrFrmNameID, bEnable, vchrBtnID, vchrBtnText, iIcon, vchrRemark, intOrder,isnull(bEnable,0) as bEnable " +
                       "FROM dbo._FormBtnInfo " +
                       "WHERE (fchrFrmNameID = '" + sFormInfo + "') " +
                       "ORDER BY intOrder DESC";
            }
            else
            {
                sSQL = "SELECT distinct _FormBtnInfo.fchrFrmNameID, bEnable, vchrBtnID, vchrBtnText, _FormBtnInfo.vchrRemark, intOrder,isnull(bEnable,0) as bEnable , " +
                       "  RTRIM(LTRIM(LEFT(dbo._RoleRight.vchrRoleRight, CHARINDEX('|', dbo._RoleRight.vchrRoleRight) - 1))) AS vchrL,  " +
                       "  RTRIM(LTRIM(RIGHT(dbo._RoleRight.vchrRoleRight, LEN(dbo._RoleRight.vchrRoleRight) - CHARINDEX('|', dbo._RoleRight.vchrRoleRight))))  " +
                       "  AS vchrR " +
                       "FROM         dbo._RoleInfo INNER JOIN " +
                       "	dbo._RoleRight ON dbo._RoleInfo.vchrRoleID = dbo._RoleRight.vchrRoleID INNER JOIN "+
                       "	dbo._UserRoleInfo ON dbo._RoleInfo.vchrRoleID = dbo._UserRoleInfo.vchrRoleID AND dbo._UserRoleInfo.vchrUserID = '"+ sUid + "'  " +
                       "	INNER JOIN "+
                       "	dbo._FormBtnInfo ON vchrBtnID = RTRIM(LTRIM(RIGHT(dbo._RoleRight.vchrRoleRight, LEN(dbo._RoleRight.vchrRoleRight) - CHARINDEX('|', dbo._RoleRight.vchrRoleRight)))) AND fchrFrmNameID = RTRIM(LTRIM(LEFT(dbo._RoleRight.vchrRoleRight, CHARINDEX('|', dbo._RoleRight.vchrRoleRight) - 1))) "+
                       "WHERE     (fchrFrmNameID = '" + sFormInfo + "')  " +
                       "ORDER BY intOrder DESC";
            }
            DataTable dt = clsSQLCommond.ExecQuery(sSQL);

            if (dt == null || dt.Rows.Count < 1)
            {
                return;
            }

            dtBtnInfo = dt.Copy();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                switch (Convert.ToInt32(dt.Rows[i]["bEnable"]))
                {
                case 0:
                    toolStripMenuBtn.Items[dt.Rows[i]["vchrBtnID"].ToString().Trim().ToLower()].Enabled = true;
                    break;

                case 1:
                    toolStripMenuBtn.Items[dt.Rows[i]["vchrBtnID"].ToString().Trim().ToLower()].Enabled = true;
                    break;

                case 2:
                    toolStripMenuBtn.Items[dt.Rows[i]["vchrBtnID"].ToString().Trim().ToLower()].Enabled = false;
                    break;

                default:
                    toolStripMenuBtn.Items[dt.Rows[i]["vchrBtnID"].ToString().Trim().ToLower()].Enabled = false;
                    break;
                }
                switch (dt.Rows[i]["vchrBtnID"].ToString().Trim().ToLower())
                {
                case "layout":
                    toolStripMenuBtn.Items["layout"].Visible = true;
                    toolStripMenuBtn.Items["layout"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag     = dt.Rows[i]["bEnable"].ToString().Trim();
                    tLayout.Visible = true;
                    break;

                case "printset":
                    toolStripMenuBtn.Items["printset"].Visible = true;
                    toolStripMenuBtn.Items["printset"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag       = dt.Rows[i]["bEnable"].ToString().Trim();
                    tLayout.Visible = true;
                    break;

                case "export":
                    toolStripMenuBtn.Items["export"].Visible = true;
                    toolStripMenuBtn.Items["export"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag     = dt.Rows[i]["bEnable"].ToString().Trim();
                    tExport.Visible = true;
                    break;

                case "print":
                    toolStripMenuBtn.Items["print"].Visible = true;
                    toolStripMenuBtn.Items["print"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag    = dt.Rows[i]["bEnable"].ToString().Trim();
                    tExport.Visible = true;
                    break;

                case "unaudit":
                    toolStripMenuBtn.Items["unaudit"].Visible = true;
                    toolStripMenuBtn.Items["unaudit"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag      = dt.Rows[i]["bEnable"].ToString().Trim();
                    tAudit.Visible = true;
                    break;

                case "audit":
                    toolStripMenuBtn.Items["audit"].Visible = true;
                    toolStripMenuBtn.Items["audit"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag    = dt.Rows[i]["bEnable"].ToString().Trim();
                    tAudit.Visible = true;
                    break;

                case "unlock":
                    toolStripMenuBtn.Items["unlock"].Visible = true;
                    toolStripMenuBtn.Items["unlock"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag     = dt.Rows[i]["bEnable"].ToString().Trim();
                    tLock.Visible = true;
                    break;

                case "lock":
                    toolStripMenuBtn.Items["lock"].Visible = true;
                    toolStripMenuBtn.Items["lock"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag   = dt.Rows[i]["bEnable"].ToString().Trim();
                    tLock.Visible = true;
                    break;

                case "alter":
                    toolStripMenuBtn.Items["alter"].Visible = true;
                    toolStripMenuBtn.Items["alter"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag    = dt.Rows[i]["bEnable"].ToString().Trim();
                    tSave.Visible = true;
                    break;

                case "undo":
                    toolStripMenuBtn.Items["undo"].Visible = true;
                    toolStripMenuBtn.Items["undo"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag   = dt.Rows[i]["bEnable"].ToString().Trim();
                    tSave.Visible = true;
                    break;

                case "save":
                    toolStripMenuBtn.Items["save"].Visible = true;
                    toolStripMenuBtn.Items["save"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag   = dt.Rows[i]["bEnable"].ToString().Trim();
                    tSave.Visible = true;
                    break;

                case "del":
                    toolStripMenuBtn.Items["del"].Visible = true;
                    toolStripMenuBtn.Items["del"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag  = dt.Rows[i]["bEnable"].ToString().Trim();
                    tAdd.Visible = true;
                    break;

                case "edit":
                    toolStripMenuBtn.Items["edit"].Visible = true;
                    toolStripMenuBtn.Items["edit"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag   = dt.Rows[i]["bEnable"].ToString().Trim();
                    tAdd.Visible = true;
                    break;

                case "add":
                    toolStripMenuBtn.Items["add"].Visible = true;
                    toolStripMenuBtn.Items["add"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag  = dt.Rows[i]["bEnable"].ToString().Trim();
                    tAdd.Visible = true;
                    break;

                case "import":
                    toolStripMenuBtn.Items["import"].Visible = true;
                    toolStripMenuBtn.Items["import"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag     = dt.Rows[i]["bEnable"].ToString().Trim();
                    tAdd.Visible = true;
                    break;

                case "delrow":
                    toolStripMenuBtn.Items["delrow"].Visible = true;
                    toolStripMenuBtn.Items["delrow"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag     = dt.Rows[i]["bEnable"].ToString().Trim();
                    tAddRow.Visible = true;
                    break;

                case "addrow":
                    toolStripMenuBtn.Items["addrow"].Visible = true;
                    toolStripMenuBtn.Items["addrow"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag     = dt.Rows[i]["bEnable"].ToString().Trim();
                    tAddRow.Visible = true;
                    break;

                case "last":
                    toolStripMenuBtn.Items["last"].Visible = true;
                    toolStripMenuBtn.Items["last"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag   = dt.Rows[i]["bEnable"].ToString().Trim();
                    tSel.Visible      = true;
                    lPageInfo.Visible = true;
                    break;

                case "next":
                    toolStripMenuBtn.Items["next"].Visible = true;
                    toolStripMenuBtn.Items["next"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag   = dt.Rows[i]["bEnable"].ToString().Trim();
                    tSel.Visible      = true;
                    lPageInfo.Visible = true;
                    break;

                case "prev":
                    toolStripMenuBtn.Items["prev"].Visible = true;
                    toolStripMenuBtn.Items["prev"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag   = dt.Rows[i]["bEnable"].ToString().Trim();
                    tSel.Visible      = true;
                    lPageInfo.Visible = true;
                    break;

                case "first":
                    toolStripMenuBtn.Items["first"].Visible = true;
                    toolStripMenuBtn.Items["first"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag    = dt.Rows[i]["bEnable"].ToString().Trim();
                    tSel.Visible      = true;
                    lPageInfo.Visible = true;
                    break;

                case "sel":
                    toolStripMenuBtn.Items["sel"].Visible = true;
                    toolStripMenuBtn.Items["sel"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag  = dt.Rows[i]["bEnable"].ToString().Trim();
                    lPageInfo.Visible = true;
                    break;

                case "refresh":
                    toolStripMenuBtn.Items["refresh"].Visible = true;
                    toolStripMenuBtn.Items["refresh"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag      = dt.Rows[i]["bEnable"].ToString().Trim();
                    lPageInfo.Visible = true;
                    break;

                case "open":
                    toolStripMenuBtn.Items["open"].Visible = true;
                    toolStripMenuBtn.Items["open"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag   = dt.Rows[i]["bEnable"].ToString().Trim();
                    tOpen.Visible = true;
                    break;

                case "close":
                    toolStripMenuBtn.Items["close"].Visible = true;
                    toolStripMenuBtn.Items["close"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag    = dt.Rows[i]["bEnable"].ToString().Trim();
                    tOpen.Visible = true;
                    break;

                case "buckup":
                    toolStripMenuBtn.Items["buckup"].Visible = true;
                    toolStripMenuBtn.Items["buckup"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag     = dt.Rows[i]["bEnable"].ToString().Trim();
                    tBuckUp.Visible = true;
                    break;

                case "autobuckup":
                    toolStripMenuBtn.Items["autobuckup"].Visible = true;
                    toolStripMenuBtn.Items["autobuckup"].Text    = dt.Rows[i]["vchrBtnText"].ToString().Trim();
                    toolStripMenuBtn.Items["layout"].Tag         = dt.Rows[i]["bEnable"].ToString().Trim();
                    tBuckUp.Visible = true;
                    break;
                }
            }
            dtBtnInfo = dt.Copy();
        }
예제 #12
0
        private void GenRdRecords()
        {
            FrameBaseFunction.ClsDataBase clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
            grvDetail.PostEditor();
            this.Validate();

            string    whCode  = "01";
            string    sSQL    = "select * from @u8.GL_mend where iperiod = month('" + FrameBaseFunction.ClsBaseDataInfo.sLogDate + "')";
            DataTable dtTemp1 = clsSQLCommond.ExecQuery(sSQL);

            if (Convert.ToBoolean(dtTemp1.Rows[0]["bflag_ST"]) == true)
            {
                MessageBox.Show("当月库存管理已结帐!");
                return;
            }


            string filter = "";

            for (int i = 0; i < grvDetail.RowCount; i++)
            {
                string billId = grvDetail.GetRowCellValue(i, colBillId).ToString();
                filter += billId + ",";
            }
            filter += "-1";

            string sql = @"select v.cVenCode , I.cInvCode ,sum(b.BackQty) as BackQty
                        from    UFDLImport.dbo.Bac_OMBack B
                                left join OM_MODetails D on B.OMDId = d.MODetailsID
                                left join dbo.OM_MOMain M on d.MOID = m.MOID
                                left join dbo.Vendor V on M.cVenCode = V.cVenCode
                                left join dbo.Inventory I on D.cInvCode = I.cInvCode
                        where   b.BillID in ({0})
                        group by v.cVenCode , I.cInvCode ";

            sql = string.Format(sql, filter);
            DataTable dt = SqlHelper.ExecuteDataset(Assistanter.U8ConnectString, CommandType.Text, sql).Tables[0];

            if (dt.Rows.Count == 0)
            {
                return;
            }

            SqlConnection conn = new SqlConnection(Assistanter.U8ConnectString);

            conn.Open();
            SqlTransaction trans    = conn.BeginTransaction();
            string         deptCode = "";

            int fatherId = 0;
            int childId  = 0;

            string[] u8DBArrs = FrameBaseFunction.ClsBaseDataInfo.sUFDataBaseName.Split('_');
            string   accId    = u8DBArrs [1];

            Assistanter.GetIndentityId(Assistanter.U8ConnectString, accId, "rd", dt.Rows.Count, out fatherId, out childId);
            DateTime serverTime = Assistanter.GetServerTime();

            try
            {
                string cCode = Assistanter.GetVouchNumber("0412", "日期", "月", "yyyyMM", 5);

                sql = @"
                            insert into dbo.RdRecord 
                                    ( 
                                    ID,
                                    bRdFlag,
                                    cVouchType,
                                    cBusType,
                                    cSource,
                                    cWhCode,
                                    dDate,
                                    cRdCode,
                                    cMaker,
                                    bpufirst,
                                    biafirst,
                                    VT_ID,
                                    bIsSTQc,
                                    bOMFirst,
                                    bIsComplement,
                                    iswfcontrolled,
                                    cDepCode,
                                    dnmaketime,
                                    cMemo,
                                    bmotran,
                                    cCode
                                    )
                            values  (
		                            '{0}',
                                     0,--bRdFlag,
                                    '11',--cVouchType,
                                    '领料',--cBusType,
                                    '库存',--cSource,
                                    '{6}',--cWhCode,
                                    '{1}',    --dDate,
                                    '21',--cRdCode,
                                    '{2}',--cMaker,
                                    0,--bpufirst,
                                    0,--biafirst,
                                    30768,--VT_ID,
                                    0,--bIsSTQc,
                                    0,--bOMFirst,
                                    0,--bIsComplement,
                                    0,--iswfcontrolled,
                                    null,--cDepCode,
                                    getdate(),--dnmaketime,
                                    '{4}',--cMemo,
                                    0,--bmotran
                                    '{5}'
                    )";
                sql = string.Format(sql,
                                    fatherId,
                                    serverTime.ToString("yyyy-MM-dd"),
                                    FrameBaseFunction.ClsBaseDataInfo.sUid,
                                    deptCode,
                                    "",
                                    cCode,
                                    whCode
                                    );

                SqlHelper.ExecuteNonQuery(trans, CommandType.Text, sql);

                int loop = 1;
                foreach (DataRow row in dt.Rows)
                {
                    int currChildId = childId - (dt.Rows.Count - loop);
                    loop++;
                    string invCode = row["cInvCode"].ToString();
                    string qty     = row["BackQty"].ToString();
                    sql = @"
                        insert into dbo.RdRecords 
                        ( 
	                        AutoID ,
	                        ID ,
	                        cInvCode ,
	                        iNum ,
	                        iQuantity ,
	                        iUnitCost ,
	                        iPrice ,
	                        iPUnitCost,
	                        iPPrice
                        )
                        values  (
	                        {0},--AutoID ,
	                        {1},--ID ,
	                        '{2}',--cInvCode ,
	                        {3},--iNum ,
	                        0-{4},--iQuantity ,
	                        {5},--iUnitCost ,
	                        {6},--iPrice ,
	                        {7},--iPUnitCost,
	                        {8}--iPPrice 
                    )
                    ";
                    sql = string.Format(sql,
                                        currChildId,
                                        fatherId,
                                        invCode,
                                        "0",
                                        qty,
                                        "0",
                                        "0",
                                        "0",
                                        "0");
                    SqlHelper.ExecuteNonQuery(trans, CommandType.Text, sql);


                    sql = "if exists(select * from  CurrentStock where cInvCode = '" + invCode + "' and cWhCode = '" + whCode + "') " +
                          "	update  CurrentStock set iQuantity = isnull(iQuantity,0) + " + qty + "  where cInvCode = '" + invCode + "' and cWhCode = '" + whCode + "' " +
                          "else " +
                          "begin " +
                          "    declare @itemid varchar(20); " +
                          "declare @iCount int;  " +
                          "select @iCount=count(itemid) from CurrentStock where cInvCode = '" + invCode + "';   " +
                          "if( @iCount > 0 ) " +
                          "	select @itemid=itemid from CurrentStock where cInvCode = '" + invCode + "';  " +
                          "else  " +
                          "	 select @itemid=max(itemid+1) from CurrentStock  " +
                          "    insert into CurrentStock(cWhCode,cInvCode,iQuantity,itemid)values('" + whCode + "','" + invCode + "'," + qty + ",@itemid) " +
                          "end";
                    SqlHelper.ExecuteNonQuery(trans, CommandType.Text, sql);
                }

                sql = "update dbo.Bac_OMBack  set IsGenRdForm =1 where BillID in ({0})";
                sql = string.Format(sql, filter);
                clsSQLCommond.ExecSql(sql);
                trans.Commit();
                DTSource.Clear();
                grdDetail.DataSource = DTSource;
                MessageBox.Show("完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception error)
            {
                trans.Rollback();
                MessageBox.Show("发生错误:\n" + error.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            trans = null;
            conn.Close();
            conn = null;
        }
예제 #13
0
 public ClsRoleInfoQuery()
 {
     clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
 }
예제 #14
0
 public ClsBuckUpDataBase()
 {
     clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
 }
예제 #15
0
 public ClsUserEditQuery()
 {
     clsSQLCommond = FrameBaseFunction.ClsDataBaseFactory.Instance();
 }