예제 #1
0
        private void Save()
        {
            DataTable dt = new DataTable();

            WhereClause where = new WhereClause();

            if (!String.IsNullOrEmpty(Manufacturer_ID))
            {
                where.Add(Manufacturer_table.Manufacturer_ID, Manufacturer_ID);
            }
            else
            {
                where.Add(Manufacturer_table.Manufacturer_ID, -1);
            }

            dt = DbUtil.getDataTableForTableName(Manufacturer_table.db_name, null, 0, where);
            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];
                row[Manufacturer_table.Name]         = txt_Name.Text;
                row[Manufacturer_table.Country_Code] = txt_Country_Code.Text;
                row[Manufacturer_table.Website]      = txt_Website.Text;
            }
            else
            {
                DataRow row = dt.NewRow();
                row[Manufacturer_table.Name]         = txt_Name.Text;
                row[Manufacturer_table.Country_Code] = txt_Country_Code.Text;
                row[Manufacturer_table.Website]      = txt_Website.Text;
                dt.Rows.Add(row);
            }

            DbUtil.saveChanges(Manufacturer_table.db_name, dt);
        }
예제 #2
0
        private void LoadData(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Manufacturer_ID))
            {
                WhereClause where = new WhereClause();

                if (Manufacturer_ID == "-1")
                {
                    where.Add(Manufacturer_table.Manufacturer_ID, -1);
                }
                else
                {
                    where.Add(Manufacturer_table.Manufacturer_ID, Manufacturer_ID);
                }

                DataTable dt = DbUtil.getDataTableForTableName(Manufacturer_table.db_name, null, 0, where);

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];

                    txt_Name.Text         = dr[Manufacturer_table.Name].MakeString();
                    txt_Country_Code.Text = dr[Manufacturer_table.Country_Code].MakeString();
                    txt_Website.Text      = dr[Manufacturer_table.Website].MakeString();

                    initialData = Globals.FillDictionary(this.radPanel1);
                }
            }
        }
예제 #3
0
        public DataTable OfficerByOffice(int officeID, bool onlyCurrent, bool noCache)
        {
            WhereClause wc = new WhereClause();

            wc.Add("OfficeID", "=", officeID);
            if (onlyCurrent)
            {
                wc.Add("CurrentEmployee", "=", 1);
            }
            return(Codes("vOfficerList", wc, noCache));
        }
예제 #4
0
        /// <summary>
        /// Променя или инсъртва ред
        /// </summary>
        private void Save()
        {
            DataTable dt = new DataTable();

            WhereClause where = new WhereClause();

            if (!String.IsNullOrEmpty(Location_ID))
            {
                where.Add(Location_table.Location_ID, Location_ID);
            }
            else
            {
                where.Add(Location_table.Location_ID, -1);
            }

            dt = DbUtil.getDataTableForTableName(Location_table.db_name, null, 0, where);
            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];

                if (cmb_Responsible_Person.SelectedValue != null)
                {
                    row[Location_table.User_ID] = cmb_Responsible_Person.SelectedValue;
                }

                row[Location_table.Address]     = txt_Address.Text;
                row[Location_table.Name]        = txt_Name.Text;
                row[Location_table.Require_Bin] = chk_Req_Bin.Checked == true ? 1 : 0;
            }
            else
            {
                DataRow row = dt.NewRow();

                if (cmb_Responsible_Person.SelectedValue != null)
                {
                    row[Location_table.User_ID] = cmb_Responsible_Person.SelectedValue;
                }

                row[Location_table.Address]     = txt_Address.Text;
                row[Location_table.Name]        = txt_Name.Text;
                row[Location_table.Require_Bin] = chk_Req_Bin.Checked == true ? 1 : 0;

                dt.Rows.Add(row);
            }



            int result = DbUtil.saveChanges(Location_table.db_name, dt);

            if (result != 0)
            {
                MessageBox.Show("Записът беше запаметен!");
            }
        }
