Exemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (JMessages.Question(" آیا از ویرایش مبلغ پرداختی توزین مطمئن هستید ؟ ", "") != DialogResult.Yes)
            {
                return;
            }
            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);

            try
            {
                dbMain.setQuery(" Update BascolWeights set Pay_h= " + txtPrice.IntValue + " Where Code=" + _Code + " And UserPostCode=" + JMainFrame.CurrentPostCode);
                if (dbMain.Query_Execute() > 0)
                {
                    JMessages.Information(" تایید شد ", "");
                }
                else
                {
                    JMessages.Error(" خطا در ثبت ", "");
                }
            }
            finally
            {
                dbMain.Dispose();
            }
        }
Exemplo n.º 2
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            string Query = @" 
delete from BascolPlakTruck Where Code= " + _Code + @"
Insert into BascolPlakTruck Values ('" + lblPlok.Text + "'," + cmbTruck.SelectedValue.ToString() + ")";
            //JDataBase db = new JDataBase();
            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     db = tmpJTransferData.CreateConMainServer(false);

            try
            {
                db.setQuery(Query);
                if (db.Query_Execute() > 0)
                {
                    Fill();
                    JMessages.Confirm(" تایید شد ", "");
                }
                else
                {
                    JMessages.Error(" تایید نشد ", "");
                }
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
            }
            finally
            {
                db.Dispose();
            }
        }
Exemplo n.º 3
0
        public static DataTable GetBlackList(string pPlokno)
        {
            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);
            string        Where            = "";

            if (pPlokno != "")
            {
                Where = " Where (select top 1 plokno from BascolWeights where bascoolid=bascoolblacklist.bascoolid)=N'" + pPlokno + "'";
            }
            try
            {
                dbMain.setQuery(@" select 
bascoolid,
(select top 1 BascoolCode from BascolWeights where bascoolid=bascoolblacklist.bascoolid) BascoolCode,
(select top 1 plokno from BascolWeights where bascoolid=bascoolblacklist.bascoolid) plokno, 
(select top 1 (select Fa_Date from StaticDates where En_Date=cast(WDate as Date)) from BascolWeights where bascoolid=bascoolblacklist.bascoolid) WDate,
(select top 1 WTime from BascolWeights where bascoolid=bascoolblacklist.bascoolid) WTime,
(select top 1 name from clsPerson where Code=(select personcode from BascolWeights where bascoolid=bascoolblacklist.bascoolid)) name
from bascoolblacklist " + Where);
                //dbMain.CommandTimeout = 4;
                return(dbMain.Query_DataTable());
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(null);
            }
            finally
            {
                dbMain.Dispose();
            }
        }
Exemplo n.º 4
0
        public static DataTable GetDataMali(string pStr)
        {
            string        Query            = @" Select 
bascoolcode, 
(Select Name From clsAllPerson Where Code=PersonCode) Name,
Count(Code) Count,
SUM(printno) printno,
Round(sum(pay_h),0,0) pay_h,
Round(SUM(Pay),0,0) Pay,
Round(SUM(Duty),0,0) Duty,
Round(SUM(Tax),0,0) Tax,
Round(Round(SUM(Pay),0,0)- Round(SUM(Duty),0,0) - Round(SUM(Tax),0,0),0,0) Total 
from BascolWeights Where dele = 0 " + pStr + " Group by BascoolCode,PersonCode ";
            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);

            try
            {
                dbMain.setQuery(Query);
                return(dbMain.Query_DataTable());
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                dbMain.Dispose();
                return(null);
            }
            finally
            {
                dbMain.Dispose();
            }
        }
