Пример #1
0
        private void btnexport_Click(object sender, EventArgs e)
        {
            try
            {
                string strSQL   = "";
                string BWB      = "人民币";
                string JHDH     = "";
                string JHDH_old = "";

                this.Cursor = Cursors.WaitCursor;
                U8Login.clsLogin u8Login = null;
                u8Login = APIinterface.GetU8Login();
                if (u8Login == null)
                {
                    MessageBox.Show("登陆错误:U8登陆失败,检查是否配置正确", "提示", MessageBoxButtons.OK);
                    return;
                }
                cxdb.DefaultView.Sort = "JHDH ASC";
                DataTable dt     = cxdb.DefaultView.ToTable();
                string    strMsg = "";
                string    ddh    = "";
                string    result = "";
                int       count  = 0;
                string    YYBM   = "";
                string    pdbm   = "";
                string    pdbm_O = "";
                if (dt.Rows.Count > 0)
                {
                    for (int j = 0; j < dt.Rows.Count; j++)
                    {
                        count = 0;

                        //if (ClsSystem.gnvl(this.dgv2.Rows[j].Cells["check"].Value, "").ToUpper() == "TRUE")
                        //{
                        JHDH = ClsSystem.gnvl(dt.Rows[j]["JHDH"], "");
                        YYBM = ClsSystem.gnvl(dt.Rows[j]["YYBM"], "");
                        pdbm = YYBM + "-" + JHDH;
                        if (pdbm != pdbm_O)
                        {
                            count = Convert.ToInt16(SqlAccess.ExecuteScalar(" select count(ID)   from so_somain with(nolock) where    cdefine14  ='" + pdbm + "'", Program.ConnectionString));
                            if (count < 1)
                            {
                                strMsg = APIinterface.InSO(u8Login, BWB, dt, j);
                                if (strMsg.IndexOf("错误") > 0)
                                {
                                    MessageBox.Show(strMsg, "提示", MessageBoxButtons.OK);
                                    this.Cursor = Cursors.Default;
                                    return;
                                }
                                else
                                {
                                    ddh    = ClsSystem.gnvl(SqlAccess.ExecuteScalar("select csocode from SO_SOMain with(nolock) where ID =" + strMsg, Program.ConnectionString), "");
                                    result = result + ddh + ",";
                                }
                            }
                            //else
                            //{
                            //    MessageBox.Show("计划单号:" + JHDH + "已经生成销售订单", "提示", MessageBoxButtons.OK);
                            //    return;
                            //}
                        }
                        //  }
                        pdbm_O = YYBM + "-" + JHDH;
                    }
                }

                this.Cursor = Cursors.Default;

                if (result != "")
                {
                    MessageBox.Show("生成销售订单成功:" + result, "提示", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    MessageBox.Show("无销售订单成功", "提示", MessageBoxButtons.OK);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("生成失败", "提示", MessageBoxButtons.OK);
                this.Cursor = Cursors.Default;
                return;
            }
        }
Пример #2
0
        private void btnexport_Click(object sender, EventArgs e)
        {
            try
            {
                string strSQL = "";
                string BWB    = "人民币";


                this.Cursor = Cursors.WaitCursor;
                U8Login.clsLogin u8Login = null;
                u8Login = APIinterface.GetU8Login();
                if (u8Login == null)
                {
                    MessageBox.Show("登陆错误:U8登陆失败,检查是否配置正确", "提示", MessageBoxButtons.OK);
                    return;
                }

                //cxdb.DefaultView.Sort = "JHDH ASC";
                //DataTable dt = cxdb.DefaultView.ToTable();
                string strMsg = "";
                string ddh    = "";
                string result = "";
                int    count  = 0;
                string YYBM   = "";
                string DDMXBH = "";
                string PSDBM  = "";
                string sql    = "";

                string    strrq  = "";
                string    strsj  = "";
                string    pdbm   = "";
                string    pdbm_O = "";
                string    DDTJRQ = "";
                DataTable dt     = new DataTable();
                dt = cxdb;


                if (dt.Rows.Count > 0)
                {
                    dt.Columns.Add("Uflag");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        if (ClsSystem.gnvl(this.dgv2.Rows[i].Cells["check"].Value, "").ToUpper() == "TRUE")
                        {
                            YYBM   = ClsSystem.gnvl(dt.Rows[i]["YYBM"], "");
                            PSDBM  = ClsSystem.gnvl(dt.Rows[i]["PSDBM"], "");
                            DDMXBH = ClsSystem.gnvl(dt.Rows[i]["DDMXBH"], "");
                            sql    = @" select  count(autoid)   from SO_SODetails  sd  with(nolock) left join so_somain so with(nolock) on sd.id=so.id " +
                                     " where so.cdefine11='" + YYBM + "' and sd.cdefine32='" + PSDBM + "' and sd.cdefine29='" + DDMXBH + "'";
                            count = Convert.ToInt16(SqlAccess.ExecuteScalar(sql, Program.ConnectionString));
                            if (count < 1)
                            {
                                dt.Rows[i]["Uflag"] = "1";
                            }
                            strrq = ClsSystem.gnvl(Public.GetInfo("/", ClsSystem.gnvl(dt.Rows[i]["DDTJRQ"], ""), 1), "");
                            strsj = ClsSystem.gnvl(Public.GetInfo("/", ClsSystem.gnvl(dt.Rows[i]["DDTJRQ"], ""), 2), "");
                            dt.Rows[i]["DDTJRQ"] = strrq + strsj;
                        }
                    }

                    dt.DefaultView.Sort = "YYBM ASC,PSDBM ASC,DDTJRQ ASC";
                    DataTable db = dt.DefaultView.ToTable();

                    DataView rowfilter = new DataView(db);
                    rowfilter.RowFilter      = "Uflag= '1'";
                    rowfilter.RowStateFilter = DataViewRowState.CurrentRows;
                    DataTable dts = rowfilter.ToTable();

                    for (int j = 0; j < dts.Rows.Count; j++)
                    {
                        YYBM   = ClsSystem.gnvl(dts.Rows[j]["YYBM"], "");
                        PSDBM  = ClsSystem.gnvl(dts.Rows[j]["PSDBM"], "");
                        DDTJRQ = ClsSystem.gnvl(dts.Rows[j]["DDTJRQ"], "");
                        pdbm   = YYBM + "-" + PSDBM + "-" + DDTJRQ;
                        if (pdbm != pdbm_O)
                        {
                            strMsg = APIinterface.InSO(u8Login, BWB, dts, j);
                            if (strMsg.IndexOf("错误") > 0)
                            {
                                MessageBox.Show(strMsg, "提示", MessageBoxButtons.OK);
                                this.Cursor = Cursors.Default;
                                return;
                            }
                            else
                            {
                                ddh    = ClsSystem.gnvl(SqlAccess.ExecuteScalar("select csocode from SO_SOMain with(nolock) where ID =" + strMsg, Program.ConnectionString), "");
                                result = result + ddh + ",";
                            }
                        }
                        pdbm_O = YYBM + "-" + PSDBM + "-" + DDTJRQ;
                    }
                }

                this.Cursor = Cursors.Default;

                if (result != "")
                {
                    MessageBox.Show("生成销售订单成功:" + result, "提示", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    MessageBox.Show("无销售订单", "提示", MessageBoxButtons.OK);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("生成失败", "提示", MessageBoxButtons.OK);
                this.Cursor = Cursors.Default;
                return;
            }
        }