예제 #5
0
        /// <summary>
        /// Променя или инсъртва ред
        /// </summary>
        private void Save()
        {
            DataTable dt = new DataTable();

            WhereClause where = new WhereClause();

            if (!String.IsNullOrEmpty(Bin_ID))
            {
                where.Add(Bin_table.Bin_ID, Bin_ID);
            }
            else
            {
                where.Add(Bin_table.Bin_ID, -1);
            }

            dt = DbUtil.getDataTableForTableName(Bin_table.db_name, null, 0, where);
            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];

                row[Bin_table.Location_ID] = cmb_Location_ID.SelectedValue;
                row[Bin_table.Length]      = txt_Lenght.Text;
                row[Bin_table.Description] = txt_Description.Text;
                row[Bin_table.Width]       = txt_Width.Text;
                row[Bin_table.Height]      = txt_Height.Text;
                row[Bin_table.Length]      = txt_Lenght.Text;
                row[Bin_table.Max_Weight]  = txt_Max_Weight.Text;
            }
            else
            {
                DataRow row = dt.NewRow();

                row[Bin_table.Location_ID] = cmb_Location_ID.SelectedValue;
                row[Bin_table.Length]      = txt_Lenght.Text;
                row[Bin_table.Description] = txt_Description.Text;
                row[Bin_table.Width]       = txt_Width.Text;
                row[Bin_table.Height]      = txt_Height.Text;
                row[Bin_table.Length]      = txt_Lenght.Text;
                row[Bin_table.Max_Weight]  = txt_Max_Weight.Text;

                dt.Rows.Add(row);
            }



            int result = DbUtil.saveChanges(Bin_table.db_name, dt);

            if (result != 0)
            {
                MessageBox.Show("Записът беше запаметен!");
            }
        }
예제 #6
0
        /// <summary>
        /// Променя или инсъртва ред
        /// </summary>
        private void Save()
        {
            DataTable dt = new DataTable();

            WhereClause where = new WhereClause();

            if (!String.IsNullOrEmpty(Model_ID))
            {
                where.Add(Model_table.Model_ID, Model_ID);
            }
            else
            {
                where.Add(Model_table.Model_ID, -1);
            }

            dt = DbUtil.getDataTableForTableName(Model_table.db_name, null, 0, where);
            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];


                if (cmb_Manufacturer.SelectedValue != null)
                {
                    row[Model_table.Manufacturer_ID] = cmb_Manufacturer.SelectedValue;
                }
                row[Model_table.Name]            = txt_Model_Name.Text;
                row[Model_table.Production_Date] = date_picker_Prod_Date.Value;
            }
            else
            {
                DataRow row = dt.NewRow();


                if (cmb_Manufacturer.SelectedValue != null)
                {
                    row[Model_table.Manufacturer_ID] = cmb_Manufacturer.SelectedValue;
                }
                row[Model_table.Name]            = txt_Model_Name.Text;
                row[Model_table.Production_Date] = date_picker_Prod_Date.Value;
                dt.Rows.Add(row);
            }



            int result = DbUtil.saveChanges(Model_table.db_name, dt);

            if (result != 0)
            {
                MessageBox.Show("Записът беше запаметен!");
            }
        }
예제 #7
0
 public void Translate(Expression expression)
 {
     this.sb = new StringBuilder();
     this.Visit(expression);
     validateBinaryExpression(null, null);
     WhereClause.Add(this.sb.ToString());
 }
예제 #8
0
        private void btn_Delete_Click(object sender, EventArgs e)
        {
            if (radGridView1.SelectedRows.Count < 1)
            {
                MessageBox.Show("Изберете ред!");
                return;
            }


            DialogResult dialogResult = MessageBox.Show("Сигурни ли сте,че искате да изтриете този запис?", "Съобщение", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                List <string> list = new List <string>();
                list.Add(radGridView1.SelectedRows[0].Cells[Location_table.Location_ID].Value.MakeString());
                WhereClause where = new WhereClause();
                where.Add(Location_table.Location_ID, list.ToArray());
                int res = DbUtil.delete(Location_table.db_name, where);
                if (res > 0)
                {
                    MessageBox.Show("Записът беше изтрит!");
                    //   this.locationTableAdapter.Fill(this.dataSet1.location);
                }
            }
        }
예제 #9
0
파일: WhereClause.cs 프로젝트: vebin/IQMap
        public void IsEmpty()
        {
            var item = new WhereClause();

            Assert.IsTrue(item.IsEmpty);

            item.Add(new WhereString("a=b"));
            Assert.IsFalse(item.IsEmpty);
        }