Exemplo n.º 5
0
        public static DataTable GetDataTop3(string pStr)
        {
            string        Query            = @" Select Top 3 Code,
BascoolCode,BascoolID,
(select Fa_Date from StaticDates where En_Date=Cast(WDate as Date)) 'WDate',
WTime,
PlokNo,
(Select Name From subdefine Where code=ProductCode) 'ProductName',
Weights,
(select Name from BascolTruck where code=TruckCode) 'TruckName',Pay_h    
from BascolWeights Where dele = 0 " + pStr + " order by WDate desc";
            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);

            //JDataBase db = new JDataBase();
            try
            {
                dbMain.setQuery(Query);
                return(dbMain.Query_DataTable());
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(null);
            }
            finally
            {
                dbMain.Dispose();
            }
        }
Exemplo n.º 6
0
        public static string GetBedehiName(string pPlokno)
        {
            string Bedehi = "";
            string Where  = " ";

            if (pPlokno != "")
            {
                Where = Where + " And PlokNo=N'" + pPlokno + "'";
            }
            string        Query            = @"Select ISNULL(STUFF((select '  و  ' + (Select fam From clsPerson Where Code=A.personcode)
  From
(
  SELECT personcode,
  (case  When (SUM(pay) - SUM(pay_h))>0 Then Sum(pay)-SUM(pay_h) ELSE 0 end)as debit,
  (case  When (SUM(pay) - SUM(pay_h)) < 0 Then SUM(pay_h) - SUM(pay) ELSE 0 end)as crdit,PlokNo  
  FROM BascolWeights  WHERE pay_h != pay And dele = 0 
  " + Where + @"
  GROUP BY PlokNo,personcode
   ) A Where (A.crdit <> A.debit )  FOR XML PATH('')), 1, 1, '' ),'') AS 'ListBedehkari'   ";
            JDataBase     db               = new JDataBase();
            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);

            try
            {
                db.setQuery(Query);
                if (db.Query_ExecutSacler() != null)
                {
                    Bedehi = db.Query_ExecutSacler().ToString();
                }
                if ((dbMain != null) && (Bedehi == ""))
                {
                    dbMain.setQuery(Query);
                    dbMain.CommandTimeout = 3;
                    object tmp = dbMain.Query_ExecutSacler();
                    if (tmp != null)
                    {
                        Bedehi = Bedehi + tmp.ToString();
                    }
                }
                return(Bedehi);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return("");
            }
            finally
            {
                db.Dispose();
                dbMain.Dispose();
            }
        }
Exemplo n.º 7
0
        public static int GetBedehi(string pPlokno, int pTruckCode)
        {
            int    Bedehi = 0;
            string Where  = " where 1=1 ";

            if (pPlokno != "")
            {
                Where = Where + " And PlokNo=N'" + pPlokno + "'";
            }
            //if (pTruckCode != 0)
            //    Where = Where + " And TruckCode=" + pTruckCode;
            string        Query            = @"select isnull(sum(pay) - Sum(pay_h),0) from BascolWeights " + Where;
            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);
            JDataBase     db = new JDataBase();

            try
            {
                db.setQuery(Query);
                Bedehi = Convert.ToInt32(db.Query_ExecutSacler());
                if (dbMain != null)
                {
                    dbMain.setQuery(Query);
                    dbMain.CommandTimeout = 3;
                    object tmp = dbMain.Query_ExecutSacler();
                    if (tmp != null)
                    {
                        Bedehi = Bedehi + Convert.ToInt32(tmp);
                    }
                }
                return(Bedehi);
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(0);
            }
            finally
            {
                db.Dispose();
                if (dbMain != null)
                {
                    dbMain.Dispose();
                }
            }
        }
