예제 #1
0
 public PAttribute Delete(PAttribute pAttribute)
 {
     if (ConcreteDb.Instance.Update(String.Format("DELETE FROM SystemAttribute Where ID = {0}", pAttribute.id)) < 0)
     {
         throw new Exception(ConcreteDb.Instance.errorMessage);
     }
     return(pAttribute);
 }
예제 #2
0
            public PAttribute Update(PAttribute pAttribute)
            {
                if (pAttribute.AttributeName.Equals(ContantCls.emlementProb, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(null);
                }
                string sql = String.Format("UPDATE SystemAttribute SET PrimaryKey = '{0}',AttributeName='{1}', DataType='{2}', Domain='{3}', Description='{4}', SchemeID='{5}' WHERE ID= '{6}' ",
                                           pAttribute.primaryKey ? "True" : "False",
                                           pAttribute.AttributeName,
                                           pAttribute.Type.DataType,
                                           pAttribute.Type.DomainString,
                                           pAttribute.Description,
                                           pAttribute.Schema.id,
                                           pAttribute.id);

                if (ConcreteDb.Instance.Update(sql) < 0)
                {
                    throw new Exception(String.Format("Failed to Update Attribute {0}, Plz try again!", pAttribute.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error));
                }
                return(pAttribute);
            }
예제 #3
0
            public PTuple insertEmptyTuple(PRelation pRelation, PAttribute pri, String IdTuple)
            {
                var relation = new PRelation()
                {
                    id = pRelation.id
                };

                var tupID = String.Empty;

                //insert empty tuple
                try
                {
                    var tuple = RawDatabaseService.Instance().GetTuplebyId(ref relation, tupID);
                    tuple.valueSet[$"{relation.relationName.ToLower()}.{pri.AttributeName.ToLower()}"] = new List <String>()
                    {
                        "{ " + IdTuple + " }"
                    };

                    foreach (var key in tuple.valueSet.Keys.ToList())
                    {
                        var atr = key.Substring(key.IndexOf(".") + 1);
                        var Pri = $"{relation.relationName.ToLower()}.{pri.AttributeName.ToLower()}";
                        if (!atr.Equals(ContantCls.emlementProb, StringComparison.CurrentCultureIgnoreCase) &&
                            key != Pri)
                        {
                            tuple.valueSet[key] = new List <String>()
                            {
                                "{ Insert Data }"
                            };
                        }
                    }
                    PTupleService.Instance().Insert(tuple, relation);
                    return(tuple);
                }
                catch (Exception Ex)
                {
                    return(null);
                }
            }
예제 #4
0
            public PAttribute Insert(PAttribute pAttribute)
            {
                //add attr o dau => CSDL
                string SQL = "";

                SQL += "INSERT INTO SystemAttribute VALUES ( ";
                SQL += pAttribute.id + ",";
                SQL += "'" + pAttribute.primaryKey + "'" + ",";
                SQL += "'" + pAttribute.AttributeName + "'" + ",";
                SQL += "'" + pAttribute.Type.TypeName + "'" + ",";
                SQL += "'" + pAttribute.Type.DomainString + "'" + ",";
                SQL += "'" + pAttribute.Description + "'" + ",";
                SQL += pAttribute.Schema.id; // notice
                SQL += " );";
                try
                {
                    ConcreteDb.Instance.Update(SQL);
                    return(pAttribute);
                }
                catch
                {
                    return(null);
                }
            }
예제 #5
0
            public IList <PAttribute> getListAttributeByScheme(PSchema pSchema)
            {
                IList <PAttribute> probAttributes = new List <PAttribute>();
                DataTable          dtb            = ConcreteDb.Instance.getDataTable("SELECT * FROM SystemAttribute Where SchemeID = " + pSchema.id);

                if (dtb != null)
                {
                    foreach (DataRow attrRow in dtb.Rows)
                    {
                        var NewAttr = new PAttribute();
                        NewAttr.id         = Convert.ToInt32(attrRow[0]);
                        NewAttr.primaryKey = Convert.ToBoolean(attrRow[1]);
                        //NewAttr.AttributeName = String.Format("{0}.{1}", pSchema.SchemaName, Convert.ToString(attrRow[2]).ToLower());
                        NewAttr.AttributeName = Convert.ToString(attrRow[2]).ToLower();
                        NewAttr.Type.TypeName = Convert.ToString(attrRow[3]);
                        NewAttr.Type.GetDomain(Convert.ToString(attrRow[4]));
                        NewAttr.Type.GetDataType();
                        NewAttr.Description = Convert.ToString(attrRow[5]);
                        NewAttr.Schema.id   = (int)attrRow[6];
                        probAttributes.Add(NewAttr);
                    }
                }
                return(probAttributes);
            }
예제 #6
0
 public ActionResult AddAttribute(PAttribute attribute)
 {
     _arep.Add(attribute);
     return(RedirectToAction("AddAttribute"));
 }
예제 #7
0
 public PTuple insertEmptyTuple(PRelation pRelation, PAttribute pri, String idTuple)
 {
     return(PTupleService.Instance().insertEmptyTuple(pRelation, pri, idTuple));
 }
예제 #8
0
 public PAttribute Delete(PAttribute pAttribute)
 {
     return(AttributeService.Instance().Delete(pAttribute));
 }
예제 #9
0
 public PAttribute Update(PAttribute pAttribute)
 {
     return(AttributeService.Instance().Update(pAttribute));
 }
예제 #10
0
 public PAttribute Insert(PAttribute pAttribute)
 {
     return(AttributeService.Instance().Insert(pAttribute));
 }
예제 #11
0
        protected virtual void Page_Load(object sender, EventArgs e)
        {
            string Act      = HTTPRequest.GetString("Act");
            int    pagesize = HTTPRequest.GetInt("pagesize", 0);
            int    page     = HTTPRequest.GetInt("page", 0);

            ProductList = tbProductsInfo.GetProductsInfoList("").Tables[0];

            if (Act != "")
            {
                Response.ClearContent();
                Response.Buffer          = true;
                Response.ExpiresAbsolute = System.DateTime.Now.AddYears(-1);

                Response.Expires = 0;
                string Json_Str = "";

                if (ispost)
                {
                    if (Act == "Add")
                    {
                        try
                        {
                            string JsonStr = HTTPRequest.GetString("json");
                            Order  oo      = (Order)JavaScriptConvert.DeserializeObject(JsonStr, typeof(Order));
                            if (oo != null)
                            {
                                if (oo.O_ORDERNUM.Trim() != "")
                                {
                                    if (!Orders.ExistsOrderInfo(oo.O_ORDERNUM))
                                    {
                                        bool      isneworder = false;
                                        OrderInfo oi         = new OrderInfo();
                                        oi.oOrderNum = oo.O_ORDERNUM;
                                        oi.oType     = (oo.O_REMARK == "4") ? 1 : (oo.O_REMARK == "8") ? 2 : (oo.O_REMARK == "1") ? 3 : (oo.O_REMARK == "5") ? 4 : (oo.O_REMARK == "2") ? 5 : (oo.O_REMARK == "3") ? 6 : (oo.O_REMARK == "7") ? 7 : (oo.O_REMARK == "6") ? 10 : 0;
                                        switch (oi.oType)
                                        {
                                        case 1:
                                        case 2:    //供货商
                                            SupplierInfo si = new SupplierInfo();
                                            try
                                            {
                                                si = tbSupplierInfo.GetSupplierInfoModelByName(oo.c_name);
                                                if (si != null)
                                                {
                                                    oi.StoresID          = si.SupplierID;
                                                    oi.oCustomersName    = si.sName;
                                                    oi.oCustomersContact = si.sLinkMan;
                                                    oi.oCustomersTel     = si.sTel;
                                                    oi.oCustomersAddress = si.sAddress;
                                                }
                                            }
                                            finally
                                            {
                                                si = null;
                                            }
                                            break;

                                        case 3:
                                        case 4:
                                        case 5:
                                        case 6:
                                        case 7:
                                            StoresInfo sti = new StoresInfo();
                                            try
                                            {
                                                sti = tbStoresInfo.GetStoresInfoModelByName(oo.c_name);
                                                if (sti != null)
                                                {
                                                    oi.StoresID          = sti.StoresID;
                                                    oi.oCustomersName    = sti.sName;
                                                    oi.oCustomersContact = sti.sContact;
                                                    oi.oCustomersTel     = sti.sTel;
                                                    oi.oCustomersAddress = sti.sAddress;
                                                }
                                            }
                                            finally
                                            {
                                                sti = null;
                                            }
                                            break;

                                        case 10:
                                            oi.StoresID          = 0;
                                            oi.oCustomersName    = "";
                                            oi.oCustomersContact = "";
                                            oi.oCustomersTel     = "";
                                            oi.oCustomersAddress = "";
                                            break;
                                        }

                                        oi.oCustomersOrderID = oo.C_ORDERID;
                                        oi.oCustomersNameB   = oo.C_MD;
                                        StaffInfo sai = new StaffInfo();
                                        sai = tbStaffInfo.GetStaffInfoModelByName(oo.sa_name);
                                        if (sai != null)
                                        {
                                            oi.StaffID = sai.StaffID;
                                        }
                                        oi.UserID         = this.userid;
                                        oi.oAppendTime    = Convert.ToDateTime(oo.O_TIME);
                                        oi.oOrderDateTime = Convert.ToDateTime(oo.O_CREATETIME);
                                        oi.oState         = 0;
                                        oi.oSteps         = 1;

                                        isneworder = (oo.O_ISCHECK == "1") ? true : false;

                                        string tListStr = "";

                                        if (oo.OrderData != null)
                                        {
                                            foreach (OrderData od in oo.OrderData)
                                            {
                                                ProductsInfo pi = new ProductsInfo();
                                                try
                                                {
                                                    pi = tbProductsInfo.GetProductsInfoModelByName(od.p_name);
                                                    if (pi == null)
                                                    {
                                                        pi = tbProductsInfo.GetProductsInfoModelByBarcode(od.p_code);
                                                    }

                                                    tListStr += "{\"OrderListID\":0,\"OrderID\":0,\"StorageID\":1,\"ProductsID\":" + pi.ProductsID + ",\"oQuantity\":" + Convert.ToDecimal(od.s_quantity) + ",\"oPrice\":" + Convert.ToDecimal(od.s_price) + ",\"oMoney\":" + Convert.ToDecimal(od.s_total) + ",\"StoresSupplierID\":" + oi.StoresSupplierID + ",\"IsPromotions\":0,\"oWorkType\":0,\"oAppendTime\":\"" + oi.oAppendTime + "\"," +
                                                                "\"OrderFieldValueInfo\":[{\"OrderFieldValueID\":0,\"OrderFieldID\":1,\"OrderListID\":0,\"oFieldValue\":\"" + od.makedate + "\",\"IsVerify\":0,\"oAppendTime\":\"" + oi.oAppendTime + "\"}," +
                                                                "{\"OrderFieldValueID\":0,\"OrderFieldID\":2,\"OrderListID\":0,\"oFieldValue\":\"" + od.Manufacturers + "\",\"IsVerify\":0,\"oAppendTime\":\"" + oi.oAppendTime + "\"}," +
                                                                "{\"OrderFieldValueID\":0,\"OrderFieldID\":3,\"OrderListID\":0,\"oFieldValue\":\"" + od.Durability + "\",\"IsVerify\":0,\"oAppendTime\":\"" + oi.oAppendTime + "\"}]},";
                                                }
                                                finally
                                                {
                                                    pi = null;
                                                }
                                            }
                                        }
                                        if (tListStr.Trim() != "")
                                        {
                                            tListStr = tListStr.Substring(0, tListStr.Length - 1);
                                        }
                                        tListStr = "{\"OrderListJson\":[" + tListStr + "]}";

                                        oi.OrderListDataJson = (OrderListDataJson)JavaScriptConvert.DeserializeObject(tListStr, typeof(OrderListDataJson));;
                                        int OrderID = Orders.AddOrderInfoAndList(oi);
                                        {
                                            oi = Orders.GetOrderInfoModel(OrderID);

                                            //完成审核操作
                                            Orders.VerifyOrder(oi.OrderID);

                                            tbProductsInfo.UpdateProductsStorageByOrderID(OrderID);//更新当前在途库存情况

                                            OrderWorkingLogInfo owl = new OrderWorkingLogInfo();
                                            owl.OrderID     = oi.OrderID;
                                            owl.UserID      = this.userid;
                                            owl.oType       = 2;
                                            owl.oMsg        = "数据迁移,系统自动处理";
                                            owl.pAppendTime = oi.oAppendTime;

                                            Orders.AddOrderWorkingLogInfo(owl);

                                            if (!isneworder)
                                            {
                                                //完成发货操作
                                                oi.oSteps = 3;
                                                Orders.UpdateOrderInfo(oi);

                                                tbProductsInfo.UpdateProductsStorageByOrderID(OrderID);//更新当前在途库存情况

                                                owl             = new OrderWorkingLogInfo();
                                                owl.OrderID     = oi.OrderID;
                                                owl.UserID      = this.userid;
                                                owl.oType       = 3;
                                                owl.oMsg        = "数据迁移,系统自动处理";
                                                owl.pAppendTime = oi.oAppendTime;

                                                Orders.AddOrderWorkingLogInfo(owl);
                                                //完成收货操作
                                                oi.oSteps = 4;
                                                Orders.UpdateOrderInfo(oi);

                                                tbProductsInfo.UpdateProductsStorageByOrderID(OrderID);//更新当前在途库存情况

                                                owl             = new OrderWorkingLogInfo();
                                                owl.OrderID     = oi.OrderID;
                                                owl.UserID      = this.userid;
                                                owl.oType       = 4;
                                                owl.oMsg        = "数据迁移,系统自动处理";
                                                owl.pAppendTime = oi.oAppendTime;

                                                Orders.AddOrderWorkingLogInfo(owl);

                                                //完成核销操作
                                                oi.oSteps = 5;
                                                Orders.UpdateOrderInfo(oi);

                                                tbProductsInfo.UpdateProductsStorageByOrderID(OrderID);//更新当前在途库存情况

                                                owl             = new OrderWorkingLogInfo();
                                                owl.OrderID     = oi.OrderID;
                                                owl.UserID      = this.userid;
                                                owl.oType       = 5;
                                                owl.oMsg        = "数据迁移,系统自动处理";
                                                owl.pAppendTime = oi.oAppendTime;

                                                Orders.AddOrderWorkingLogInfo(owl);
                                            }
                                            else
                                            {
                                                //完成发货操作
                                                oi.oSteps = 3;
                                                Orders.UpdateOrderInfo(oi);

                                                tbProductsInfo.UpdateProductsStorageByOrderID(OrderID);//更新当前在途库存情况

                                                owl             = new OrderWorkingLogInfo();
                                                owl.OrderID     = oi.OrderID;
                                                owl.UserID      = this.userid;
                                                owl.oType       = 3;
                                                owl.oMsg        = "数据迁移,系统自动处理";
                                                owl.pAppendTime = oi.oAppendTime;
                                            }
                                        }
                                        Json_Str = "{\"results\": true,\"msg\":\"" + oi.OrderID + "\",\"orderid\":\"" + oo.O_ORDERNUM + "\"}";
                                    }
                                    else
                                    {
                                        Json_Str = "{\"results\": false,\"msg\":\"单据已存在.\",\"orderid\":\"" + oo.O_ORDERNUM + "\"}";
                                    }
                                }
                                else
                                {
                                    Json_Str = "{\"results\": false,\"msg\":\"对象为空.\"}";
                                }
                            }
                            else
                            {
                                Json_Str = "{\"results\": false,\"msg\":\"单号为空.\"}";
                            }
                        }
                        catch (Exception ex)
                        {
                            Json_Str = "{\"results\": false,\"msg\":\"" + ex.Message + "," + ex.Data + "\"}";
                        }
                        Response.Charset         = "utf-8";
                        Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                        Response.ContentType     = "application/json";

                        Response.Write(Json_Str);
                    }
                    if (Act == "PAttribute")
                    {
                        int     ProductID    = HTTPRequest.GetInt("pid", 0);
                        string  JsonStr      = HTTPRequest.GetString("JsonStr");
                        int     PriceClassID = 0;
                        decimal Price        = 0;
                        if (ProductID > 0 && JsonStr.Trim() != "")
                        {
                            PAttribute oo = (PAttribute)JavaScriptConvert.DeserializeObject(JsonStr, typeof(PAttribute));
                            if (oo != null)
                            {
                                foreach (PAttributePrice pa in oo.PAttributePrice)
                                {
                                    if (pa != null)
                                    {
                                        if (pa.pr_Name.Trim() != "")
                                        {
                                            try
                                            {
                                                Price        = Convert.ToDecimal(pa.a_Price);
                                                PriceClassID = DataClass.GetPriceClassInfoModel(pa.pr_Name).PriceClassID;
                                                tbPriceClassDefaultPriceInfo.SavePriceClassDefaultPrice(PriceClassID, ProductID, Price, 0);
                                            }
                                            catch
                                            {
                                            }
                                        }
                                    }
                                }
                            }
                            Response.Charset         = "utf-8";
                            Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                            Response.ContentType     = "application/json";

                            Response.Write("{\"results\": true,\"msg\":\"OK.\",\"PID\":" + ProductID + "}");
                        }
                    }
                }
                else
                {
                    if (Act == "GetOrderList" || Act == "GetPAttribute")
                    {
                        WebClient client = new WebClient();
                        byte[]    bytes  = null;
                        if (Act == "GetOrderList")
                        {
                            bytes = client.DownloadData(new Uri("http://erp.bdu9.com/datapost.aspx?Act=" + Act + "&pagesize=" + pagesize + "&page=" + page + ""));
                        }
                        if (Act == "GetPAttribute")
                        {
                            bytes = client.DownloadData(new Uri("http://erp.bdu9.com/datapost.aspx?Act=" + Act + "&pid=" + HTTPRequest.GetInt("pid", 0) + "&pname=" + tbProductsInfo.GetProductsInfoModel(HTTPRequest.GetInt("pid", 0)).pName));
                        }
                        if (bytes.Length == 0)
                        {
                            Response.ContentType = "text/plain";
                            Response.Write("(not loaded)");
                        }
                        else
                        {
                            Response.BinaryWrite(bytes);
                        }
                    }
                }

                Response.End();
            }
        }
예제 #12
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            var attLs = new List <PAttribute>();

            if (String.IsNullOrEmpty(this.txtSchName.Text.ToString()))
            {
                MessageBox.Show("You must enter a schema name, please try again!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if ("select".Equals(this.txtSchName.Text.ToLower(), StringComparison.CurrentCultureIgnoreCase) ||
                "from".Equals(this.txtSchName.Text.ToLower(), StringComparison.CurrentCultureIgnoreCase) ||
                "where".Equals(this.txtSchName.Text.ToLower(), StringComparison.CurrentCultureIgnoreCase))
            {
                MessageBox.Show("Schema name is not valid ( not match with keyword 'select', 'from', 'where')", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            foreach (var item in StaticParams.currentDb.Schemas.ToList())
            {
                if (item.SchemaName.ToLower().Equals(this.txtSchName.Text.ToLower(), StringComparison.CurrentCultureIgnoreCase))
                {
                    MessageBox.Show("This schema name has already existed in the database, please try again !", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            if (!CheckValidatedDataGridView(attrs))
            {
                return;
            }

            //create schema
            PSchema schema = new PSchema();

            schema.id         = RawDatabaseService.Instance().getNextIdSch(); //important
            schema.SchemaName = this.txtSchName.Text.Trim();

            PAttribute attribute;

            //insert Schema and relative component in Db
            try
            {
                #region addAtrr
                foreach (SchemaModelView attr in attrs.ToList())
                {
                    attribute               = new PAttribute();
                    attribute.id            = RawDatabaseService.Instance().getNextIdAttr();
                    attribute.AttributeName = attr.attrName;
                    attribute.primaryKey    = attr.isPri;
                    attribute.Type          = new Domain.Unit.PDataType()
                    {
                        DomainString = attr.domain, DataType = attr.datatype, TypeName = attr.typeName
                    };
                    attribute.Description = attr.descs;
                    attribute.Schema      = schema;

                    RawDatabaseService.Instance().Insert(attribute); //=>csdl need id schema
                    //update full info schema
                    schema.Attributes.Add(attribute);
                }
                //Ps
                var datatype = new PDataType();
                datatype.TypeName = "String";
                datatype.GetDomain("[0  ...  32767] characters");
                datatype.GetDataType();
                var attrPs = new PAttribute()
                {
                    AttributeName = "Ps",
                    id            = RawDatabaseService.Instance().getNextIdAttr(),
                    Schema        = schema,
                    primaryKey    = false,
                    Description   = "Prob",
                    Type          = datatype
                };
                RawDatabaseService.Instance().Insert(attrPs);
                schema.Attributes.Add(attrPs);
                #endregion addAtrr


                //insert scheme in db
                RawDatabaseService.Instance().Insert(schema);

                //insert scheme in ram
                StaticParams.currentDb.Schemas.Add(schema);
                //commit
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (MessageBox.Show("Add successfully. Do you want add new schema ?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                this.txtSchName.Text = "";
                this.attrs.Clear();
                this.dtg.ItemsSource = attrs;
                this.dtg.Items.Refresh();
                this.txtSchName.Focus();
            }
            else
            {
                this.Close();
            }
        }