예제 #10
0
 public void Translate(Expression expression)
 {
     this.sb = new StringBuilder();
     this.Visit(expression);
     if (sb.ToString().Contains("{IsNullOrEmpty}"))
     {
         sb = new StringBuilder(sb.ToString().Replace("{IsNullOrEmpty}", " = 1 "));
     }
     WhereClause.Add(this.sb.ToString());
 }
예제 #11
0
        /// <summary>
        /// Зарежда данните
        /// </summary>
        private void LoadData()
        {
            if (!String.IsNullOrEmpty(Location_ID))
            {
                WhereClause where = new WhereClause();

                if (Location_ID == "-1")
                {
                    where.Add(Location_table.Location_ID, -1);
                }
                else
                {
                    txt_Location_ID.Text = Location_ID;

                    where.Add(Location_table.Location_ID, Location_ID);
                }



                DataTable dt = DbUtil.getDataTableForTableName(Location_table.db_name, null, 0, where);

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];


                    txt_Address.Text = dr[Location_table.Address].MakeString();
                    txt_Name.Text    = dr[Location_table.Name].MakeString();
                    if (cmb_Responsible_Person.Items.Count > 0)
                    {
                        cmb_Responsible_Person.SelectedValue = dr[Location_table.User_ID].MakeLong();
                    }
                    if (!String.IsNullOrEmpty(dr[Location_table.Require_Bin].MakeString()))
                    {
                        chk_Req_Bin.Checked = dr[Location_table.Require_Bin].MakeString() == "1" ? true : false;
                    }
                }
            }
        }
예제 #12
0
        /// <summary>
        /// Зарежда данните
        /// </summary>
        private void LoadData()
        {
            if (!String.IsNullOrEmpty(Model_ID))
            {
                WhereClause where = new WhereClause();

                if (Model_ID == "-1")
                {
                    where.Add(Model_table.Model_ID, -1);
                }
                else
                {
                    txt_Model_ID.Text = Model_ID;

                    where.Add(Model_table.Model_ID, Model_ID);
                }



                DataTable dt = DbUtil.getDataTableForTableName(Model_table.db_name, null, 0, where);

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];


                    txt_Model_Name.Text = dr[Model_table.Name].MakeString();
                    if (cmb_Manufacturer.Items.Count > 0)
                    {
                        cmb_Manufacturer.SelectedValue = dr[Model_table.Manufacturer_ID].MakeLong();
                    }
                    if (!String.IsNullOrEmpty(dr[Model_table.Production_Date].MakeString()))
                    {
                        date_picker_Prod_Date.Value = Convert.ToDateTime(dr[Model_table.Production_Date].MakeString());
                    }
                }
            }
        }
예제 #13
0
        /// <summary>
        /// Зарежда данните
        /// </summary>
        private void LoadData()
        {
            if (!String.IsNullOrEmpty(Bin_ID))
            {
                WhereClause where = new WhereClause();

                if (Bin_ID == "-1")
                {
                    where.Add(Bin_table.Bin_ID, -1);
                }
                else
                {
                    txt_Bin_ID.Text = Bin_ID;

                    where.Add(Bin_table.Bin_ID, Bin_ID);
                }



                DataTable dt = DbUtil.getDataTableForTableName(Bin_table.db_name, null, 0, where);

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];


                    txt_Description.Text = dr[Bin_table.Description].MakeString();
                    txt_Lenght.Text      = dr[Bin_table.Length].MakeString();
                    txt_Height.Text      = dr[Bin_table.Height].MakeString();
                    txt_Width.Text       = dr[Bin_table.Width].MakeString();
                    txt_Max_Weight.Text  = dr[Bin_table.Max_Weight].MakeString();
                    if (cmb_Location_ID.Items.Count > 0)
                    {
                        cmb_Location_ID.SelectedValue = dr[Bin_table.Location_ID].MakeLong();
                    }
                }
            }
        }
예제 #14
0
        private void MasterTemplate_RowsChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
        {
            MessageBox.Show(e.Action.MakeString());
            if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Add)
            {
                WhereClause where = new WhereClause();
                where.Add(Item_Journal_Header_Table.Item_Journal_Header_ID, -1);
                DataTable dt = DbUtil.getDataTableForTableName(Item_Journal_Header_Table.db_name, null, 0, where);
                if (dt.Rows.Count > 0)
                {
                    return;
                }
                DataRow dr = dt.NewRow();

                dr[Item_Journal_Header_Table.Item_Journal_Header_Name] = e.GridViewTemplate.Rows[0].Cells[Item_Journal_Header_Table.Item_Journal_Header_Name].Value;
                dr[Item_Journal_Header_Table.User_ID] = Globals.UserName;
            }
        }