Exemplo n.º 8
0
        public static DataTable GetDataBedehkari(string Str)
        {
//            string Query = @"
//Select * from
//(
//  SELECT clsAllPerson.Name,
//  (case  When (SUM(pay) - SUM(pay_h))>0 Then Sum(pay)-SUM(pay_h) ELSE 0 end)as debit,
//  (case  When (SUM(pay) - SUM(pay_h)) < 0 Then SUM(pay_h) - SUM(pay) ELSE 0 end)as crdit,PlokNo
//  FROM (BascolWeights INNER JOIN BascolTruck ON BascolWeights.TruckCode=BascolTruck.Code )
//  INNER JOIN clsAllPerson ON BascolWeights.PersonCode=clsAllPerson.code WHERE pay_h != pay And dele = 0
//" + Str  + @"
//  GROUP BY PlokNo,clsAllPerson.Name ) A Where (A.crdit <> A.debit )";

            string Query = @"
Select * from 
(
  SELECT clsPerson.Fam,
  (case  When (SUM(pay) - SUM(pay_h))>0 Then Sum(pay)-SUM(pay_h) ELSE 0 end)as debit,
  (case  When (SUM(pay) - SUM(pay_h)) < 0 Then SUM(pay_h) - SUM(pay) ELSE 0 end)as crdit,PlokNo,
  (Select Fa_Date From StaticDates where En_Date = cast(WDate as date))WDate,BascoolCode
  FROM BascolWeights 
  INNER JOIN clsPerson ON BascolWeights.PersonCode=clsPerson.code 
  WHERE pay_h != pay And dele = 0 " + Str + @"
  GROUP BY PlokNo,clsPerson.Fam ,WDate,BascoolCode 
  ) A Where (A.crdit <> A.debit )
  and ( select isnull(sum(pay) - Sum(pay_h),0) from BascolWeights where BascolWeights.PlokNo=A.PlokNo) <> 0";

            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);

            try
            {
                dbMain.setQuery(Query);
                return(dbMain.Query_DataTable());
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(null);
            }
            finally
            {
                dbMain.Dispose();
            }
        }
Exemplo n.º 9
0
        public static DataTable GetDataManager(string pStr)
        {
            string        Query            = @" Select 
(select Name from clsallperson where Code=PersonCode) 'PersonName',
BascoolCode,BascoolID,
(select Fa_Date from StaticDates where En_Date=Cast(WDate as Date)) 'WDate',
WTime,
PlokNo,
pay,verify,
dele,
(Select Name From subdefine Where code=ProductCode) 'ProductName',
(select Name from BascolTruck where code=TruckCode) 'TruckName',
Weights,
FullW,Code,
BascoolID BascoolID1,
PrintNo,
hamrahno,
pay_h,
Duty,
Tax,
(Select top 1 EmptyWeight from BascolEmptyWeights Where BascoolID=WeightID) FirstWeight,
Weights - (Select top 1 EmptyWeight from BascolEmptyWeights Where BascoolID=WeightID) Khales,
--(Select title from organizationchart where Code=UserPostCode) 'PostName',
UserPostCode,TruckCode   
from BascolWeights Where 1=1 " + pStr + "  order by  WDate,WTime Desc ";
            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);

            //JDataBase db = new JDataBase();
            try
            {
                dbMain.setQuery(Query);
                return(dbMain.Query_DataTable());
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(null);
            }
            finally
            {
                dbMain.Dispose();
            }
        }
Exemplo n.º 10
0
        public void DelBlackList(int pBascoolID)
        {
            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);

            try
            {
                dbMain.setQuery(" Delete From bascoolblacklist Where BascoolID=" + pBascoolID);
                if (dbMain.Query_Execute() > 0)
                {
                    JMessages.Information(" ماشین از لیست سیاه حذف شد ", "");
                }
                else
                {
                    JMessages.Error(" خطا در ثبت ", "");
                }
            }
            finally
            {
                dbMain.Dispose();
            }
        }
Exemplo n.º 11
0
        public void AddBlackList(int pBascoolID)
        {
            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);

            try
            {
                dbMain.setQuery(" Insert into bascoolblacklist values(" + pBascoolID + ")");
                if (dbMain.Query_Execute() > 0)
                {
                    JMessages.Information(" ماشین در لیست سیاه قرار گرفت ", "");
                }
                else
                {
                    JMessages.Error(" خطا در ثبت ", "");
                }
            }
            finally
            {
                dbMain.Dispose();
            }
        }
