Esempio n. 1
0
        private void dgv2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            int              i             = e.RowIndex;
            string           sql           = "";
            DataGridViewCell dgc           = dgv2.CurrentCell;
            decimal          iTaxUnitPrice = 0;
            decimal          iDisRate      = 0;

            if (dgc.OwningColumn.Name == "ZXSPBM")
            {
                frmQueryYP HW = new frmQueryYP();
                //frmQueryHW.strmdcode = mdcode;

                HW.ShowDialog();

                if (frmQueryYP.hwID != "")
                {
                    this.dgv2.Rows[i].Cells["xh"].Value     = dgv2.Rows.Count + 1;
                    this.dgv2.Rows[i].Cells["ZXSPBM"].Value = frmQueryYP.hwID;
                    this.dgv2.Rows[i].Cells["YQBM"].Value   = "ZDYC0001";
                    sql = @"select  c.cComUnitName from inventory inv left join ComputationUnit  c on c.cComunitCode =inv.cComunitCode  where inv.cInvCode='" + frmQueryYP.hwCode + "'";
                    this.dgv2.Rows[i].Cells["CGJLDW"].Value = ClsSystem.gnvl(SqlAccess.ExecuteScalar(sql, Program.ConnectionString), "");
                }
            }
        }
Esempio n. 2
0
        public static bool GetPass(string caccid, string ddate)
        {
            string   sql     = "";
            DateTime dt1     = DateTime.Now;
            DateTime dt2     = Convert.ToDateTime(ddate);
            TimeSpan span    = dt1.Subtract(dt2);
            int      dayDiff = span.Days + 1;

            if (dayDiff >= 30)
            {
                sql = @" update UA_Account_Ex set cFinKind='2' where cAcc_Id='" + caccid + "'";
                SqlAccess.ExecuteSql(sql, Program.ConnectionString);
            }

            sql = @" select cFinKind from UA_Account_Ex where cAcc_Id='" + caccid + "'";
            string result = ClsSystem.gnvl(SqlAccess.ExecuteScalar(sql, Program.ConnectionString), "");

            if (result == "2")
            {
                return(true);
            }
            return(false);
        }