예제 #15
0
        /// <summary>
        /// Зарежда данните
        /// </summary>
        private void LoadData()
        {
            if (!String.IsNullOrEmpty(Item_ID))
            {
                WhereClause where = new WhereClause();

                if (Item_ID == "-1")
                {
                    where.Add(Item_table.Item_ID, -1);
                }
                else
                {
                    where.Add(Item_table.Item_ID, Item_ID);
                }

                DataTable dt = DbUtil.getDataTableForTableName(Item_table.db_name, null, 0, where);

                if (dt.Rows.Count > 0)
                {
                    DataRow dr = dt.Rows[0];

                    txt_Description.Text = dr[Item_table.Description].MakeString();
                    txt_No.Text          = dr[Item_table.Item_ID].MakeString();
                    txt_Purch_Price.Text = dr[Item_table.Purchase_Price].MakeString();
                    txt_Sales_Price.Text = dr[Item_table.Sales_Price].MakeString();
                    txt_Length.Text      = dr[Item_table.Length].MakeString();
                    txt_Height.Text      = dr[Item_table.Height].MakeString();
                    txt_Weight.Text      = dr[Item_table.Weight].MakeString();
                    txt_Width.Text       = dr[Item_table.Width].MakeString();
                    txt_Barcode.Text     = dr[Item_table.Barcode].MakeString();


                    if (cmb_Item_Type.Items.Count > 0)
                    {
                        cmb_Item_Type.SelectedValue = dr[Item_table.Item_Type].MakeString();
                    }

                    if (cmb_Bin.Items.Count > 0)
                    {
                        cmb_Bin.SelectedValue = dr[Item_table.Bin_ID].MakeString();
                    }

                    if (cmb_Location.Items.Count > 0)
                    {
                        cmb_Location.SelectedValue = dr[Item_table.Location_ID].MakeString();
                    }

                    if (cmb_Manufacturer.Items.Count > 0)
                    {
                        cmb_Manufacturer.SelectedValue = dr[Item_table.Manufacturer_ID].MakeString();
                    }

                    if (cmb_Model.Items.Count > 0)
                    {
                        cmb_Model.SelectedValue = dr[Item_table.Model_ID].MakeString();
                    }

                    if (cmb_UoM.Items.Count > 0)
                    {
                        cmb_UoM.SelectedValue = dr[Item_table.Unit_of_Measure].MakeString();
                    }

                    if (cmb_Purch_Price_Currency.Items.Count > 0)
                    {
                        cmb_Purch_Price_Currency.SelectedValue = dr[Item_table.Purchase_Price_Currency_Code].MakeString();
                    }

                    if (cmb_Sales_Price_Currency.Items.Count > 0)
                    {
                        cmb_Sales_Price_Currency.SelectedValue = dr[Item_table.Sales_Price_Currency_Code].MakeString();
                    }
                }
            }
        }
