Example #1
0
File: w_Jb.cs Project: sosgzj/Gtcs
        private void button1_Click(object sender, EventArgs e)
        {
            int       i_count = 0;
            Gtsql     r1      = new Gtsql();
            DataTable d1      = new DataTable();

            i_count = Gt.GetBc(Global.s_dh, label2.Text);
            if (i_count > 0)  //有交班
            {
                if (i_count != int.Parse(comboBox1.Text))
                {
                    MessageBox.Show("请选择原来的班次: " + i_count.ToString() + " 交班");
                    return;
                }
            }

            String str = "update t_pos_bill set jbdate ='" + label2.Text + "'" + ",bc='" + comboBox1.Text + "' where bc = 0";

            i_count = r1.ExecuteUpdate(str);
            if (i_count >= 1)
            {
                MessageBox.Show("交班成功!");
                this.Close();
            }
            else
            {
                MessageBox.Show("交班不成功!");
            }
        }
Example #2
0
File: Gt.cs Project: sosgzj/Gtcs
        public static string GetListno(int i_set)  //返回流水号 0不更新 1更新
        {
            DateTime dt = Gt.GetStime();
            String   str;
            long     l_listno = 0;
            string   s_listno;
            int      i_flag = 0;

            if (int.Parse(dt.Hour.ToString()) > 6)
            {
                str = "SELECT listno FROM t_pos_bill_number WITH ( TABLOCKX ) where listdate ='" + dt.Date + "'";
                Gtsql     r1 = new Gtsql();
                DataTable d1 = new DataTable();
                d1 = r1.ExecuteQuery(str);
                if (d1 != null && d1.Rows.Count > 0)
                {
                    l_listno = long.Parse(d1.Rows[0]["listno"].ToString());
                    i_flag   = 1;
                }
            }
            else
            {
                str = "select listno from t_pos_bill_number with(tablockx)";
                Gtsql     r1 = new Gtsql();
                DataTable d1 = new DataTable();
                d1 = r1.ExecuteQuery(str);
                if (d1 != null && d1.Rows.Count > 0)
                {
                    l_listno = long.Parse(d1.Rows[0]["listno"].ToString());
                    dt       = dt.AddDays(-1);
                    i_flag   = 1;
                }
            }
            if (i_set == 1)
            {
                if (i_flag == 1)
                {
                    l_listno++;
                    str = "update t_pos_bill_number set listno ='" + l_listno + "'";
                    Gtsql r2 = new Gtsql();
                    r2.ExecuteUpdate(str);
                }
                else
                {
                    l_listno = 1;
                    str      = "update t_pos_bill_number set listno ='" + l_listno + "'" + "," + "listdate = '" + dt.Date + "'";
                    Gtsql r3 = new Gtsql();
                    r3.ExecuteUpdate(str);
                }
            }
            else
            {
                if (i_flag == 1)
                {
                    l_listno++;
                }
                else
                {
                    l_listno = 1;
                }
            }

            s_listno = dt.ToString("MMdd") + "-" + l_listno.ToString("d3");
            return(s_listno);
        }