Esempio n. 3
0
        private void button6_Click(object sender, EventArgs e)
        {
            string sql = "";

            try
            {
                dgv2.EndEdit();
                sql = BuildSqlSelect();

                this.Cursor = Cursors.WaitCursor;
                if (dgv2.Rows.Count > 0)
                {
                    dgv2.Rows.Clear();
                }
                DataSet ds = new DataSet();
                if (ClsSystem.gnvl(sql, "") != "")
                {
                    string resultXml = SendMessage.SetMessage("YQ010", sql);

                    string result = SendMessage.ReadXMl(resultXml, "HEAD", "ZTCLJG");

                    if (result == "00000")
                    {
                        TextReader tdr = new StringReader(resultXml);
                        ds.ReadXml(tdr);
                        result = "";
                        result = SendMessage.ReadXMl(resultXml, "MAIN", "JLS");
                        if (Public.GetNum(result) > 0)
                        {
                            DataTable db = ds.Tables[3];

                            //dt.DefaultView.Sort = "JHDH ASC";
                            //DataTable db  = dt.DefaultView.ToTable();
                            cxdb = db;


                            if (db.Rows.Count > 0)
                            {
                                for (int i = 0; i < db.Rows.Count; i++)
                                {
                                    dgv2.Rows.Add();

                                    dgv2.Rows[i].Cells["SFWJ"].Value   = ClsSystem.gnvl(ds.Tables[1].Rows[0]["SFWJ"], "");
                                    dgv2.Rows[i].Cells["JLS"].Value    = ClsSystem.gnvl(ds.Tables[1].Rows[0]["JLS"], "");
                                    dgv2.Rows[i].Cells["DDMXBH"].Value = ClsSystem.gnvl(db.Rows[i]["DDMXBH"], "");
                                    dgv2.Rows[i].Cells["JHDH"].Value   = ClsSystem.gnvl(db.Rows[i]["JHDH"], "");
                                    dgv2.Rows[i].Cells["YQBM"].Value   = ClsSystem.gnvl(db.Rows[i]["YQBM"], "");

                                    dgv2.Rows[i].Cells["YYBM"].Value  = ClsSystem.gnvl(db.Rows[i]["YYBM"], "");
                                    dgv2.Rows[i].Cells["YYMC"].Value  = ClsSystem.gnvl(SqlAccess.ExecuteScalar("select cus.cCusName from Customer_extradefine  ex join Customer cus on cus.cCusCode=ex.cCusCode where ex.ccdefine1='" + ClsSystem.gnvl(db.Rows[i]["YYBM"], "") + "'", Program.ConnectionString), "");
                                    dgv2.Rows[i].Cells["PSDBM"].Value = ClsSystem.gnvl(db.Rows[i]["PSDBM"], "");
                                    dgv2.Rows[i].Cells["PSDZ"].Value  = ClsSystem.gnvl(db.Rows[i]["PSDZ"], "");
                                    dgv2.Rows[i].Cells["CGLX"].Value  = ClsSystem.gnvl(SqlAccess.ExecuteScalar("select cgmc from ysxt_CGMS  with(nolock) where cgbm='" + ClsSystem.gnvl(db.Rows[i]["CGLX"], "") + "'", Program.ConnectionString), "");
                                    if (ClsSystem.gnvl(db.Rows[i]["DDLX"], "") == "1")
                                    {
                                        dgv2.Rows[i].Cells["DDLX"].Value = "医院自行订单";
                                    }
                                    else
                                    {
                                        dgv2.Rows[i].Cells["DDLX"].Value = "托管药库订单";
                                    }
                                    if (ClsSystem.gnvl(db.Rows[i]["SPLX"], "") == "1")
                                    {
                                        dgv2.Rows[i].Cells["SPLX"].Value = "药品类";
                                    }
                                    else if (ClsSystem.gnvl(db.Rows[i]["SPLX"], "") == "2")
                                    {
                                        dgv2.Rows[i].Cells["SPLX"].Value = "医用耗材器械类";
                                    }
                                    else
                                    {
                                        dgv2.Rows[i].Cells["SPLX"].Value = "其他";
                                    }
                                    dgv2.Rows[i].Cells["YPLX"].Value   = ClsSystem.gnvl(SqlAccess.ExecuteScalar("select ypjxmc from ysxt_Ypjx  with(nolock) where ypjxbm='" + ClsSystem.gnvl(db.Rows[i]["YPLX"], "") + "'", Program.ConnectionString), "");
                                    dgv2.Rows[i].Cells["ZXSPBM"].Value = ClsSystem.gnvl(db.Rows[i]["ZXSPBM"], "");
                                    dgv2.Rows[i].Cells["CPM"].Value    = ClsSystem.gnvl(db.Rows[i]["CPM"], "");
                                    dgv2.Rows[i].Cells["YPJX"].Value   = ClsSystem.gnvl(db.Rows[i]["YPJX"], "");

                                    dgv2.Rows[i].Cells["CFGG"].Value = ClsSystem.gnvl(db.Rows[i]["CFGG"], "");

                                    dgv2.Rows[i].Cells["YYDWMC"].Value = ClsSystem.gnvl(db.Rows[i]["YYDWMC"], "");
                                    dgv2.Rows[i].Cells["BZNHSL"].Value = ClsSystem.gnvl(db.Rows[i]["BZNHSL"], "");
                                    dgv2.Rows[i].Cells["SCQYMC"].Value = ClsSystem.gnvl(db.Rows[i]["SCQYMC"], "");
                                    dgv2.Rows[i].Cells["CGJLDW"].Value = ClsSystem.gnvl(db.Rows[i]["CGJLDW"], "");
                                    dgv2.Rows[i].Cells["CGSL"].Value   = ClsSystem.gnvl(db.Rows[i]["CGSL"], "");
                                    //  dgv2.Rows[i].Cells["DCPSBZ"].Value = ClsSystem.gnvl(db.Rows[i]["DCPSBZ"], "");
                                    if (ClsSystem.gnvl(db.Rows[i]["DDTJFS"], "") == "1")
                                    {
                                        dgv2.Rows[i].Cells["DDTJFS"].Value = "医院填报";
                                    }
                                    else
                                    {
                                        dgv2.Rows[i].Cells["DDTJFS"].Value = "药企代填";
                                    }
                                    dgv2.Rows[i].Cells["DDCLZT"].Value = ClsSystem.gnvl(SqlAccess.ExecuteScalar("select mc from ysxt_ddclzt  with(nolock) where bm='" + ClsSystem.gnvl(db.Rows[i]["DDCLZT"], "") + "'", Program.ConnectionString), "");

                                    dgv2.Rows[i].Cells["DDTJRQ"].Value = ClsSystem.gnvl(db.Rows[i]["DDTJRQ"], "");
                                    dgv2.Rows[i].Cells["BZSM"].Value   = ClsSystem.gnvl(db.Rows[i]["BZSM"], "");
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("未查到订单记录", "错误", MessageBoxButtons.OK);
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("处理结果:" + result + ClsSystem.gnvl(ds.Tables[0].Rows[0]["CWXX"], ""), "错误", MessageBoxButtons.OK);
                        return;
                    }
                }


                this.Cursor = Cursors.Default;
                //      MessageBox.Show("未上传的存货查询完成", "提示", MessageBoxButtons.OK);
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(ex.Message.ToString(), "错误", MessageBoxButtons.OK);
                return;
            }
        }
Esempio n. 4
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;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 生成保存dgv的语句
        /// </summary>
        /// <param name="dgv"></param>
        /// <param name="tbName">表名</param>
        /// <param name="conn">连接</param>
        /// <returns></returns>
        public static string GetUpdateStr(DataGridView dgv, string tbName, SqlConnection conn)
        {
            string strPKName = dgv.Columns[0].Name;
            string strPKCode = "";
            //SqlCommand sqlcmd = null;
            string strSql    = "";
            string strInsert = "insert into " + tbName + " (";

            //生成插入语句前半部分
            for (int i = 1; i < dgv.ColumnCount; i++)
            {
                if (Convert.ToString(dgv.Columns[i].DataPropertyName) == "")
                {
                    continue;
                }
                strInsert += dgv.Columns[i].Name + ",";
            }
            strInsert = strInsert.Substring(0, strInsert.Length - 1);
            strInsert = strInsert + ") values (";

            for (int i = 0; i < dgv.Rows.Count; i++)
            {
                strPKCode = Convert.ToString(dgv.Rows[i].Cells[strPKName].Value);
                //strPKCode = dgv.Rows[i].Cells[strPKName].Value == null ? null : dgv.Rows[i].Cells[strPKName].Value.ToString();
                //sqlcmd = new SqlCommand(string.Format("select {0} from {1} where {2} = '{3}'", strPKName, tbName, strPKName, strPKCode), conn);
                //object o = sqlcmd.ExecuteScalar();
                //if (o != null && o != System.DBNull.Value && o.ToString() != "")//update
                if (Convert.ToInt32(SqlAccess.ExecuteScalar("select " + strPKName + " from " + tbName + " where " + strPKName + " = N'" + strPKCode + "'", conn)) > 0)
                {
                    strSql = strSql + string.Format("update {0} set ", tbName);
                    for (int j = 1; j < dgv.ColumnCount; j++)
                    {
                        if (Convert.ToString(dgv.Columns[j].DataPropertyName) == "")
                        {
                            continue;
                        }

                        strSql = strSql + dgv.Columns[j].Name + " = " + Public.SqlParm(dgv.Rows[i].Cells[j].Value) + ",";
                    }
                    strSql = strSql.Substring(0, strSql.Length - 1);
                    strSql = strSql + string.Format(" where {0} = N'{1}'\n", strPKName, strPKCode);
                }
                else//insert
                {
                    strSql = strSql + strInsert;
                    for (int j = 1; j < dgv.ColumnCount; j++)
                    {
                        if (Convert.ToString(dgv.Columns[j].DataPropertyName) == "")
                        {
                            continue;
                        }

                        strSql = strSql + Public.SqlParm(dgv.Rows[i].Cells[j].Value) + ",";
                    }
                    strSql = strSql.Substring(0, strSql.Length - 1);
                    strSql = strSql + ")\n";
                }
            }
            //判断一下删除的
            DataTable dt = SqlAccess.ExecuteSqlDataTable("select " + strPKName + " from " + tbName, conn);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                strPKCode = Convert.ToString(dt.Rows[i][strPKName]);
                if (Public.FindDgvRow(dgv, new string[] { strPKName }, new string[] { strPKCode }, 0, dgv.Rows.Count) == -1)
                {
                    strSql += "delete from " + tbName + " where " + strPKName + " = " + Public.SqlParm(strPKCode) + "\n";
                }
            }
            return(strSql);
        }
Esempio n. 6
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;
            }
        }