예제 #16
0
        public DataTable Codes(string codeName, object vWhere, bool noCache)
        {
            string      sListname = codeName + this.AppMan.Language;
            DataTable   olist     = new DataTable(codeName);
            WhereClause wc        = new WhereClause();

            if (!noCache)
            {
                if (this.MyColCodes.ContainsKey(sListname))
                {
                    return((DataTable)this.MyColCodes[sListname]);
                }
            }

            switch (codeName.ToUpper())
            {
            case "VOUTCOME":
            case "OUTCOME":
                if (vWhere == null)
                {
                    int decID = 1;

                    if (GetSSTMng().DB.SSTCase.Count > 0 && !GetSSTMng().DB.SSTCase[0].IsDecisionTypeNull())
                    {
                        decID = GetSSTMng().DB.SSTCase[0].DecisionType;
                    }

                    if (GetSSTMng().DB.SSTDecision.Count > 0)
                    {
                        SST.SSTDecisionRow[] sdrs = (SST.SSTDecisionRow[])GetSSTMng().GetSSTDecision().GetCurrentRow();
                        if (sdrs.Length == 1)
                        {
                            decID = sdrs[0].DecisionType;
                        }
                    }
                    wc.Add("DecisionType", "=", decID);
                    wc.Add("Obsolete", "=", 0);
                    olist   = this.AtMng.GetGeneralRec("select * from vOutcomeList " + wc.Clause() + " order by sortkey");
                    noCache = true;
                }
                else
                {
                    wc = (WhereClause)vWhere;
                    wc.Add("Obsolete", "=", 0);
                    olist = this.AtMng.GetGeneralRec("select * from vOutcomeList " + wc.Clause() + " order by sortkey");
                }
                break;

            case "SSTPARTYTYPE":
                int prgId = 0;
                if (GetSSTMng().DB.SSTCase.Rows.Count > 0)
                {
                    prgId = GetSSTMng().GetSSTCase().EffectiveProgram(GetSSTMng().DB.SSTCase[0]);
                }

                wc.Add("ProgramId", "=", prgId);
                wc.Add("Obsolete", "=", 0);
                olist   = this.AtMng.GetGeneralRec("vSSTContactTypeList", wc);
                noCache = true;
                break;

            case "CHILDFILETYPE":
                appDB.EFileSearchRow pfr = this.EFile.GetEfileParentRow(this.CurrentFile);
                if (pfr != null)
                {
                    string ft = pfr.FileType;
                    wc.Add("ParentFileType", "=", ft);
                    sListname += ft;
                }
                else
                {
                    string ft = this.CurrentFile.FileType;
                    wc.Add("ParentFileType", "=", ft);
                    sListname += ft;
                }
                if (this.MyColCodes.ContainsKey(sListname))
                {
                    return((DataTable)this.MyColCodes[sListname]);
                }

                olist = this.AtMng.GetGeneralRec("vFileTypeList", wc);
                break;

            case "CHILDMETATYPE":
                appDB.EFileSearchRow pfr1 = this.EFile.GetEfileParentRow(this.CurrentFile);
                if (pfr1 != null)
                {
                    string mt = pfr1.MetaType;
                    wc.Add("ParentMetaType", "=", mt);
                    sListname += mt;
                }
                else
                {
                    string mt = this.CurrentFile.MetaType;
                    wc.Add("ParentMetaType", "=", mt);
                    sListname += mt;
                }

                if (this.MyColCodes.ContainsKey(sListname))
                {
                    return((DataTable)this.MyColCodes[sListname]);
                }

                olist = this.AtMng.GetGeneralRec("vMetaTypeList", wc);

                break;

            case "PROVINCE":
                if (vWhere != null)
                {
                    wc = (WhereClause)vWhere;
                }
                wc.Add("Obsolete", "=", 0);
                olist = this.AtMng.GetGeneralRec(codeName, wc);
                if (1 == 1)
                {
                    DataColumn[] keys = new DataColumn[1];
                    keys[0]          = olist.Columns["ProvinceCode"];
                    olist.PrimaryKey = keys;
                }
                break;

            case "VOFFICECLIENTLIST":
                olist            = this.AtMng.GetGeneralRec("vOfficeClientList", wc);
                olist.PrimaryKey = new DataColumn[] { olist.Columns["OfficeID"] };
                break;

            case "VOFFICELIST":
            case "OFFICELIST":
            case "AGENTLIST":
                olist            = this.AtMng.GetGeneralRec("vOfficeList", wc);
                olist.PrimaryKey = new DataColumn[] { olist.Columns["OfficeID"] };
                break;

            case "AGENTLISTSPECIAL":
                olist = this.AtMng.GetGeneralRec("Select * from Office as a inner join address as ad on a.addressid=ad.addressid");
                break;

            case "VOFFICERLIST":
            case "OFFICERLIST":
                if (vWhere == null)
                {
                    olist = this.AtMng.GetGeneralRec("vOfficerList", wc);
                }
                else if (vWhere.GetType() == typeof(WhereClause))
                {
                    olist = this.AtMng.GetGeneralRec("vOfficerList", (WhereClause)vWhere);
                }
                else if ((bool)vWhere == true)
                {
                    wc.Add("CurrentEmployee", "=", 1);
                    olist = this.AtMng.GetGeneralRec("vOfficerList", wc);
                }
                olist.PrimaryKey = new DataColumn[] { olist.Columns["OfficerID"] };
                break;

            case "LAWYERLIST":
                wc.Add("CurrentEmployee", "=", 1);
                olist = AtMng.GetGeneralRec("vLawyerList", wc);

                olist.PrimaryKey = new DataColumn[] { olist.Columns["OfficerID"] };
                break;

            case "OWNERLIST":
                olist = this.OfficerByOffice(this.CurrentFile.OwnerOfficeId, true, true);
                break;

            case "AGENTLOGGEDONOFFLIST":
                olist = this.OfficerByOffice(this.AtMng.OfficeLoggedOn.OfficeId, true, true);
                break;

            case "OFFICERACCESSLIST":
                wc.Add("FileId", "=", this.CurrentFile.FileId);
                wc.Add("CurrentEmployee", "=", 1);
                olist            = this.AtMng.GetGeneralRec("vOfficerAccessList", wc);
                olist.PrimaryKey = new DataColumn[] { olist.Columns["OfficerID"] };
                break;

            case "LEADLIST":
            case "AGENTOFFLIST":
                olist = this.OfficerByOffice(this.CurrentFile.LeadOfficeId, true, true);
                break;

            default:
                if (vWhere == null)
                {
                    return(AtMng.GetddLookup().Codes(codeName, this));
                }
                else
                {
                    olist = this.AtMng.GetGeneralRec(codeName, (WhereClause)vWhere);
                }
                break;
            }
            switch (codeName.ToUpper())
            {
            case "SELJUDGMENT":
                break;

            case "SELWRIT":
                break;

            default:
                if (!noCache)
                {
                    this.MyColCodes.Add(sListname, olist);
                }
                break;
            }

            if (olist.PrimaryKey.Length == 0)
            {
                olist.PrimaryKey = new DataColumn[] { olist.Columns[0] };
            }
            return(olist);
        }