Example #3
0
        protected void Cash()
        {
            String s_dh = "", s_mc = "", s_cash = "0.0", s_vip = "0.0", s_hlq = "0.0", s_wx = "0.0", s_zfb = "0.0", s_bf_consume_dh, s_rec_key;
            string s_cardtxt = "";
            int    i_flag    = 0;

            if (tbZL.Text.Trim() == "")
            {
                tbZL.Text = string.Format("{0:F2}", (double.Parse(tbSSJE.Text.Trim()) - double.Parse(tbYS.Text.Trim())));
            }
            else
            {
                w_Main       frmP = (w_Main)this.Owner;
                DataGridView dgv  = (DataGridView)frmP.Controls.Find("dGV", true)[0];
                //消费总记录
                //insert into t_pos_bill(dh, mc, bf_consume_dh, total_cost, cash, djq, hy_card, hlq, dh_who_receive, mc_who_receive, rec_key, bc, carddh, dz_ratio, dz_cost, cardvalue)
                //values(:s_dh,:s_mc,:s_bf_consume_dh,:c_last,:c_xian,:c_djq,:c_card,:c_hlq,:s_user.dh,:s_user.xm,:s_rec_key, 0,:s_card.dh,:s_card.zl,:c_djq,:s_card.je) using sqlca;

                s_dh = Global.s_fh;
                if ((s_dh == "") || (s_dh == null))
                {
                    s_dh = "K000";
                }


                s_mc            = Gt.GetListno(1);
                s_bf_consume_dh = s_dh + Gt.GetStime().ToString("yyyyMMddHHmmssfff");

                s_cash = dataGridView2.Rows[0].Cells[1].Value.ToString();
                s_vip  = dataGridView2.Rows[1].Cells[1].Value.ToString();
                s_hlq  = dataGridView2.Rows[2].Cells[1].Value.ToString();
                s_wx   = dataGridView2.Rows[3].Cells[1].Value.ToString();
                s_zfb  = dataGridView2.Rows[4].Cells[1].Value.ToString();

                s_rec_key = "CS" + Gt.GetStime().ToString("yyMMddHHmmssfff");//超市与包房识别号

                String str1 = "insert into t_pos_bill(dh,mc,bf_consume_dh,total_cost,cash,hy_card,hlq,wx,zfb,dh_who_receive, mc_who_receive,rec_key,bc,carddh,dz_ratio,dz_cost,cardvalue) values('" + s_dh + "','" + s_mc + "','" + s_bf_consume_dh + "','" + tbYS.Text + "','" + s_cash
                              + "','" + s_vip + "','" + s_hlq + "','" + s_wx + "','" + s_zfb + "','" + Global.s_dh + "','" + Global.s_xm + "','" + s_rec_key + "','" + "0"
                              + "','" + Global.s_vip + "','" + Gt.GetVipinfo(Global.s_vip, 1) + "','" + s_vip + "','" + Gt.GetVipinfo(Global.s_vip, 2)
                              + "')";

                Gtsql r1 = new Gtsql();   //我写的那个用来连接数据库的类是ResM,所以用其创建对象;
                i_flag = r1.ExecuteUpdate(str1);
                if (i_flag == 0)
                {
                    //执行成功
                }
                //添加详单	insert into t_cp_yd(dh,mc,xldh,xlmc,cpdh,cpmc,fastdh,unit,unitprice,nowprice,isnow,is_dz,dzbl,kedian,qy,je,bfdh,is_free,printdh,printname,sequen_kf,rec_key,share_ratio,is_stock,dhid,in_price,printed,is_tc)
                //select dh, mc, xldh, xlmc, cpdh, cpmc, fastdh, unit, unitprice, nowprice,:i_isnow,is_dz,dzbl,kedian,:c_qy,:c_je,:sle_bf.text,:i_isfree,printdh,printname,:s_bf_consume_dh,:s_rec_key,share_ratio,is_stock,dhid,in_price,1,:i_istc from t_cp
                //         where cpdh = :s_cpdh using sqlca;

                for (int i = 0; i < dgv.RowCount; i++)
                {
                    //添加销售记录
                    string s_cpdh = dgv.Rows[i].Cells[0].Value.ToString();
                    string s_qy   = dgv.Rows[i].Cells[3].Value.ToString();
                    string s_je   = dgv.Rows[i].Cells[4].Value.ToString();
                    string i_istc = dgv.Rows[i].Cells[5].Value.ToString();

                    String str2 = "insert into t_cp_yd(dh,mc,xldh,xlmc,cpdh,cpmc,fastdh,unit,unitprice,nowprice,qy,je,bfdh,sequen_kf,rec_key,is_tc)"
                                  + " select dh,mc,xldh,xlmc,cpdh,cpmc,fastdh,unit,unitprice,nowprice,'" + s_qy + "','" + s_je + "','" + s_dh + "','" + s_bf_consume_dh + "','" + s_rec_key + "','" + i_istc + "'" + " from t_cp" + " where cpdh = '" + s_cpdh + "'";
                    Gtsql r2 = new Gtsql();
                    i_flag = r2.ExecuteUpdate(str2);
                }
                // 扣会员卡款
                if (Global.s_vip != null)
                {
                    int i_Vipflag;
                    i_Vipflag = Gt.UpdateVip(Global.s_vip, decimal.Parse(s_vip), s_rec_key, 3, "消费");

                    if (i_Vipflag == 1)
                    {
                        s_cardtxt = "会员卡:" + Global.s_vip + "  扣款前:" + Global.d_svipje.ToString("F1") + "\n扣款后:" + (Global.d_svipje - decimal.Parse(s_vip)).ToString("F1");
                        MessageBox.Show(s_cardtxt, "会员卡扣款", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("会员卡扣款失败!");
                    }
                }


                String str3       = "SELECT cpmc, qy,unitprice,je FROM t_cp_yd WHERE  rec_key ='" + s_rec_key + "'";
                String s_sumjetxt = "select cash,hy_card,hlq,wx,zfb from t_pos_bill where rec_key='" + s_rec_key + "'";

                Gtsql     r3       = new Gtsql();
                DataTable d3       = new DataTable();
                string    s_Height = "65";
                d3 = r3.ExecuteQuery(str3);          //使用ExecuteQuery()执行sql语句;
                if (d3 != null && d3.Rows.Count > 0)
                {
                    s_Height = (Convert.ToUInt32(d3.Rows.Count * 7.5) + 85).ToString();
                }
                // 报表路径
                string path   = Application.StartupPath + "\\Report\\Report_mx.frx";
                Report report = new Report();

                report.Load(path);
                report.SetParameterValue("s_xm", Global.s_xm);
                report.SetParameterValue("s_posdate", Gt.GetStime().ToString("yy/MM/dd hh:mm"));
                report.SetParameterValue("s_mc", s_mc);
                report.SetParameterValue("s_dh", s_dh);
                report.SetParameterValue("s_Height", s_Height);

                report.SetParameterValue("s_sumje", Gt.Getjetxt(s_sumjetxt));
                report.SetParameterValue("s_card", s_cardtxt);


                report.RegisterData(d3, "t_cp_yd");

                eSet.ReportSettings.ShowProgress = false;

                report.PrintSettings.ShowDialog = false;


                report.Print();

                //    //减少货物质量
                //    bGoods.UpdateCount(int.Parse(dgv.Rows[i].Cells[3].Value.ToString()), dgv.Rows[i].Cells[0].Value.ToString());
                //}

                frmP.ClearForm();
                frmP.showPre();
                this.Close();
            }
        }