Exemplo n.º 12
0
        public static DataTable GetDataTableAll(long pCode, bool Conn)
        {
            string Where = " where 1=1 ";

            if (pCode != 0)
            {
                Where = Where + " And Code=" + pCode;
            }
            string    Query = @"select  Code,
BascoolID,
(select Fam from clsperson where Code=PersonCode) 'PersonName',
BascoolCode,
(select Fa_Date from StaticDates where En_Date=Cast(WDate as Date)) 'WDate',
WTime,
Substring(PlokNo,0,3) +
case 
when (PlokNo like '%ا%' ) then Substring(PlokNo,3,3) else Substring(PlokNo,3,1) end +
case
when (PlokNo like '%ا%' ) then Substring(PlokNo,6,3) else Substring(PlokNo,4,3) end +
case
when (PlokNo like '%ا%' ) then +'-'+Substring(PlokNo,10,2) else '-'+Substring(PlokNo,8,2) end  PlokNo,
(select Name from Subdefine where code=ProductCode) 'ProductName',
(select Name from BascolTruck where code=TruckCode) 'TruckName',
Weights,
pay,
hamrahno,
dele,
verify,
FullW,
PrintNo,
pay_h,
Duty,
Tax,
ProductCode,
isnull(cast((Select top 1  EmptyWeight from BascolEmptyWeights Where BascoolID=WeightID) as nvarchar),'') FirstWeight,
isnull(cast(ABS(Weights - (Select top 1  EmptyWeight from BascolEmptyWeights Where BascoolID=WeightID)) as nvarchar),'') Khales,
--(Select title from organizationchart where Code=UserPostCode) PostName, 
'' PostName, 
Substring(PlokNo,0,3) p1,
case 
when (PlokNo like '%ا%' ) then Substring(PlokNo,3,3) else Substring(PlokNo,3,1) end p2,
case
when (PlokNo like '%ا%' ) then Substring(PlokNo,6,3) else Substring(PlokNo,4,3) end p3,
case
when (PlokNo like '%ا%' ) then +'-'+Substring(PlokNo,10,2) else '-'+Substring(PlokNo,8,2) end p4,
UserPostCode,TruckCode,PersonCode 
from BascolWeights " + Where + "    order by BascoolID desc ";
            JDataBase db    = new JDataBase();

            try
            {
                if (Conn)
                {
                    JTransferData tmpTransferData = new JTransferData();
                    JDataBase     MyDB            = tmpTransferData.CreateConMainServer(true);
                    try
                    {
                        MyDB.setQuery(Query);
                        return(MyDB.Query_DataTable());
                    }
                    catch (Exception ex)
                    {
                        JSystem.Except.AddException(ex);
                        return(null);
                    }
                    finally
                    {
                        db.Dispose();
                        MyDB.Dispose();
                    }
                }
                else
                {
                    db.setQuery(Query);
                    return(db.Query_DataTable());
                }
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
                return(null);
            }
            finally
            {
                db.Dispose();
                //MyDB.Dispose();
            }
        }