예제 #17
0
        /// <summary>
        /// Променя или инсъртва ред
        /// </summary>
        private void Save()
        {
            DataTable dt = new DataTable();

            WhereClause where = new WhereClause();

            if (!String.IsNullOrEmpty(Item_ID))
            {
                where.Add(Item_table.Item_ID, Item_ID);
            }
            else
            {
                where.Add(Item_table.Item_ID, -1);
            }

            dt = DbUtil.getDataTableForTableName(Item_table.db_name, null, 0, where);
            if (dt.Rows.Count > 0)
            {
                DataRow row = dt.Rows[0];

                row[Item_table.Item_Type]       = cmb_Item_Type.SelectedValue.MakeLong();
                row[Item_table.Description]     = txt_Description.Text;
                row[Item_table.Manufacturer_ID] = cmb_Manufacturer.SelectedValue.MakeLong();
                row[Item_table.Model_ID]        = cmb_Model.SelectedValue.MakeLong();
                row[Item_table.Unit_of_Measure] = cmb_UoM.SelectedValue;
                row[Item_table.Purchase_Price]  = txt_Purch_Price.Text.MakeDecimal();
                row[Item_table.Sales_Price]     = txt_Sales_Price.Text.MakeDecimal();
                row[Item_table.Purchase_Price_Currency_Code] = cmb_Purch_Price_Currency.SelectedValue;
                row[Item_table.Sales_Price_Currency_Code]    = cmb_Sales_Price_Currency.SelectedValue;
                row[Item_table.Location_ID] = cmb_Location.SelectedValue.MakeLong();
                row[Item_table.Bin_ID]      = cmb_Bin.SelectedValue.MakeLong();
                row[Item_table.Width]       = txt_Width.Text.MakeDecimal();
                row[Item_table.Weight]      = txt_Weight.Text.MakeDecimal();
                row[Item_table.Length]      = txt_Length.Text.MakeDecimal();
                row[Item_table.Height]      = txt_Height.Text.MakeDecimal();
                row[Item_table.Barcode]     = txt_Barcode.Text;
            }
            else
            {
                DataRow row = dt.NewRow();

                row[Item_table.Item_Type]       = cmb_Item_Type.SelectedValue.MakeLong();
                row[Item_table.Description]     = txt_Description.Text;
                row[Item_table.Manufacturer_ID] = cmb_Manufacturer.SelectedValue.MakeLong();
                row[Item_table.Model_ID]        = cmb_Model.SelectedValue.MakeLong();
                row[Item_table.Unit_of_Measure] = cmb_UoM.SelectedValue;
                row[Item_table.Purchase_Price]  = txt_Purch_Price.Text.MakeDecimal();
                row[Item_table.Sales_Price]     = txt_Sales_Price.Text.MakeDecimal();
                row[Item_table.Purchase_Price_Currency_Code] = cmb_Purch_Price_Currency.SelectedValue;
                row[Item_table.Sales_Price_Currency_Code]    = cmb_Sales_Price_Currency.SelectedValue;
                row[Item_table.Location_ID] = cmb_Location.SelectedValue.MakeLong();
                row[Item_table.Bin_ID]      = cmb_Bin.SelectedValue.MakeLong();
                row[Item_table.Width]       = txt_Width.Text.MakeDecimal();
                row[Item_table.Weight]      = txt_Weight.Text.MakeDecimal();
                row[Item_table.Length]      = txt_Length.Text.MakeDecimal();
                row[Item_table.Height]      = txt_Height.Text.MakeDecimal();
                row[Item_table.Barcode]     = txt_Barcode.Text;

                dt.Rows.Add(row);
            }

            int result = DbUtil.saveChanges(Item_table.db_name, dt);
        }