Esempio n. 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            string    xmlData   = "";
            string    resultXMl = "";
            string    sql       = "";
            string    SBVID     = "";
            string    SBVID_o   = "";
            string    yybm      = "";
            string    yybm_O    = "";
            string    PSDBM     = "";
            string    PSDBM_O   = "";
            int       y         = 0;
            int       count     = 0;
            DataTable dts       = null;

            this.Cursor = Cursors.WaitCursor;
            decimal hsje = 0;

            if (dgv1.Rows.Count > 0)
            {
                if (dgv1.Rows.Count > 0)
                {
                    xmlData = "";
                    xmlData = xmlData + @"<?xml version=""1.0""  encoding=""utf-8""?>";
                    xmlData = xmlData + "<XMLDATA>";
                    xmlData = xmlData + "<HEAD>";
                    xmlData = xmlData + "<IP>" + SendMessage.GetIP() + "</IP> ";
                    xmlData = xmlData + "<MAC>" + SendMessage.GetMAC() + "</MAC> ";
                    xmlData = xmlData + "<BZXX></BZXX> ";
                    xmlData = xmlData + "</HEAD> ";
                    xmlData = xmlData + "<MAIN>";
                    xmlData = xmlData + "<YQBM>ZDYC0001</YQBM> ";
                    xmlData = xmlData + "<YYBM>" + ClsSystem.gnvl(dgv1.Rows[count].Cells["cdefine11"].Value, "") + "</YYBM> ";
                    xmlData = xmlData + "<FPH>" + ClsSystem.gnvl(dgv1.Rows[count].Cells["cSBVCode"].Value, "") + "</FPH> ";

                    xmlData = xmlData + "<FPHSZJE>" + ClsSystem.gnvl(SqlAccess.ExecuteScalar(" select isnull(sum(iSum),0) from SaleBillVouchs where  sbvid=" + ClsSystem.gnvl(dgv1.Rows[count].Cells["sbvid"].Value, ""), Program.ConnectionString), "") + "</FPHSZJE> ";
                    xmlData = xmlData + "</MAIN>";

                    xmlData = xmlData + "</XMLDATA>";
                }
                DataSet   ds        = new DataSet();
                DataTable db        = null;
                string    iDLsID    = "";
                string    CLJG      = "";
                string    resultXml = SendMessage.SetMessage("YQ016", xmlData);
                string    result    = SendMessage.ReadXMl(resultXml, "HEAD", "ZTCLJG");
                if (result == "00000")
                {
                    sql = " update SaleBillVouch set cdefine9='" + result + "' where cSBVCode='" + ClsSystem.gnvl(dgv1.Rows[count].Cells["cSBVCode"].Value, "") + "'\n";
                }
                else
                {
                    //TextReader tdr = new StringReader(resultXml);
                    //ds.ReadXml(tdr);

                    //if (ds.Tables.Count >= 4)
                    //{
                    //    db = ds.Tables[2];
                    //}
                    //CLJG = ClsSystem.gnvl(db.Rows[0]["CLJG"], "");
                    //string CLQKMS = ClsSystem.gnvl(db.Rows[0]["CLQKMS"], "");
                    //    dgv1.Rows[i].Cells["cdefine24"].Value = "错误编码:" + CLJG + "错误信息:" + CLQKMS;

                    string CWXX = SendMessage.ReadXMl(resultXml, "HEAD", "CWXX");
                    MessageBox.Show("错误编码:" + result + "错误信息:" + CWXX, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                    //MessageBox.Show("错误编码:" + ClsSystem.gnvl(ds.Tables[0].Rows[0]["ZTCLJG"], "") + "错误信息:" + ClsSystem.gnvl(ds.Tables[0].Rows[0]["CWXX"], ""), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //return;
                }
                SqlAccess.ExecuteSql(sql, Program.ConnectionString);

                this.Cursor = Cursors.Default;
            }
        }