Exemplo n.º 13
0
        //dele,verify,pay,Duty,Tax,
        private void btnPrint2_Click(object sender, EventArgs e)
        {
            if (jJanusGrid1.DataSource == null)
            {
                JMessages.Error(" ابتدا دکمه جستجو را بزنید ", "");
                return;
            }
            if (jJanusGrid1.SelectedRow == null)
            {
                JMessages.Error(" لطفا سطری را انتخاب کنید ", "");
                return;
            }
            _Code = Convert.ToInt32(jJanusGrid1.SelectedRow.Row["Code"].ToString());
            DataTable dt    = JWeights.GetDataTableAll(_Code, true);
            string    State = "این برگه المثنی" + " قبض شماره " + dt.Rows[0]["BascoolID"].ToString() + " مورخ " + dt.Rows[0]["WDate"].ToString() + "ساعت" + dt.Rows[0]["WTime"].ToString().Trim() + "می باشد";

            JWeight tmpWeight = new JWeight();

            tmpWeight.TruckCode    = Convert.ToInt32(dt.Rows[0]["TruckCode"].ToString());
            tmpWeight.UserPostCode = JMainFrame.CurrentPostCode;
            tmpWeight.PersonCode   = JMainFrame.CurrentPersonCode;
            tmpWeight.pay          = Convert.ToInt32(dt.Rows[0]["pay"].ToString());
            tmpWeight.pay_h        = Convert.ToInt32(dt.Rows[0]["pay"].ToString());
            tmpWeight.BascoolCode  = Convert.ToInt32(dt.Rows[0]["BascoolCode"].ToString());
            tmpWeight.PlokNo       = dt.Rows[0]["P1"].ToString() + dt.Rows[0]["P2"].ToString() + dt.Rows[0]["P3"].ToString() + dt.Rows[0]["P4"].ToString();
            tmpWeight.Weights      = Convert.ToInt32(dt.Rows[0]["Weights"].ToString());
            //tmpWeight.Duty = Convert.ToDecimal(dt.Rows[0]["Duty"].ToString());
            //tmpWeight.Tax = Convert.ToDecimal(dt.Rows[0]["Tax"].ToString());
            JTransferData tmpT = new JTransferData();

            tmpT.GetTaxDuty();
            tmpWeight.Duty = (tmpWeight.pay / (100 + tmpT._Duty + tmpT._Tax)) * tmpT._Duty;
            tmpWeight.Tax  = (tmpWeight.pay / (100 + tmpT._Duty + tmpT._Tax)) * tmpT._Tax;

            tmpWeight.hamrahno    = Convert.ToInt32(dt.Rows[0]["hamrahno"].ToString());
            tmpWeight.ProductCode = Convert.ToInt32(dt.Rows[0]["ProductCode"].ToString());
            tmpWeight.PrintNo     = 2;
            string Min = "";

            if (DateTime.Now.Minute.ToString().Length == 1)
            {
                Min = "0" + DateTime.Now.Minute.ToString();
            }
            else
            {
                Min = DateTime.Now.Minute.ToString();
            }
            string Hour = "";

            if (DateTime.Now.Hour.ToString().Length == 1)
            {
                Hour = "0" + DateTime.Now.Hour.ToString();
            }
            else
            {
                Hour = DateTime.Now.Hour.ToString();
            }
            tmpWeight.WTime = Hour + ":" + Min;

            tmpWeight.BascoolID = JWeights.GetCounter();
            tmpWeight.WDate     = DateTime.Now;

            JTransferData tmpJTransferData = new JTransferData();
            JDataBase     dbMain           = tmpJTransferData.CreateConMainServer(false);

            if (tmpWeight.Insert() > 0)//dbMain
            {
                dt = JWeights.GetDataTableAll(tmpWeight.Code, false);
            }
            dt.Columns.Add("State");
            dt.Columns.Add("StateHamrah");
            dt.Rows[0]["State"] = State;
            if (Convert.ToInt32(dt.Rows[0]["HamrahNO"]) != 0)
            {
                dt.Rows[0]["StateHamrah"] = dt.Rows[0]["HamrahNO"] + "    تعداد همراه  ";
            }
            else
            {
                dt.Rows[0]["StateHamrah"] = "";
            }
            if (dt != null)
            {
                //JDynamicReportForm DRF = new JDynamicReportForm(JReportDesignCodes.Bascool.GetHashCode());
                JDynamicReports DRF = new JDynamicReports(JReportDesignCodes.BillGoods.GetHashCode());
                DRF.Add(dt);
                //DRF.ShowDialog();
                DRF.Print("چاپ قبض", false, false);
            }

            try
            {
                dbMain.setQuery("Update BascolWeights set PrintNo=PrintNo+1 Where Code=" + _Code);
                dbMain.Query_Execute();
            }
            catch (Exception ex)
            {
                JSystem.Except.AddException(ex);
            }
            finally
            {
                dbMain.Dispose();
            }
        }