예제 #18
0
        public DataTable Codes(string name, FileManager fm)
        {
            if (myddLookupDT.Count == 0)
            {
                Load();
            }

            appDB.ddLookupRow[] dlrs = (appDB.ddLookupRow[])myddLookupDT.Select("LookupName='" + name + "'");
            if (dlrs.Length == 1)
            {
                DataTable         dtList;
                appDB.ddLookupRow dlr = dlrs[0];

                string sListname = name + myA.AppMan.Language;

                if (dlr.Cache && myA.myColCodes.ContainsKey(sListname))
                {
                    return((DataTable)myA.myColCodes[sListname]);
                }

                WhereClause wc = new WhereClause();
                if (dlr.UseFileContext && fm != null && !fm.IsVirtualFM)
                {
                    wc.Add("Fileid", "=", fm.CurrentFileId);
                }
                if (!dlr.IncludeObsolete)
                {
                    wc.Add("Obsolete", "=", 0);
                }
                if (!dlr.IsWhereClauseNull())
                {
                    wc.And(dlr.WhereClause);
                }
                switch (dlr.LookupType)
                {
                case "SP":
                    if (dlr.UseFileContext && fm != null && !fm.IsVirtualFM)
                    {
                        dtList = myA.AppMan.ExecuteDataset(dlr.Source, fm.CurrentFileId).Tables[0];
                    }
                    else
                    {
                        dtList = myA.AppMan.ExecuteDataset(dlr.Source, System.DBNull.Value).Tables[0];
                    }
                    break;

                case "SQL":
                    dtList = myA.GetGeneralRec(dlr.Source);
                    break;

                case "VIEW":
                case "TABLE":

                    dtList = myA.GetGeneralRec(dlr.Source, wc);

                    break;

                case "GEN":
                default:
                    wc.Add("LookupId", "=", dlr.LookupId);

                    DataView dv = new DataView(myA.DB.ddGeneric, wc.Filter(), "", DataViewRowState.CurrentRows);
                    dtList = dv.ToTable();
                    dtList.Columns.Remove("LookupId");
                    dtList.Columns.Remove("ParentId");
                    dtList.PrimaryKey = new DataColumn[] { dtList.Columns["GenericId"] };
                    //dtList = myA.GetGeneralRec("vddGenericList",wc);
                    break;
                }

                string sort = "";
                if (!dlr.IsSortcolumnsNull())
                {
                    sort = dlr.Sortcolumns;
                }
                else
                {
                    sort = dtList.Columns[0].ColumnName;
                }

                DataView dv1 = new DataView(dtList, "", sort, DataViewRowState.CurrentRows);
                dtList = dv1.ToTable();

                if (dtList.PrimaryKey.Length == 0)
                {
                    if (!dlr.IsPKNameNull())
                    {
                        dtList.PrimaryKey = new DataColumn[] { dtList.Columns[dlr.PKName] };
                    }
                    else
                    {
                        dtList.PrimaryKey = new DataColumn[] { dtList.Columns[0] };
                    }
                }

                if (dlr.Cache)
                {
                    myA.myColCodes.Add(sListname, dtList);
                }

                return(dtList);
            }
            else
            {
                throw new AtriumException(name + " is not a valid lookup table");
            }
        }
예제 #19
0
        protected override void BeforeChange(DataColumn dc, DataRow ddr)
        {
            string ObjectName = this.myAddressDT.TableName;

            atriumDB.AddressRow dr      = (atriumDB.AddressRow)ddr;
            WhereClause         whereCl = new WhereClause();

            switch (dc.ColumnName)
            {
            case  "City":
                if (!dr.IsNull("CountryCode") && dr.CountryCode == "CDN")
                {
                    if (dr.IsCityNull())
                    {
                        throw new RequiredException(Resources.AddressCity);
                    }

                    if (myA.AtMng.GetSetting(AppBoolSetting.ValidateCity))
                    {
                        if (!dr.IsProvinceCodeNull())
                        {
                            DataTable dt = myA.Codes("vCity");
                            whereCl.Add("ProvinceCode", "=", dr.ProvinceCode);

                            if (dt.Select(whereCl.Filter()).Length != 0)
                            {
                                whereCl.Add("City", "=", dr.City);
                                //dt = myA.AtMng.GetGeneralRec("City", whereCl);
                                if (dt.Select(whereCl.Filter()).Length == 0)
                                {
                                    throw new AtriumException(Resources.AddressCityNotInProv, Resources.AddressCity, Resources.AddressProvince);
                                }
                            }
                        }
                    }
                }
                break;

            case  "ProvinceCode":
                if (dr.IsProvinceCodeNull())
                {
                    if (!dr.IsNull("CountryCode"))
                    {
                        if (dr.CountryCode == "CDN" || dr.CountryCode == "USA")
                        {
                            throw new RequiredException(Resources.AddressProvinceCode);
                        }
                    }
                }
                else
                {
                    if (!dr.IsNull("CountryCode"))
                    {
                        if (dr.CountryCode == "CDN" || dr.CountryCode == "USA")
                        {
                            DataTable           dtP = myA.Codes("Province");
                            atLogic.WhereClause wc  = new atLogic.WhereClause();
                            wc.Add("CountryCode", "=", dr.CountryCode);

                            //if (!myA.Codes("Province").Rows.Contains(dr.ProvinceCode))
                            if (!dtP.Rows.Contains(dr.ProvinceCode))
                            {
                                throw new AtriumException(Resources.IsNotValid, Resources.AddressProvinceCode);
                            }
                        }
                    }
                }
                break;

            case  "CountryCode":
                if (dr.IsNull(dc))
                {
                    throw new RequiredException(Resources.AddressCountryCode);
                }

                else if (!myA.Codes("Country").Rows.Contains(dr.CountryCode))
                {
                    throw new AtriumException(Resources.IsNotValid, Resources.AddressCountryCode);
                }
                break;

            case  "AddressSourceCode":
                if (dr.IsAddressSourceCodeNull())
                {
                    throw new RequiredException(Resources.AddressAddressSourceCode);
                }
                else if (!myA.Codes("AddressSource").Rows.Contains(dr.AddressSourceCode))
                {
                    throw new AtriumException(Resources.IsNotValid, Resources.AddressAddressSourceCode);
                }
                break;

            case  "AddressType":
                if (dr.IsAddressTypeNull())
                {
                    throw new RequiredException(Resources.AddressAddressType);
                }
                else if (!myA.Codes("AddressType").Rows.Contains(dr.AddressType))
                {
                    throw new AtriumException(Resources.IsNotValid, Resources.AddressAddressType);
                }
                break;

            case "Address1":
                if (dr.IsNull(dc))
                {
                    throw new RequiredException(Resources.AddressAddress1);
                }
                break;

            case  "EffectiveTo":
                if (dr.IsEffectiveToNull())
                {
                    throw new RequiredException(Resources.AddressEffectiveTo);
                }
                myA.IsValidDate(Resources.AddressEffectiveTo, dr.EffectiveTo, false, DebtorBE.CSLBegin, DateTime.Today, Resources.ValidationCSLBegin, Resources.ValidationToday);
                break;

            default:
                break;
            }
        }
예제 #20
0
 public void AddWhere(object value, string comment = "")
 {
     WhereClause.Add(new KeyValuePair <string, object>(comment, value));
 }